jpegtran optimize without changing filename

David picture David · Apr 7, 2011 · Viewed 23.1k times · Source

I need to optimize some images, but not change their name.

jpegtran -copy none -optimize image.jpg > image.jpg 

However, this seems to create an filesize of 0. When i do it to a different filename, the size is still exactly the same.

Answer

so12311 picture so12311 · Apr 7, 2011

how about:

jpegtran -copy none -optimize -outfile image.jpg image.jpg

I'm not a shell expert by any means, but I think that with your original command, as soon as it is executed, the redirect is set up which overwrites your image.jpg. Then when jpegtran tries to read it in it finds an empty file.