tjko / jpegoptim

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

Option to output to another filename #14

Closed talha-asad closed 10 years ago

talha-asad commented 10 years ago

Currently you support batch image processing nicely by offering destination directory option, however if a user wants to optimize just a single image with a different file name, he can't. I think having 2 parameters one for input and one for output can help in this case and it seems reasonable to have this support in this awesome optimizer.

tjko commented 10 years ago

Starting from v1.4.0, jpegoptim supports stdin/stdout. So, now there is couple ways to do what you want:

jpegoptim --stdout a.jpg > b.jpg

or

cat a.jpg | jpegoptim --stdin > b.jpg

vortex852456 commented 4 years ago

To use stdin/stdout you have to use a shell. The binary itself is not capable of outputting to another filename, which in my opinion is a weakness/missing feature.

ravgeetdhillon commented 3 years ago

If anyone is stuck with this, you can get a little creative by doing this.

  1. Create a copy of your original image and rename it to your intended output file name.
  2. Optimize the copied version of your original image.

Here is a small bash script:

img='test.jpg'
cp $img ${img%.*}-optimized.jpg
jpegoptim ${img%.*}-optimized.jpg