Ayesh / grunt-guetzli

Grunt plugin to compress JPG and PNG images according to Google's Guetzli algorithm.
MIT License
3 stars 1 forks source link

.png conversion -> rename file extension to .jpg #2

Open mizzos opened 7 years ago

mizzos commented 7 years ago

Great work Ayesh! It would be great if PNGs could receive a JPG file extension after conversion.

Ayesh commented 7 years ago

Thanks @mizzos . The compressed files will still be in the format. PNG files will lose their alpha channel, but they will still be PNG files, so I'm not sure it is a good thing to change the extension.

However, the output file name/path pattern is not polished, and needs some work. I think I can make the plugin support a output file name pattern (.jpg -> .g.jpg, or even .png -> .jpg) option.

mizzos commented 7 years ago

That is a bit confusing. Here is why: I compressed some PNG files and opened them with IrfanView to have a look at the results. A message appeared saying, that the image was in deed a JPG with a wrong extension. Followed be the opportunity to rename it properly.

Please note that the README of the original google/guetzli repo reads:

The binary reads a PNG or JPEG image and creates an optimized JPEG image: guetzli [--quality Q] [--verbose] original.png output.jpg guetzli [--quality Q] [--verbose] original.jpg output.jpg

and further:

Please note that JPEG images do not support alpha channel (transparency). If the input is a PNG with an alpha channel, it will be overlaid on black background before encoding.

mizzos commented 7 years ago

Hey @Ayesh, any update on this topic?

Ayesh commented 7 years ago

Right sorry I will work on this. Ideally I think an additional option (say force_jpg) will work better to prevent backwards compatibility issues.