Image Magick: Cheat Sheet - Resize, Make Animated Gif, Change Background Color to transparent

@pen1710 - 15-12-18

Resize

http://www.howtogeek.com/109369/how-to-quickly-resize-convert-modify-images-from-the-linux-terminal/

ImageMagick will try to preserve the aspect ratio if you use this command. It will alter the image to fit within a 200×100 area, but the image may not be exactly 200×100.

In [ ]:
convert example.png -resize 200×100 example.png
In [ ]:
convert -delay 120 -loop 0 *.png animated.gif

Change background color to transparent

Works only if the background has only one color.

In [1]:
convert balloon.gif -transparent blue balloon_trans.gif
  File "<ipython-input-1-b67e3939fb78>", line 1
    convert balloon.gif -transparent blue balloon_trans.gif
                  ^
SyntaxError: invalid syntax

For all .pngs in a folder:

In [ ]:
 for file in *.png ; do convert "${file}" -transparent '#ffcc66' "batch/${file}"

On Windows: Vorssetzung: Es gibt einen Ornder mit den Bildern, darin einen Ordner 'final' für die fertigen Bilder anlegen. Dann CMD starten und folgenden Code eingeben:

In [ ]:
FOR %G IN (*.png) DO convert %G -transparent #FFFFFF final\%G