Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to output to another filename #14

Closed
talha-asad opened this issue May 20, 2014 · 3 comments
Closed

Option to output to another filename #14

talha-asad opened this issue May 20, 2014 · 3 comments

Comments

@talha-asad
Copy link

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
Copy link
Owner

tjko commented May 21, 2014

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

@tjko tjko closed this as completed May 22, 2014
@vortex852456
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants