I used javascript to crop an image,
[url]http://miamiproviders.com/providers/test_feature.php?id=1
Select an image, submit the form and thats the cool cropping thing.
The next step is to save the new cropped image (as feature.jpg) into the folder ($dirname points to it) This is what I have soo far,
[code=php]
$dirname = “images/”.$_GET[‘id’].”/”;
$max_width = “500”; // Max width allowed for the large image
$thumb_width = “100”; // Width of thumbnail image
$thumb_height = “100”; // Height of thumbnail image
//Image Locations
$large_image_location = “{$dirname}temp.jpg”;
$thumb_image_location = “{dirfname}feature.jpg”;
function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){
$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
$source=imagecreatefromjpeg($image);
imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height);
imagejpeg($newImage,$image,90);
}
function getHeight($image) {
$size = getimagesize($image);
$height = $size[1];
return $height;
}
function getWidth($image) {
$size = getimagesize($image);
$width = $size[0];
return $width;
}
if (isset($_POST[“upload_thumbnail”])) {
echo “<pre>”;print_r($_POST);echo “</pre>”;
//Get the new coordinates to crop the image.
$x1 = $_POST[“x1”];
$y1 = $_POST[“y1”];
$x2 = $_POST[“x2”];
$y2 = $_POST[“y2”];
$w = $_POST[“w”];
$h = $_POST[“h”];
//Scale the image to the thumb_width set above
$scale = $thumb_width/$w;
$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale);
echo $cropped;
// Save the image as a jpg
imagejpeg( $cropped, $dirname.”feature.jpg” );
// Clear the memory of the tempory image
imagedestroy( $cropped );
}
I am stumped as I thought if I echo $cropped I would get the path to the cropped image, but it shows nothing…
What am I missing?
Thanks.