Decreasing thumb quality under 1

I would like to know if I can decrease the thumb quality under 1. I’m using this method to show a low-def image as lazyload.

This is the image I get with 'quality' => 0.1

For example

  • 'quality' => 0.1 is the same as 'quality' => 1
  • 'quality' => -0.1 doesn’t work

And I would to be able to set : 'quality' => -5 to decrease, even more, the quality of the image.

The SimpleImage library expects an integer between 0 and 100. Haven’t checked ImageMagic yet…


Thanks, I didn’t know SimpleImage libary, I try to implement it by adding

$image = thumb($img, array('width' => 1920, 'quality' => 100))->url(); 
$imgSimpleImage = new SimpleImage($image); 
$imgSimpleImageFile = $imgSimpleImage->pixelate('3')->toScreen();
echo $imgSimpleImageFile; 

But I get the error Object of class claviska\SimpleImage could not be converted to string.

If you know more about the SimpleImage class, do you know how to get the image url(), before or after setting the pixelate() property correclty ?

Just out of curiosity, why do you want a quality below 1?
Is it because you want a visually different type of image or because you want to reduce the weight even more?

Because if it’s the latter you could generate an image that’s smaller in size (for example a 500px wide or even a 200px wide image). This should save you a few extra bytes.

Thank you, I think I found a solution, easy as hell : decrease the width before setting the quality like

'width' => 200, 'quality' => 1

I was interested by this pixellate/trashy effect, not the weight, but you make me think I could reduce the width first…


1 Like