Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting quality with imagemagick?

I use the following code to create a thumbnail on the site:

$small_image = new Imagick($large_path."/".$pic['image']);
$small_image->thumbnailImage(100, 0);
$small_image->writeImage($small_path."/".$pic['image']);

It sets it's own quality and I tried adding

$small_image->setCompression(imagick::COMPRESSION_JPEG);
$small_image->setCompressionQuality(1);

But that didn't change a thing. I also tried

$img = new Imagick($small_path."/".$pic['image']);
$img->setCompression(Imagick::COMPRESSION_JPEG);
echo $img->setCompressionQuality(1); // should come out ugly
$img->writeImage();

But even that didn't change the size with quality 1. Any ideas what I'm doing wrong?

like image 570
Marki Avatar asked Jan 23 '23 07:01

Marki


1 Answers

I think you want:

$small_image->setImageCompression(imagick::COMPRESSION_JPEG);
$small_image->setImageCompressionQuality(1);

Note the "Image" between the "get"/"set" and "Compression".

like image 84
VTEX Avatar answered Jan 25 '23 20:01

VTEX