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:
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.
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: 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.