gif animation with a transparent background - animation

In matplotlib, I am trying to save a gif animation with a transparent background. I have tried this:
ani.save('tsk_julaug24.gif',writer='imagemagick',savefig_kwargs=dict(facecolor='w',transparent=True))
but could not get the transparent background.
Any hints to solve this issue?
Thanks

The following ImageMagick command lines solved the issue:
magick.exe mogrify -transparent white -fuzz 2%% in.gif
magick.exe in.gif -define trim:percent-background=0% out.gif

Related

Cutting out a mask from a image with ImageMagick

I'm trying to cut out a shape from an image based on a mask I have. I tried a number of ways but I'm really struggling to get the result I need.
I'm using ImageMagick 7.1.0-51 Q16-HDRI on Windows.
The "base" image:
https://imgur.com/a/j1kioWu
The mask i'm using:
https://imgur.com/a/OcArICa
Expected result(photoshoped):
https://imgur.com/a/GjRoxyS
Edit: Reuploaded direct on imgur to maintain transparent background
In Imagemagick, you want to invert (negate) the polarity of black and white, then do a -compose difference -composite, then invert again.
Hair:
Face:
magick hair.png face.png -alpha off -colorspace gray -negate -compose difference -composite -negate result.png
Result:
If you want pure white in the face area, threshold the two images after the conversion to grayscale
magick hair.png face.png -alpha off -colorspace gray -auto-threshold otsu -negate -compose difference -composite -negate result2.png
Result 2:
ADDITION
If your input images have transparent backgrounds, then you have to extract the alpha channels, combine them to do the difference and then put that alpha channel back on the input.
Unix Syntax:
magick hair.webp \
\( +clone face_mask.webp -alpha extract -compose difference -composite \) \
-alpha off -compose copy_opacity -composite result.png
For Windows,remove the \ in front of the parentheses and change the end of line \ to ^.

video from images, but only imagemagick created pixelized

I am trying to make video from images. First i create images with imagemagick (simple version):
convert -background transparent -size 1280x720 -gravity center
caption:'text' 0.png
then ffmpeg(simple version):
ffmpeg -framerate 0.5 -i 0.png debug.mp4
and this is what happens: http://prntscr.com/qy5i08 do you see the difference? Image and video resolution is the same 1280x720
I used another png image not created with imagemagick and there is no difference. Why is that?
The issue was -background transparent
When using background black than the quality is normal.

How I can remove background color from image using GraphicsMagick?

How I can remove background color from image using GraphicsMagick? I need to delete rgb(255,255,255) and rgb(254,254,254) colors from image and replace them to transparency.
Thank you.
you should tinker with fuzz -parameter to match #fefefe
gm convert in.png -fuzz 3% -transparent "#ffffff" out.png
Should comment but cannot.
gm convert -geometry 50x50! -background white -extent 0x0 +matte in.png out.jpg or
gm convert -background color -extent 0x0 +matte src.png dst.png

Combining images in ImageMagick with drop shadow

I am cropping and blurring a 960x960px image to 960x416 using GraphicsMagick:
gm convert -resize 960x416^ -gravity center -crop 960x416+0+0 +repage in.jpg bg.png
gm mogrify -gaussian 25x10 bg.png
After that, I create a 200x200px thumbnail of same initial image:
gm convert -resize 200x200 in.jpg top.png
On the last step, I combine both images, where the thumbnail will be placed on the top left position of the background image:
gm composite top.png bg.png -geometry 960x416+50+16 out.jpg
This works like a charm. But what I now need is a automatically generated dropshadow for the image top.png when it will be composited on the top of the bg.png in the last step. Is this possible?

Imagemagick gradient from left and right

I want to use Imagemagick to add a transparent gradient from the left and right to be composed with an image.
I can generate the image with:
convert -size 100x100 gradient: -function Polynomial -4,4,0 -distort SRT 90 gradient.png
And it looks like:
I can also compose that image on top of the image I want with:
composite original.jpg -compose Multiply gradient.png final_image.jpg
All of this works fine. My question is, how do I change the color of that gradient?
Thanks!
Simply add comma-separated colors after gradient: option:
convert -size 100x100 gradient:white,blue -function Polynomial -4,4,0 -distort SRT 90 gradient.png
Note, that -function converts channels too, so colors in gradient wont be original.
Found a way around this by doing
convert input.jpg -alpha set -virtual-pixel transparent -background red -channel A -blur 0x34 -level 75%,100% +channel -flatten final.jpg
which works in my case, giving me:

Resources