Attached below is the script I'm trying to use to allow the uploading and resizing of an image... The script that is currently being used for the same purpose uses GD but my host only has v1.6 installed and as such there is no "createresambpled" function available. That being said, I am redoing the script to make use of ImageMagice which is installed and on the latest version. The image is being uploaded properly and ends up in the right folder, I just cant seem to get the convert function to work. I've checked that paths are correct (fileexists) and the path to imagemagick is correct - but to no avail... am I missing something - I'm stumped...
I've also tried relative paths for the images upload and that didn't work either.
Thanks in advance for any light that can be shed on this.
Code below
<?
require("../pagebuilder.php");
Root();
//delete below when done testing
////////////////////////////////
$CrewID = "99";
////////////////////////////////
// Define the $base_dir & imagemagick path
$impath = "/usr/X11R6/bin/";
$temp_dir = "/var/www/html/images/crew/";
//move from temp to folder
$userfile = $_FILES['image']['tmp_name'];
$upfile = "../../images/crew/".$CrewID.".jpg";
move_uploaded_file($userfile, $upfile);
chmod($upfile, 0777);
//get maximum image size from pagebuilder.php
$MIS = $MaxImageSize;
if ($MIS == "") { $MIS = 240; };
// Set the temp filename
$temp_file = $CrewID."_sm.jpg";
//get image attributes
$image_attr = getimagesize($upfile);
// Get the percentage required to resize the image
if ($image_attr[0] > $image_attr[1]) {
$percentage = ($MIS / $image_attr[0]);
} else {
$percentage = ($MIS / $image_attr[1]);
}
$new_w = $image_attr[0] * $percentage;
$new_h = $image_attr[1] * $percentage;
$new_w = (int) $new_w;
$new_h = (int) $new_h;
// Create the output file
exec($impath."convert -resize ".$new_w."x".$new_h." ".$upfile." ".$temp_dir.$temp_file);
echo "<DIV align=\"center\"><B>Item updated. Image(s), if any, were resized. Click <a href=\"./index.php\">[HERE][/url] to return to the menu.</div>"
?>