Image resize after upload quastion

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Image resize after upload quastion

Post by Bonzo »

You would be better off posting this in the "User" section as you are not Using MagickWand.

This is a simple upload example you can use as a referance:

Code: Select all

<?php
// If the form has been submitted do this
if ( $Submit ) {  

// Temporary upload image name
$original_image = $_FILES['filename']['tmp_name'];

// 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'];

// Maximum image width
$max_width = "200";

// Maximum image height
$max_height = "90";

// Resize the image and save
exec("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 } ?> 
With your code

Code: Select all

// Try changing this bit
             copy($_FILES['images']['tmp_name'][$key], $add);
             chmod("$add",0777);
             exec("convert logo: -resize 25% ".$add."");
// To this
             $input = $_FILES['images']['tmp_name'][$key];
             chmod("$add",0777);
             exec("convert $input -resize 25% $add");

Logo: is a default ImageMagick image not your image; I would echo out $input and $add to check they contain what you expect.

To add some errror reporting try this:

Code: Select all

$array=array();
echo "<pre>";
             $input = $_FILES['images']['tmp_name'][$key];
             chmod("$add",0777);
             exec("convert $input -resize 25% $add 2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
You can find some more php information on my site.
Post Reply