Command-line lore: Convert Images Using ImageMagick

Command-line lore: Convert Images Using ImageMagick

Another series, command-line lore. It will primarily document some quick command-line tricks.

In this particular post, we’ll discuss various quick stuff that can be done through ImageMagick. ImageMagick is used to create, edit, compose or convert digital images. It has both GUI and CLI applications.

On Debian/Ubuntu systems, just do the following to grab the package:

sudo apt install imagemagick

ImageMagick includes a number of command-line utilities, but we mainly require convert from the suite.

Note - ImageMagick is moving towards v7 which doesn’t have convert and other utilities available in v6 (legacy), so the following stuff won’t work in v7.

Table of Content

Append images together

convert image1.png image2.png -append output.png
convert image1.png image2.png +append output.png

Rotate image

convert image.png -rotate {90|180|270} output.png

Convert image to different format

convert image.jpg output.png
convert image.jpg output.pdf

Note - ImageMagick started blocking image to PDF conversion due to a security issue. You can read more and how to enable it back on Stack OverFlow.

convert image1.jpg image2.jpg output.pdf

Crop or resize image

convert image.jpg -resize 50% output.jpg
convert image.jpg -resize 32x32 output.jpg