Back to the snippets index

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:

// 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");

Batch file - windows server
Check size before resizing
Dividing an image
Fonts Installed view
Get image data into a variable 1
Get image data into a variable 2
Gravity option
New image size in variable
Row of images
Setup Information
Use an array
Warhol effect