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.
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
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.
If anyone is stuck with this, you can get a little creative by doing this.
Here is a small bash script:
img='test.jpg'
cp $img ${img%.*}-optimized.jpg
jpegoptim ${img%.*}-optimized.jpg
Most helpful comment
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