Skip to content. | Skip to navigation

Personal tools
Log in
Sections
You are here: Home Knowledge How-to convert multiple image files in Linux

How-to convert multiple image files in Linux

by Akaname last modified May 29, 2011 11:42 PM

You have a folder with hundreds or thousands of image files that you wish to convert into another image file format? And you don't want to open them one by one, click on "save as", choose the new file format and confirm everything with "save" and "close"?

Fortunately, the Linux terminal has everything for batch converting, resizing and editing your image files!

Convert and resize all *.jpg images to *.png thumbnails

by Akaname last modified Jul 04, 2011 04:15 PM

This will convert and resize all *.jpg images in the current directory to *.png images. Perfect for creating smaller thumbnails in large image directories. See the Linux manual pages "man bash", "man find", "man read", "man convert" and "man sed".

All filename results from find are piped line by line to read and then processed by convert, editing the new filename with sed. This ensures that all paths with whitespace characters are processed correctly.

find . -type f -name '*.jpg' | while read filename; do echo "converting ${filename}"; convert -size 128x128 -resize 128x128 +profile '*' "${filename}" "`echo "${filename}" | sed -e 's/\.jpg$/\.png/'`"; done
Filed under: , , ,
Akaname (垢嘗) licks it...

Sekien Akaname

Akaname is a long tongued japanese demon

Usually, it comes in the night to lick the mud out of the bathtub. Take care and don't forget to clean your bathtub properly!