danielgtaylor / jpeg-archive

Utilities for archiving JPEGs for long term storage.
1.17k stars 121 forks source link

recompressing small files can result in creating larger files #100

Open pavelxkrejci opened 6 years ago

pavelxkrejci commented 6 years ago

Metadata added by jpeg-recompress can outweight the savings from recompression of small files. The logic for output size calculation and checking ignores size of all metadata and this can result in creating output files larger then original files in some cases. Example file included: m Command used: jpeg-recompress -l 10 -c -a -q high m.jpg m-out.jpg

I'm also including diff file with my fix. jpeg-recompress.c.diff.txt The fix also uses minDelta constant which is the minimum required savings in bytes for the new file to be created. I wanted to avoid useless recompressions with 1 byte improvement. This might be improved to be configurable via parameter.