Table of Contents
- Resize an Image for the Web
- Reduce Animated GIF File Size
- Combine Multiple Images into an Animated GIF
- Stack Images Vertically
- ImageMagick with a URL
- Conventions Used in This Guide
Resize an Image for the Web
magick input.png \
-resize 800x> \
-strip \
-quality 75 \
-interlace Plane \
output.jpg
-resize 800x>
Set the width to 800px and maintain aspect ratio without upscaling smaller images. Use 800x
to also upscale smaller images.
-strip
Remove EXIF, IPTC, XMP, and embedded color profiles to reduce file size.
-quality 75
Set JPEG compression to 75.
-interlace Plane
Interlace the image so that it progressively sharpens as more data arrives.
Reduce Animated GIF File Size
magick input.gif \
-fuzz 7% \
-layers optimize \
output.gif
fuzz 7%
Allow a 7% color difference when comparing pixels for optimization. This helps further reduce size by treating near-identical colors as the same.
-layers optimize
Optimize the GIF animation by reducing redundant pixels between frames, which can reduce file size.
Combine Multiple Images into an Animated GIF
magick input1.png input2.png input3.png \
-delay 100 \
-loop 5 \
-dispose previous \
output.gif
-delay 100
Pause for 1 second between frames.
-loop 5
Loop the frames five times. Use -loop 0
to loop forever.
-dispose previous
Clears the previous frame before drawing the next.
Stack Images Vertically
magick input1.jpg input2.jpg input3.jpg \
-append \
result.jpg
-append
Stack images vertically. Use +append
to stack horizontally instead.
ImageMagick With a URL
magick https://example.com/input.png \
result.jpg
Requires ImageMagick compiled with HTTPS delegate support. Some ImageMagick builds disable remote reading.
Conventions Used in This Guide
- Use
input.png
andoutput.jpg
as the filenames (extensions can change as needed). - Put one switch on each line.
- Use future tense such as "optimize" instead of "optimizes" or "optimized".
- Use AP style heading capitalization.
- Use the newer
magick
command instead of the olderconvert
command. - Arbitrarily organize into what I think are the most likely use cases.
Get the Full Guide
Get the ImageMagick Field Guide when it ships, along with future guides and notes on building fast, privacy-first, evergreen sites. Subscribe below.