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 » 2012-03-21T10:53:24-07:00

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: 10690
Joined: 2003-05-31T11:32:55-07:00

Re: Using -define jpeg:size= with PHP

Post by magick » 2012-03-21T11:26:23-07:00

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 » 2012-03-21T11:54:46-07:00

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

Post Reply