Getting started with Imagemagick

2,917 views

Published on

A very quick introductory course on ImageMagick. Part of our standard training courses for offshore software developers at Zeropoint.IT

Published in: Technology, Art & Photos
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,917
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
19
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Getting started with Imagemagick

  1. 1. Introduction The absolute basics Let’s get a little more advanced Introduction to ImageMagick Bart Van Loon 2nd February 20121 / 13 Bart Van Loon Introduction to ImageMagick
  2. 2. Introduction The absolute basics Let’s get a little more advanced 1 Introduction 2 The absolute basics 3 Let’s get a little more advanced2 / 13 Bart Van Loon Introduction to ImageMagick
  3. 3. Introduction The absolute basics Let’s get a little more advanced Introduction ImageMagick® ImageMagick is an Open Source software suite to create, edit, compose, or convert bitmap images. ImageMagick: mind the spelling, and camel-case Open Source: Apache 2.0 license (GPLv3 compatible) software suite: more than ten binaries create, edit, compsose or convert: extremely versatile tools bitmap images: over 100 formats supported, but all bitmaps3 / 13 Bart Van Loon Introduction to ImageMagick
  4. 4. Introduction The absolute basics Let’s get a little more advanced Did I mention extremely versatile? features : 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, . . . bindings : MagickCore (C), MagickWand (C), ChMagick (Ch), Magick++ (C++), JMagick (Java), L-Magick (Lisp), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), PythonMagick (Python), RMagick (Ruby), TclMagick (Tcl/TK), ... platforms : runs on all major operating systems We will focus on simple command line usage.4 / 13 Bart Van Loon Introduction to ImageMagick
  5. 5. Introduction The absolute basics Let’s get a little more advanced Overview of some of the binaries animate : animates an image or image sequence compare : annotates the difference between images composite : overlaps one image over another conjure : executes scripts in the Magick Scripting Language convert : converts between image formats and much more display : displays an image or image sequence identify : describes the characteristics of image files import : saves any visible area and outputs it as an image file mogrify : is like convert but works on the original image file montage : creates an image by combining several images5 / 13 Bart Van Loon Introduction to ImageMagick
  6. 6. Introduction The absolute basics Let’s get a little more advanced Conversion of file formats Binary to use is convert. Example: $ convert image.png image.jpg It guesses the required format from the target filename extension.6 / 13 Bart Van Loon Introduction to ImageMagick
  7. 7. Introduction The absolute basics Let’s get a little more advanced Identifying images Binary to use is identify. Examples: $ identify pic.jpg pic.jpg JPEG 170x100 170x100+0+0 8-bit DirectClass 7.75KB 0.000u 0:00.000 $ identify pic.png pic.png PNG 960x191 960x191+0+0 8-bit DirectClass 104KB 0.000u 0:00.0007 / 13 Bart Van Loon Introduction to ImageMagick
  8. 8. Introduction The absolute basics Let’s get a little more advanced Changing the size of an image Binary to use is convert or mogrify. The switch is -scale: $ convert -scale 100x250 pic.png png small.png or $ mogrify -scale 100x250 pic.png The -scale switch takes a “geometry” as argument. A simple “geometry” looks like <W>x<H> where <W> is a width; and <H> is a height. One of both can be ommitted!8 / 13 Bart Van Loon Introduction to ImageMagick
  9. 9. Introduction The absolute basics Let’s get a little more advanced Adding a frame to an image Again, convert (or mogrify) can take care of this. Example: $ convert -border 2 -bordercolor black pic.png frame.png More sexy example: $ convert -caption "My latest Polaroid" pic.png -gravity center -background black +polaroid polaroid.png9 / 13 Bart Van Loon Introduction to ImageMagick
  10. 10. Introduction The absolute basics Let’s get a little more advanced Making a screenshot For making screenshots, import is a great tool. Example uses: $ import window.jpg # now click on a window with your mouse $ import -rotate 30 area.png # now draw a rectangle with your mouse $ sleep 5; import -window root all.tiff10 / 13 Bart Van Loon Introduction to ImageMagick
  11. 11. Introduction The absolute basics Let’s get a little more advanced A real story For a project, we needed drawings of various pieces of clothing. Our script expected a bunch of .png-files like11 / 13 Bart Van Loon Introduction to ImageMagick
  12. 12. Introduction The absolute basics Let’s get a little more advanced A real story But we only had .pdf-documents that looked like Hundreds of them. . .11 / 13 Bart Van Loon Introduction to ImageMagick
  13. 13. Introduction The absolute basics Let’s get a little more advanced A real story So for each .pdf-file we had to: convert the .pdf-files to the .png-format; cut the original images in two to separate the drawings of the front side from those of the back side of the clothing; set all the images on a transparent background; and fix the filenames of the resulting .png images. We did this with a simple ImageMagick script (the loop and file renaming was taken care of by bash) which saved both a developer and a designer a day of boring, repetitive work.11 / 13 Bart Van Loon Introduction to ImageMagick
  14. 14. Introduction The absolute basics Let’s get a little more advanced The time saving script Now what would this script have looked like, you think?12 / 13 Bart Van Loon Introduction to ImageMagick
  15. 15. Introduction The absolute basics Let’s get a little more advanced References http://imagemagick.org http://www.soton.ac.uk/~fangohr/computing/imagemagick.html13 / 13 Bart Van Loon Introduction to ImageMagick

×