I want to change size of GIF animation image using python and PIL or PythonMagick. I can't find solution. PIL and thumbnail method works for jpg and png but not for gif. ImageMagick has command mogrify/convert -resize '1280x1024>' but i can't find documentation and i don't know how to do it with pythonmagick.
Anyone knows solution?
In the worst case i use os/subprocess and convert ;-S
Thanks.
You can use PIL and
images2gif
, a short PIL based module linked to on this blog page, and available here. Code used to process thisrose.gif
is below. I set theimages2gif.readGif
'read as numpy array' property tofalse
in order to get a list of PIL images so as I could use the PILthumbnail
function.Orignial: Processed:
I'm not sure how to preserve transparency, my attempts to do so have failed (so far).
Some amazing person made an updated version of images2gif.py that accounts for transparency:
https://bitbucket.org/bench/images2gif.py/overview
There are still some artifacts, but it's way better than the original!