GoogleChromeLabs / squoosh

Make images smaller using best-in-class codecs, right in the browser.
https://squoosh.app
Apache License 2.0
21.72k stars 1.53k forks source link

Prevent renaming JPEG files to JPG #1248

Open thechiefalone opened 2 years ago

thechiefalone commented 2 years ago

I am trying to bulk convert my images but I realized that CLI converts the JPEG extensions to JPG. Is there any parameter that I can prevent conversion?

I used below command.

squoosh-cli --mozjpeg \
'{
   "quality":75,
   "baseline":false,
   "arithmetic":false,
   "progressive":true,
   "op timize_coding":true,
   "smoothing":0,
   "color_space":3,
   "quant_table":3,
   "trellis_multipass":false,
   "trel lis_opt_zero":false,
   "trellis_opt_table":false,
   "trellis_loops":1,
   "auto_subsample":true,
   "chroma_sub sample":2,
   "separate_chroma_quality":false,
   "chroma_quality":75
}' \
-d output ./*

Also I used this one to find from all subdirectories and convert them.

find . -name "*.jpeg" -exec bash -c 'file="{}"; squoosh-cli --mozjpeg auto "$file"' \;

Version:

t1gor commented 2 years ago

@thechiefalone have you been able to find the solution?

DasWordNerd commented 1 year ago

Have you tried changing the config for mozJPEG to export .jpeg as the extension instead of .jpg? I don't know if that will resolve your issue, but you can probably test it quickly.

I'd try changing this line export const extension = 'jpg'; first. If that line change doesn't produce your desired outcome, I'd change it back and then try changing this line extension: 'jpg', next. I think one of these two ought to achieve what you're looking for without much trouble.

If you figure it out and want to help the user community here, you could probably add a config variable with options for .jpg or .jpeg and then sub that variable into whichever line change works. Then you could link it up with the interface EncodeOptions for mozJPEG to make it user-selectable.