Batch downsize images - best parameters and a script

500K is sufficient for most images. This DOS batch script can handle many directories using Imagemagick.

Storage has become cheap. However, with the years, photo directories can get bloated. How much data is redundant? I have played around with the free command line tool Imagemagick and checked the details. The result: Most photos do not require more than 500 KB

This applies to 99% of all photos in standard consumer situations, taken with a cell phone. Many are even well with 300 KB. Most messengers compress them to this size for transmission. This saves mobile bandwidth. But archives still grow. So why not batch resize all directories?

Before starting such a major operation I wanted find out the best parameters. It turned out that resizing file size works best when width and height are not modified. A modest sharpening improves the overall impression though zooming suffers a bit from it. The original looks like this (right-click to see full image):

The Danish town of Kolding (original 1.5 MB)

from original
500K zoomed in, no sharpening
The Danish town of Kolding (500K sharpened)

This DOS-script can be saved as a .bat-file. Adjust it to your needs. Right now it would only convert files larger than 800K and put them in then "down" subdirectory of each year. Originals are stored in directories like "D:\photos\2014", "D:\photos\2015" and so on. Originals will not be modified. The script also keeps the original modification date in the filesystem and all EXIF Info (meta data) of each photo. @echo off set "xpath=d:\photos" for /L %%j in (2014,1,2023) do ( :: md "%xpath%\%%j\down" for %%i in ("%xpath%\%%j\*.jpg") do ( if %%~zi gtr 800000 ( echo "%%~fi %xpath%\%%j\down\%%~nxi" magick "%%~fi" -define jpeg:extent=600KB -sharpen 0x1 "%xpath%\%%j\down\%%~nxi"))) pause

WARNING: Some have a general issue with Imagemagick: It seems like they lose all detail like a blown-up thumbnail regardless of the specific operation. This applies for all photos of out Moto G4 with extreme effects. File size was around 1M in these cases. With other devices, 10% of all pictures have a minimized colour depth after resizing, especially with shades of bright sky colours. I cannot find any systematic in this. So check the results before overwriting your originals in the next step.