Using -define jpeg:size= with PHP

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
Falesh
Posts: 5
Joined: 2012-03-21T08:12:37-07:00
Authentication code: 8675308

Using -define jpeg:size= with PHP

Post 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');
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Using -define jpeg:size= with PHP

Post 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');
Falesh
Posts: 5
Joined: 2012-03-21T08:12:37-07:00
Authentication code: 8675308

Re: Using -define jpeg:size= with PHP

Post by Falesh »

That made it more then twice as fast. Cheers! :D
Post Reply