Back to the snippets index

New image size in variable ( Anthony 27/6/2008 )

This will resize an image and put the new image details into a vairable. You can either use the variable elsewhere in your code or display it. In this case it is reading the width and height; you should be able to use any of the information for -format.

IM code:

<?php
// Setup the vaiables
$sourceFile "input.jpg";
$width "100";
$height "100";
$destinationFile "output.png";
// Displays the output size of the new image
$command="convert $sourceFile -resize {$width}x{$height} \( +write $destinationFile \) -format \"%wx%h\" info: ";
$output exec("$command"); 
print(
"<b>New image size:</b>".$output."<br>");
?>

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