Skip to content. | Skip to navigation

Personal tools
Log in
Sections
You are here: Home Knowledge Convert and resize all *.jpg images to *.png thumbnails

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
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!