Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
<?
if ( $Submit ) {
// Display what is being posted
echo "<br> filename = ".$filename;
echo "<br> HTTP_POST_VARS filename = ".$HTTP_POST_VARS["filename"];
echo "<br> _POST filename = ".$_POST["filename"];
// Temporary upload image name
$original_image = $_FILES['filename']['tmp_name'];
// Display what original_image contains
echo "<br> original_image = ".$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'];
echo "<br> new_image = ".$new_image;
exec("/usr/local/bin/convert $original_image -resize 794x564> -segment 1x1 +dither -colors 2 -edge 1 -normalize -negate $new_image");
echo "File uploaded";
echo "<img src=\"".$new_image."\">";
}
?>
Thats strange; according to the Imagemagick instructions if you use 794x564> it should only resize the image if it is larger than 794x564. I have just tried it and created an image of 0kb !
I would say use my first example where it checks the size with getimagesize and the uses the if else function.
Note: I think I may have found the problem, try changing this line :
exec("/usr/local/bin/convert $original_image -resize '794x564>' -segment 1x1 +dither -colors 2 -edge 1 -normalize -negate $new_image");
Not unless you add a '!' to the resize the images aspect ration is preserved, just as you want. That is the final image will fit into the requested box, NOT fill the requested box.