← All 183 books imagemagick, one operation per page
One operation per page

imagemagick, one operation per page

Twenty-eight lessons on what ImageMagick is: a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images, invoked from the command line as magick or convert, created by John Cristy in 1987, run here as ImageMagick 6.9.12-98 Q16 x86_64; the law of one operation per page; convert and the magick gate, identify; -resize, where a 320x200 image asked for 160x160 came out 160x100; -thumbnail, -crop, which keeps a page offset until +repage, -trim; -rotate, -auto-orient, -border, -gravity; -append, montage, -compose, -layers; -modulate, -level, -normalize, -threshold; -blur, -sharpen, -colors, -colorspace; -annotate, -quality, -strip, and one honest hour.


Steve Hodgkiss 7 lessons

One operation, one page, one real run. That is the shape of this book.

imagemagick, one operation per page

Twenty-eight lessons on what ImageMagick is: a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images, invoked from the command line as magick or convert, created by John Cristy in 1987, run here as ImageMagick 6.9.12-98 Q16 x86_64; the law of one operation per page; convert and the magick gate, identify; -resize, where a 320x200 image asked for 160x160 came out 160x100; -thumbnail, -crop, which keeps a page offset until +repage, -trim; -rotate, -auto-orient, -border, -gravity; -append, montage, -compose, -layers; -modulate, -level, -normalize, -threshold; -blur, -sharpen, -colors, -colorspace; -annotate, -quality, -strip, and one honest hour.


Set in Space Grotesk, Inter and JetBrains Mono (SIL Open Font License).

An honest book about its demos: ImageMagick 6.9.12-98 Q16 x86_64 (Ubuntu apt 8:6.9.12.98+dfsg1-5.2build2) ran on the machine that built this book. Every quoted command and output line was captured from real runs inside the scratch directory /root/.hermes/cache/scratch/imdemo183/ with nothing outside it written. No output was invented. Every other fact traces to the man pages rendered on the build machine, the official ImageMagick 6 documentation pages and the cached Wikipedia articles. No facts come from Reddit, Stack Overflow, vendor blogs or commercial sites. Every practice exercise carries 'this book's plan'. Independent, not affiliated with ImageMagick Studio LLC or the Wikimedia Foundation.

Your purchase is for personal use only. You do not have redistribution rights: please do not share, resell, or republish this book or its pages.

© 2026 Steve Hodgkiss. All rights reserved. Personal use only; no redistribution rights.

Edition 1.0 · stevehodgkiss.net

Contents

Contents


Part 1 · The command and its images
identify4
Part 2 · Size and shape
-crop5
Part 3 · Turns and frames
-gravity6
Part 4 · Joining images
-layers7
Part 5 · Tone and color
-threshold8
Part 6 · Blur, sharpness, color count
-sharpen9
Part 7 · Text, files, the honest hour
One honest hour10

Per identify(1), describes the format and characteristics of one or more image files; It also reports if an image is incomplete or corrupt; the identify command is strictly read only. Per a real local run captured at dispatch, identify base.png gradient.png plasma.png checker.png; plasma.png PNG 320x200 320x200+0+0 16-bit sRGB 348017B 0.000u 0:00.000; base.png PNG 320x200 320x200+0+0 8-bit sRGB 2c 181B 0.000u 0:00.000; checker.png PNG 320x200 320x200+0+0 8-bit Grayscale Gray 16c 384B 0.000u 0:00.000.

imagemagick companion · No. 01
the proof

identify

what the machine says about a file

identify: one line per file, and strictly read onlyplasma.pnga PNG on diskplasma.png PNG 320x200 320x200+0+0 16-bit sRGB 348017B 0.000u 0:00.000the captured identify lineformatPNGsize320x200page+0+0depth16-bitcolorspacesRGBbytes348017Bname, format, size, page, depth, colorspace, bytes:identify before you change anythingthe format and characteristics of one or more image files

Per identify(1), it describes the format and characteristics of one or more image files, also reports if an image is incomplete or corrupt, and is strictly read only.

A real local run: identify base.png gradient.png plasma.png checker.png printed plasma.png PNG 320x200 320x200+0+0 16-bit sRGB 348017B 0.000u 0:00.000. Name, format, size, page, depth, colorspace, bytes: one line per file.

Before any operation, identify is how you know what you started from.

ONE HONEST OPERATION

What would identify print for the last image file you opened?

Per the official ImageMagick 6 options reference, Cut out one or more rectangular regions of the image; The width and height of the geometry argument give the size of the image that remains after cropping; Similarly you may want to use +repage after cropping to remove the page offset that will be left behind; You can add the @ to the geometry argument to equally divide the image into the number of tiles generated. Per a real local run captured at dispatch, convert plasma.png -crop 100x100+50+40 crop.png; crop.png PNG 100x100 320x200+50+40 16-bit sRGB 54651B 0.000u 0:00.000; convert crop.png +repage crop_repage.png; 100x100+0+0; convert checker.png -crop 2x2@ tile_%d.png; tile_0.png PNG 160x100 320x200+0+0 8-bit Grayscale Gray 16c 254B 0.000u 0:00.000.

imagemagick companion · No. 02
the cut

-crop

cut a window out, mind the offset

crop: a window at +50+40, and the page offset it leaves behind+50+40plasma.png, 320x200100x100crop.png320x200+50+40page offset left behind+repage100x100+0+0-crop 2x2@four 160x100 tilestile_0.png to tile_3.pngcrop keeps the memory of where it was;+repage lets it go100x100 cut at +50+40; the page offset stays until +repage

Per the options reference, -crop will Cut out one or more rectangular regions of the image; the width and height give the size that remains, the offsets place its corner.

A real local run: convert plasma.png -crop 100x100+50+40 crop.png left the page offset 320x200+50+40 behind. convert crop.png +repage crop_repage.png reset it to 100x100+0+0; -crop 2x2@ made four equal tiles.

Crop keeps the memory of where it was; +repage is how you let it go.

ONE HONEST OPERATION

Which matters more for your next crop: the exact window, or where it sat on the page?

Per the official ImageMagick 6 options reference, Sets the current gravity suggestion for various other settings and options; The direction you choose specifies where to position text or subimages; By default, the image gravity is undefined; Set the image size and offset; If the image is enlarged, unfilled areas are set to the background color. Per a real local run captured at dispatch, convert base.png -background white -gravity center -extent 400x300 extent.png; extent.png 400x300+0+0; convert base.png -background white -gravity northwest -extent 400x300 extentnw.png; convert -list gravity; NorthWest; North; NorthEast; West; Center; East; SouthWest; South; SouthEast.

imagemagick companion · No. 03
the anchor

-gravity

where text and images land

gravity: the anchor for text, for subimages, for -extentNorthWestNorthNorthEastWestCenterEastSouthWestSouthSouthEastconvert -list gravity400x300320x200convert base.png -background white-gravity center -extent 400x300extent.pngextent.png 400x300+0+0the image lands centeron a white 400x300 canvasunfilled areas take the backgroundgravity is the anchor; -extent is the canvas you anchor on

Per the options reference, -gravity Sets the current gravity suggestion for various other settings and options; The direction you choose specifies where to position text or subimages.

A real local run: convert base.png -background white -gravity center -extent 400x300 extent.png gave extent.png 400x300+0+0: the 320x200 image centered on white, the unfilled area taking the background color. convert -list gravity printed NorthWest, Center and the rest.

Gravity is the anchor; -extent is the canvas you anchor on.

ONE HONEST OPERATION

Which corner would you anchor a caption to, and why not the center?

Per the official ImageMagick 6 options reference, Handle multiple images forming a set of image layers or animation frames; Create a canvas the size of the first images virtual canvas using the current -background color, and -compose each image in turn onto that canvas; Equivalent to a call to the -coalesce operator; Use +repage to completely remove/reset the virtual canvas meta-data from the images. Per a real local run captured at dispatch, convert base.png gradient.png plasma.png -layers flatten flat.png; flat.png 320x200+0+0; convert -delay 20 base.png gradient.png plasma.png anim.gif; anim.gif[0] GIF 320x200 320x200+0+0 8-bit sRGB 2c 0.010u 0:00.000; convert anim.gif -coalesce coal_%d.png; coal_1.png PNG 320x200 320x200+0+0 8-bit sRGB 65c 1770B 0.000u 0:00.000; convert -page +0+0 base.png -page +40+30 gradient.png -layers flatten flat_off.png; flat_off.png 320x200+0+0.

imagemagick companion · No. 04
the stack

-layers

flatten, coalesce, repage a sequence

layers: a stack flattened to one canvas, frames coalesced3 layersbase, gradient, plasma-layersflattenflat.png 320x200+0+0320x200+repageresets the virtual canvas meta-datacoalesce: anim.gif, three full framesconvert anim.gif -coalesce coal_%d.pngcoal_1.png PNG 320x200 320x200+0+0every frame the full 320x200flatten ends a sequence; coalesce fills each frame in

Per the options reference, -layers will Handle multiple images forming a set of image layers or animation frames. Flatten composes each image in turn onto one canvas.

A real local run: convert base.png gradient.png plasma.png -layers flatten flat.png gave flat.png 320x200+0+0, three images into one; convert anim.gif -coalesce coal_%d.png made each frame full. +repage resets the virtual canvas meta-data.

Flatten ends a sequence; coalesce fills each frame in.

ONE HONEST OPERATION

Which of your sequences is a stack to flatten, and which is an animation to keep?

Per the official ImageMagick 6 options reference, Apply simultaneous black/white threshold to the image; Any pixel values (more specifically, those channels set using -channel ) that exceed the specified threshold are reassigned the maximum channel value, while all other values are assigned the minimum; -monochrome Transform the image to black and white; Simulate a sepia-toned photo; A threshold of 80% is a good starting point for a reasonable tone. Per a real local run captured at dispatch, convert plasma.png -threshold 50% thr50.png; thr50.png 2 gray(0) gray(0); convert plasma.png -monochrome mono.png; mono.png 2 gray(0) gray(255); convert plasma.png -sepia-tone 80% sepia80.png; sepia80.png 32399 srgb(75.8206%,40.6851%,0%) srgb(92.7123%,58.2834%,6.64225%); convert base.png -sepia-tone notanumber bad2.png; convert-im6.q16: invalid argument for option `-sepia-tone': notanumber @ error/convert.c/ConvertImageCommand/2687.; [exit 1].

imagemagick companion · No. 05
the line

-threshold

every pixel to black or white

threshold: one line; every pixel to black or white50%plasma, by intensitythr50.png: 2 colors-monochromemono.png 2 gray(0) gray(255)-sepia-tone 80%sepia80.png 32399convert-im6.q16: invalid argument for option `-sepia-tone': notanumber[exit 1]above the line white, below it black; monochrome draws the line for you

Per the options reference, -threshold will Apply simultaneous black/white threshold to the image: values above the line take the maximum, all other values are assigned the minimum.

A real local run: convert plasma.png -threshold 50% thr50.png left thr50.png 2 gray(0) gray(0); monochrome left two colors too; -sepia-tone at 80% kept 32399, and a bad value failed with invalid argument for option `-sepia-tone': notanumber.

Threshold draws one line; monochrome is the same line drawn for you.

ONE HONEST OPERATION

Which would you want for a scanned page: two tones, or the sepia warmth?

Per the official ImageMagick 6 options reference, Sharpen the image; Use a Gaussian operator of the given radius and standard deviation (sigma); Sharpen the image with an unsharp mask operator; The fraction of the difference between the original and the blur image that is added back into the original (default 1.0); Detect edges within an image; Emboss an image. Per the Wikipedia Unsharp masking article, the technique uses a blurred, or "unsharp", negative image to create a mask of the original image. Per a real local run captured at dispatch, convert blur3.png -sharpen 0x1 sharp1.png; convert blur3.png -unsharp 0x1 unsharp1.png; convert checker.png -edge 1 edge1.png; convert checker.png -emboss 1 emboss1.png; blur3.png gray(146) gray(144) gray(144); sharp1.png gray(146) gray(145) gray(145); edge1.png gray(0) gray(0) gray(0); emboss1.png gray(224) gray(224) gray(224).

imagemagick companion · No. 06
the crisp

-sharpen

sharpen, unsharp, edge, emboss

sharpen: a notch crisper; edge and emboss redraw the outlinesblur3.png: a soft edge-sharpen 0x1-edge 1-emboss 1sharpen nudges the edge back;edge finds the outline;emboss lifts it to light graysharp1.png gray(146) gray(145) gray(145)edge1.png gray(0) gray(0) gray(0)emboss1.png gray(224) gray(224) gray(224)convert blur3.png -sharpen 0x1 sharp1.pngconvert checker.png -edge 1 edge1.pngsharpen nudges; edge and emboss redraw from the outlines

Per the options reference, -sharpen will Sharpen the image with a Gaussian operator of the given radius and sigma; -unsharp adds back the difference between the original and the blur image.

A real local run on the blurred checkerboard: convert blur3.png -sharpen 0x1 sharp1.png read sharp1.png gray(146) gray(145) gray(145), crisper than gray(144). -edge 1 left edge1.png gray(0) gray(0) gray(0) in the flat middle; -emboss 1 read gray(224).

Sharpen nudges; edge and emboss redraw from the outlines.

ONE HONEST OPERATION

Which would you sharpen, a soft portrait or a screenshot of text, and by how much?

Per this book's plan, one honest hour of practice is: run convert -version, make a base image with convert -size 320x200 xc:navy base.png, read it with identify base.png, resize it with -resize 160x160, crop it with -crop 100x100+50+40 and reset the page with +repage, border it with -border 10x10, join two with +append, flatten a sequence with -layers flatten, write it small with -quality 75 and clean it with -strip; every one of these commands ran on the build machine inside the scratch directory /root/.hermes/cache/scratch/imdemo183/, and nothing outside it was written.

imagemagick companion · No. 07
the handoff

One honest hour

a practice plan, labelled as such

one honest hour: eight moves, planned and labelled1check the versionconvert -version2make a base imagexc:navy at 320x2003identify itidentify base.png4resize, crop, repage160x160, then +repage5border-border 10x106append+append7flatten-layers flatten8quality, stripquality 75, then stripthis book's plan: eight operations, one hour, every line traced to a runone hour in one directory: resize, crop, read back, throw away

Per this book's plan, one honest hour: check the gate with convert -version, then convert -size 320x200 xc:navy base.png and identify base.png before anything else.

Then the moves in order: -resize 160x160, -crop 100x100+50+40 and +repage, -border 10x10, +append, -layers flatten, -quality 75, -strip. Eight operations, each first run here.

One hour in one directory: an image you can resize, crop, read back and throw away.

ONE HONEST OPERATION

Book the hour this week; which of the operations will surprise you most?

Index

Index


-crop5
-gravity6
-layers7
-sharpen9
-threshold8
identify4
One honest hour10