Best way to set image quality / compression with 5.7 image helper?

Permalink
Hello,

I'm currently using the image helper in 5.7 to generate a thumbnail like so:

$ih->getThumbnail($productImage, 444, 444, true);


Does anyone know the best way to set the quality in 5.7? Is there a global setting or one you can use with getThumbnail() ?

Thanks

andrewhawkes
 
mhawke replied on at Permalink Reply
mhawke
It's hard-coded at 80 in concrete/src/Legacy/ImageHelper.php
pedroserapio replied on at Permalink Reply
pedroserapio
I was trying the same, but looks like we need change the core files, what I can not understand is why 80 produces so bad quality image compared with 60 in Photoshop.

Well, after changing the two line that define the level of compression from 80 to 95..100 I don't see any change. After upload new files, no change.

Any one tried find a replacement in PHP for this module? That produce better results?
mnakalay replied on at Permalink Reply 1 Attachment
mnakalay
Actually the lines are there but they are not taken into account because the saving function does not use it.

I had to modify the helper to be able to do what you want. The function create() was modified. I also submitted the modification to the core team that might add it to the core.

Meanwhile, here it is if you want it.

A few things to keep in mind:
1- do not change the quality value in the helper, that's a default value. Instead use the function setJpegCompression($level)
2- to go back to the default value use the function reset()
3- The helper changed between version of C5 5.7. This one works from 5.7.3 and above. Below that I don't know.