Search code examples
linuximageimage-processingimage-manipulationjpegtran

jpegtran optimize without changing filename


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.


Solution

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