Operations 6 min read

ImageMagick on CentOS 8: Install, Convert, Batch, Rotate & Resize via CLI

This guide shows how to install ImageMagick on CentOS 8, use the convert command to change image formats, batch‑process files with a Bash script, rotate or flip images, append pictures, and resize them, providing practical command‑line examples and tips.

Liangxu Linux
Liangxu Linux
Liangxu Linux
ImageMagick on CentOS 8: Install, Convert, Batch, Rotate & Resize via CLI

Installing ImageMagick on CentOS 8

Download the RPM packages and install them with yum:

wget https://download.imagemagick.org/ImageMagick/download/linux/CentOS/x86_64/ImageMagick-7.1.0-17.x86_64.rpm
wget https://download.imagemagick.org/ImageMagick/download/linux/CentOS/x86_64/ImageMagick-libs-7.1.0-17.x86_64.rpm
yum localinstall ImageMagick-*
ImageMagick installation result
ImageMagick installation result

Converting image formats

Use convert to change a file from JPG to PNG: convert penguins.jpg penguins.png The resulting PNG looks identical to the original JPG but has a different file size and extension. Verify the file header with od if needed:

od -bc penguins.jpg | head -6
od -bc penguins.png | head -6

Batch conversion script

A Bash loop can convert many files automatically:

#!/bin/bash
for file in *.jpg; do
    newfile=$(echo $file | sed 's/jpg/png/')
    convert "$file" "$newfile"
done

Run the script with ./batch_convert.sh to process all JPG files in the directory.

Rotate and flip images

Rotate an image 45° clockwise or flip it vertically:

convert penguins.jpg -rotate 45 penguins_45.png
convert penguins.jpg -flip penguins_flip.png
Rotated and flipped images
Rotated and flipped images

Appending images

Combine two images vertically with -append or horizontally with +append:

convert penguins.jpg penguins_flip.png -append append_vertical.png
convert penguins.jpg penguins_flip.png +append append_horizontal.png
Appended images
Appended images

Resizing images

Adjust image dimensions using -resize. The examples shrink the image to 65 % of its original size or enlarge it to 150 %:

convert penguins.jpg -resize 65% pen_65.jpg
convert penguins.jpg -resize 150% pen_150.jpg
Resized images
Resized images
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Image ProcessingLinuxcommand-lineBashImageMagickCentOS
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.