Skip to content

Archive

ImageMagick

1 articles
Linux 26 Sep 2026 4 min read

Batch Resize Images with Bash and ImageMagick Without Overwriting Originals

A resize command is straightforward. Keeping a batch recoverable takes more care. Writing results over the source images can leave a collection only partly processed if a conversion fails. Flattening every result into one folder also creates collisions: events/photo.jpg and products/photo.jpg would have the same destination name. A separate output tree avoids both problems. The script below accepts a source directory, a destination directory, and a maximum edge length. It processes JPEG, PNG, and WebP files recursively, retains their relative paths and formats, and leaves the originals alone.