Page 1 of 1

Using -define jpeg:size= with PHP

Posted: 2012-03-21T10:53:24-07:00
by Falesh
I have read that when shrinking an image using -define jpeg:size= can greatly increase the speed of the operation. Is there a way to do this with the PHP module? My current code is:

Code: Select all

$image = new Imagick('origional.jpg');
$image->stripImage();
$image->setImageCompression(imagick::COMPRESSION_JPEG);

if($image->getImageHeight() <= $image->getImageWidth()) {
	$image->resizeImage(800,0, imagick::FILTER_POINT, 1);
} else {
	$image->resizeImage(0,800, imagick::FILTER_POINT, 1);
}
$image->setImageCompressionQuality(70);
$image->writeImage('large.jpg');

if($image->getImageHeight() <= $image->getImageWidth()) {
	$image->resizeImage(190,0, imagick::FILTER_POINT, 1);
} else {
	$image->resizeImage(0,190, imagick::FILTER_POINT, 1);
}
$image->setImageCompressionQuality(70);
$image->writeImage('thumb.jpg');
	
$image->destroy();
I tried changing the start to the following but it made no difference:

Code: Select all

$image = new Imagick();
$image->setSize(800, 532);
$image->readImage('origional.jpg');

Re: Using -define jpeg:size= with PHP

Posted: 2012-03-21T11:26:23-07:00
by magick
We did not test this code snippet, however, try

Code: Select all

$image = new Imagick();
$image->setOption('jpeg:size', '800x532');
$image->readImage('origional.jpg');

Re: Using -define jpeg:size= with PHP

Posted: 2012-03-21T11:54:46-07:00
by Falesh
That made it more then twice as fast. Cheers! :D