ImageMagickTable of contents IntroductionImageMagick(R), is a software suite to create, edit, and compose bit- map images. It can read, convert and write images in a variety of for- mats (about 100) including GIF, JPEG, JPEG-2000, PNG, PDF, PhotoCD, TIFF, and DPX. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bezier curves. ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you can freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems. The functionality of ImageMagick is typically utilized:
This tiny introduction focuses on the command line use which is extremely useful if the same operation has to be carried out repeatedly (and automatically). Typical examples include post processing of some kind of data, dynamic and automatic creation of bitmaps for webpages, or just the odd conversion or annotation of a collection of photos. We point the interested reader to http://www.imagemagick.org for the full documentation, download and installation of the software. Conversion of file formatsThe command line tool to convert from one graphics format to another is convert. The basic usage is straight forward: convert pic.png pic.jpg The convert command guesses the required format from the filename extension (i.e. from png to jpg). We use the ImageMagick logo (stored in file pic.png) in the following examples Identifying image typesThe identify command allows quick identification of image files: fangohr$ identify pic.jpg pic.jpg JPEG 632x478 632x478+0+0 DirectClass 8-bit 87.5605kb fangohr$ identify pic.png pic.png PNG 632x478 1280x800+3+44 DirectClass 16-bit 141.225kb Changing the sizeFirst, we'll make the image we have somewhat smaller. For example, suppose we would like to limit it to 250 pixel in the x-direction: convert -geometry 250 pic.png small.png The number of pixels in the other direction (i.e. y) will be chosen such that the proportions of the image are preserved: fangohr$ identify small.png small.png PNG 250x189 506x316+1+17 DirectClass 16-bit 72.3418kb Here is the smaller image: Adding a frameActually, the size of the image would be better visible if we had a frame around the image. Here is the command to create a frame of 2 pixels in color black: convert -geometry 250 -border 2 -bordercolor black pic.png small_frame.png Adding labelsThere is a multitude of possible ways to add labels to a picture. One is to use the montage command line utility which can create a montage by putting together several pictures. This is often used to create index thumbnail pages for directories with many pictures. Here, we put together our normal image, and a piece of text ("My label below"): montage -geometry +0+0 -background skyblue -label "My label below" \ small.png small_label.png which results in this picture ImageMagick has a number of quite sophisticated image processing options which includes the polaroid switch: convert -caption "My latest Polaroid" small.png -gravity center \ -background black +polaroid small_polaroid.png We point to http://www.imagemagick.org/Usage/annotating for a lengthy list of examples. SummaryIn summary, the ImageMagick toolbox and library is an extremely powerful tool that can be used for tasks ranging from the occasional image processing job to the fully automated production or processing of large numbers of files. As with any sophisticated tool, there is some overhead in understanding how it works before it can be used effectively. All one can hope to achieve in a very short introduction like this is to point out the existence of the package. Acknowledgements: parts of this short article have been taken from the ImageMagick Documentation. (Hans Fangohr) Addition April 2021Creation of favicon.ico from a bitmap favicon.png can be one with a one-liner: convert favicon.png -define icon:auto-resize=128,64,48,32,16 favicon.ico Source: https://gist.github.com/pfig/1808188 convert favicon.png -define icon:auto-resize=64,48,32,16 favicon.ico |
|