Snippets
Check size before resizing ( Anthony 25/6/2008 )
This will check the image size before running the resize command.
Imagemagick can be set to resize depending on the original image size BUT it needs to read the image in first and decide what to do; the image is then resaved introducing jpg compression.
You could also check the image size using the ping function but the getimagesize() is just as easy.
IM code:
<?php // original image $input = "input.jpg"; // Get the size of the image $size = getimagesize( $input ); // If the width or height is larger than 200 carry on with the resizing if ( ( $size[0] > '200' ) or ( $size[1] > '200' ) { exec("convert $input -resize 200x200 output.jpg"); } ?>