natjohan's blog

Posted sam. 29 d├ęcembre 2012

Tip of the week 1


Who has never needed to change an image to put on a website that accepts only a certain size (i.e. 220x220px) ?

ImageMagick is a powerful command line suite tool that allow to resize/convert/compare/composite your pictures, and more.


You can download ImageMagick here. But it's available in Fedora packets :

natjohan# yum install ImageMagick
Note : ImageMagick is also available on MacOs, Ios, Win

Quick references

Here is some quick reference to use ImageMagick (but you should read the manual with man imagemagick) :


Change the size of a picture (in px), just note that command just resize (for crop there is -crop option) :

natjohan$ convert -resize 220x220 picture.png newsize.png

Convert a jpeg image in png (this command works with many format) :

natjohan$ convert picture.jpeg picture.png

Convert a lot of pictures (and keep the same name):

natjohan$ convert *.jpeg -set filename:f '%t.png' +adjoin '%[filename:f]'

resize your picture before convert :

natjohan$ convert picture.jpeg -resize 30% picture.png

create a pdf doc with several pictures :

natjohan$ convert -compress jpeg picture_*.jpeg mydoc.pdf

create a gif with some pictures :

natjohan$ convert picture_*.jpeg mybeautifulgif.gif

note you can adjust delay between each pictures with -delay 60 (in centisecond)


You can compare the differences between two or more pictures and show the diff in a third picture:

natjohan$ compare picture1.jpg picture2.jpg pictureDiff.jpg


Show information about your picture :

natjohan$ identify 1234.JPG
1234.JPG JPEG 1182x1182 1182x1182+0+0 8-bit DirectClass 245KB 0.000u 0:00.000

for your scripts, you can retrieve specific info, example :

natjohan$ identify -format "width  %w px" 1234.JPG
width  1182 px


You can also use a little GUI for ImageMagick with the display command :

natjohan$ display picture.jpg

Go further

There is a book about ImageMagick, yeah !

Category: ToTW
Tags: tool tip ImageMagick