is a utility that allows users to manipulate images with command lines
. While most imaging software
have elaborate graphical user interfaces with plenty of special effects to choose from, ImageMagick
can perform operations on the image from the command line
. This utility is particularly useful for projects where there is a need to automate work on images. ImageMagick
is available for Windows and Linux operating systems. With ImageMagick
, an image can be converted from one format to another or a text can be added to the image from the command line.
ImageMagick is a powerful command line tool that allows you to manipulate images.
The advantage of this tool is that it allows:
- Automated work on images (this avoids having to do some manipulation in Photoshop or Gimp).
- Implement operations and conversion of a blow to hundreds of images at once.
- To convert between different image formats
- To create images on the go
- To be incorporated into your programs and scripts (this allows your programs and scripts to generate and manipulate images on the fly). For example, it is usable with PHP to generate images.
This program is available for Windows and Linux.
Install ImageMagick on Windows:
- 1. Download ImageMagick
- 2. Install it. During installation, be sure to properly check the "Update executable search path"
- 3. Close and re-open your session (or restart the computer). This step is necessary for the path (PATH) ImageMagick to be taken into account.
To verify the installation, open an MS-DOS window and type: convert--version
You should see,
Version: ImageMagick 6.3.3 04/08/07 Q16 file:///usr/local/share/doc/ImageMagick
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC
Convert an image from one format to another
- Convert an image in bmp png:
convert image.bmp image.png
- Convert an image in jpg bmp progressive, quality 70%:
convert image.bmp -interlace line -quality 70 image.png
The -quality xoption
allows you to adjust the quality of JPEG.
can create JPEG progession.
Prepare a photo for the web
The operations are:
- Reduce the image resolution (eg, switch from 2592x1944 (5 Mega-pixels) to 800x600)
- Progressive JPEG compressed (for an immediate display of the image in the page)
- Delete unecessary information (comments, EXIF ...: This information (miniature, name of the software that created this file, camera settings when shooting (EXIF), etc..) is ignored by browsers.
convert maphoto.jpg -resize 800x600 -strip -quality 50 -interlace line imageweb.jpg
Put a text on an image
- -resize AxBresizes the image to the desired size.
- -strip remove additional information (EXIF, comments ...)
- -quality 50 can select a quality of 50% for the JPEG compression.
- -Interlace line creates a progressive JPEG.
To avoid getting given a high resolution image without permission, you can add a text on the entire surface of the image.
convert -size 150x50 xc:none -matte -pointsize 20 -fill #ffffff80 -draw "text 10,30 'My copyright'" miff:- | composite -tile - photo.jpg resultat.jpg
Apply a transformation to a group of images
To simplify the previous explanations, examples were given on a single image.
But it is possible to perform these operations at once on many images.
Recompress JPEG images in the current directory as 70 (exit in the output sub-directory):
FOR %%G IN (*.jpg) DO convert "%%G" -strip -quality 70 -interlace plane "output/%%G"
Convert all files from .BMP to. JPG :
FOR %%G IN (*.bmp) DO convert "%%G" -strip -quality 70 -interlace plane "%%~nG.jpg"
(~ n means that it only takes the filename (without the extension).)