Home / Alt manpages / imagemagick-im6.q16(1)

  • imagemagick-im6.q16(1)
  • User command
  • linux

Resize and Inspect Images Safely with ImageMagick 6

ImageMagick's convert and identify turn a big photo into a smaller copy while confirming its dimensions and format. Do it this way and you dodge the easy mistake of overwriting the source. This guide uses the installed Debian package imagemagick-6.q16, which provides ImageMagick 6.9.12-98 with Q16 support. Allow about 10 minutes if the package is already installed.

Prerequisites: a shell, an input image you can read, and a directory where you can write the output. The examples use convert-im6.q16 and identify-im6.q16, the versioned commands installed on this system.

1. Check the installed commands and source image

Start by checking the program version and the input file. This catches a missing package and confirms you are measuring the file you think you are measuring:

convert-im6.q16 -version
identify-im6.q16 /path/to/input.jpg

The first command should report ImageMagick 6.9.12-98 and Q16 on this machine. The second prints properties such as format, width, height, colour depth and file size; the output varies with the image, but it should name the input and show dimensions such as 1920x1080.

Use a real path in place of /path/to/input.jpg. Do not put a wildcard in this first check: identify-im6.q16 *.jpg is useful later, but it can produce a long list and make it easy to inspect the wrong file.

Checkpoint

You have a readable input file, know its current dimensions, and have confirmed which ImageMagick 6 binary is running.

2. Make a proportional smaller copy

Use -resize with a maximum width and height, then give the output a different filename. The > modifier means "only shrink images larger than this size", and stops a small source from being enlarged:

convert-im6.q16 /path/to/input.jpg \
  -resize '1200x1200>' \
  /path/to/output-small.jpg

The output keeps the source aspect ratio. A wide image might become 1200x675; a tall one might become 800x1200. The command writes a new file and leaves input.jpg untouched.

Verify both files explicitly:

identify-im6.q16 /path/to/input.jpg /path/to/output-small.jpg
test -s /path/to/output-small.jpg && echo "output exists and is non-empty"

Quote the geometry exactly as shown. In an interactive shell, an unquoted > is redirection syntax rather than part of the ImageMagick argument. The trailing backslash on the first line is also part of the shell command: it joins the next line onto it.

3. Convert to a different format

ImageMagick normally infers the output format from the filename extension. For a PNG copy, keep the input first and use a .png output name:

convert-im6.q16 /path/to/input.jpg \
  -resize '1200x1200>' \
  /path/to/output-small.png

Check that the result is actually PNG rather than trusting the name:

identify-im6.q16 -format '%m %wx%h %b\n' /path/to/output-small.png

The output should show three fields: PNG, dimensions such as 1200x675, and a byte count. -format controls this compact output: %m is the format, %w and %h are width and height, and %b is the file size.

JPEG and PNG suit different jobs. JPEG usually works for photographs. PNG usually works better for sharp text, diagrams and transparency. Conversion can discard information, so keep the original and inspect the result before replacing anything.

4. Control JPEG size deliberately

For a JPEG output, -quality accepts a value from 0 to 100. Higher values usually mean a larger file with less visible compression, but the exact result depends on the image:

convert-im6.q16 /path/to/input.png \
  -resize '1600x1600>' \
  -quality 85 \
  /path/to/photo-web.jpg

Measure the result and compare it visually with the source:

identify-im6.q16 -format '%m %wx%h %b\n' /path/to/photo-web.jpg
ls -lh /path/to/input.png /path/to/photo-web.jpg

Do not treat 85 as a universal quality target. If text shows ringing or fine detail has vanished, try a higher value. If the file is still too big, cut the dimensions first or try a lower value, then check again.

5. Process several files without changing the originals

For a small, known set of files, name each input and output explicitly. It is more typing, but it makes the mapping auditable and avoids accidental overwrites:

convert-im6.q16 ./photo-01.jpg -resize '1200x1200>' ./web-photo-01.jpg
convert-im6.q16 ./photo-02.jpg -resize '1200x1200>' ./web-photo-02.jpg
identify-im6.q16 ./web-photo-01.jpg ./web-photo-02.jpg

With a wildcard, remember that one convert invocation treats multiple input images as an image sequence, which can combine or process them differently from the one-input, one-output pattern above. A shell loop keeps each output separate.

Create ./web before running that loop, and check the list first:

mkdir -p ./web
printf '%s\n' ./photos/*.jpg

If the glob matches nothing, some shells pass the literal pattern straight to the command. Treat that as a reason to check the directory, not a signal to widen the pattern:

for input in ./photos/*.jpg; do
  output="./web/$(basename "$input")"
  convert-im6.q16 "$input" -resize '1200x1200>' "$output"
done

6. Avoid the destructive shortcut

mogrify-im6.q16 is built to modify images in place. The manpage draws the line clearly: mogrify overwrites the original, while convert writes to another output file.

Warning

Do not use mogrify on the only copy of a photograph, scan or asset. In-place resizing and format changes can be hard or impossible to undo, and a failed operation can leave you with no clean source left at all.

If you must run it on disposable copies, back up first:

cp -- ./input.jpg ./input.jpg.before-mogrify
mogrify-im6.q16 -resize '1200x1200>' ./input.jpg
identify-im6.q16 ./input.jpg

To undo that specific example, restore the backup only after checking its contents:

identify-im6.q16 ./input.jpg.before-mogrify
cp -- ./input.jpg.before-mogrify ./input.jpg

The ordinary convert examples need no elevated privileges. If a command reports permission denied, fix ownership or choose a directory you can write to; do not reach for sudo just to paper over a path mistake.

Common failure checks

  • "no decode delegate" or an unreadable file: check the path, file permissions and actual file type with file /path/to/input. A filename extension proves nothing about the contents.
  • Output is unexpectedly large: check both dimensions and bytes with identify. Resizing alone does not guarantee a small file, especially for noisy photographs.
  • Output is blank or visually wrong: stop and inspect the source and output separately. Do not overwrite the source while you are still troubleshooting.
  • Permission denied: write to a directory you own, or ask whoever administers it. Image conversion itself does not require root.
  • Command behaves differently from this guide: check convert-im6.q16 -version. ImageMagick 7 uses different command naming; this guide covers the installed ImageMagick 6 package.

Done means

  • Version and dimensions known. The installed ImageMagick version and input dimensions are confirmed.
  • Separate output path. The resized or converted file has a separate output path from the source.
  • Result verified. identify-im6.q16 confirms the output format, dimensions and size.
  • Original protected. The original remains available, or a verified backup exists before any in-place operation.