Creating a thumbnail

<?php
exec
("/usr/local/bin/convert -size 733x567 earth.jpg -thumbnail 250x90 thumbnail/new.jpg");
?>

A thumbnail image created using ImageMagick

You may need to use this instead depending on the ImageMagick version

<?php
exec
"/usr/bin/convert -size 733 earth.jpg -geometry 90 thumbnail/new1.jpg" );
?>

A thumbnail image created using ImageMagick

Crop part of an image

<?php
exec
("/usr/local/bin/convert earth.jpg -crop 400x300+100+100 +repage thumbnail/cropped.jpg")
?>

A cropped image created using ImageMagick

Upload and resize an image

A piece of code to allow you to upload and resize an image. You can either just put the image into the form and have the other settings built into the code as this example or pass things like the finished size or location in the form as well.

You should do some validation to check the file type, file size etc.

<?php
// If the form has been submitted do this
if ( $Submit ) {  
// Temporary upload image name
$original_image $_FILES['filename']['tmp_name'];
// Strip any malicious code from the user input
$original_image strip_tags$original_image );
// Get the image dimensions
$size=GetImageSize$original_image );
// Name to save the image as - in this case the same as the original
$new_image $_FILES['filename']['name'];
// Strip any malicious code from the user input
$new_image strip_tags$new_image );
// Maximum image width
$max_width "200";
// Maximum image height
$max_height "90";
// Resize the image and save
exec("/usr/local/bin/convert -size {$size[0]}x{$size[1]} $original_image -thumbnail $max_widthx$max_height $new_image");
echo 
"File uploaded<br>";
echo 
"<img src=\"".$new_image."\">";
}
else { 
?>
<p>File to upload:</p>
<form method="post" action="<?php echo $PHP_SELF?>" enctype="multipart/form-data"> 
<input type="file" name="filename"  />
<input type="Submit" name="Submit" value="Submit" />
</form>
<?php ?>