Re: Image resize after upload quastion
Posted: 2009-03-17T11:04:45-07:00
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:
With your code
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:
You can find some more php information on my site.
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 } ?>
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>";