tjko / jpegoptim

jpegoptim - utility to optimize/compress JPEG files
http://www.iki.fi/tjko/projects.html
GNU General Public License v3.0
1.56k stars 116 forks source link

Option for JPEGOptim to output the original file if it can't optimize it #80

Closed jackyhallyday closed 2 years ago

jackyhallyday commented 3 years ago

Hello,

Would it be possible to force JPEGOptim to output the original file if it hasn't been able to reduce its size?

The problem I've got is when I insert JPEGOptim in my workflow : I'm using JPEGTran, then JPEGOptim using --stdin, then output the result to a file using --stdout and a >.

When a file has not been optimized, JPEGOptim outputs a message saying that the file has been skipped. It's possible to force the output, but in that case, the output is the biggest file.

So it seems that the current options we have if JPEGOptim fails to optimize the files are: original_file.jpg > JPEGOptim > "skip message" original_file.jpg > JPEGOptim > bigger_file.jpg

It would be nice to have an option like --force-smallest or something: original_file.jpg > JPEGOptim > copy_of_original_file.jpg

That way, JPEGOptim could be chained to other commands and always output the smallest file it can.

tjko commented 2 years ago

This has now been implemented with commit (05c3f85aa1330f88f20b86c9d535a72735ed33a1). Can you test if behavior is now as expected?

This should also fix --size option that was not working when input was read from stdin....

jackyhallyday commented 1 year ago

I'm super late but yes, it works! 👍 Thank you