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.
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-*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 -6Batch 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"
doneRun 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.pngAppending 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.pngResizing 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.jpgSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
