class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
more info about the class
See all posts Reply
// Set our crop dimensions. $width = 100; $height = 75; // Get dimensions of existing image $dimensions = getimagesize('path/to/image'); // Prepare canvas $canvas = imagecreatetruecolor($width,$height); $piece = imagecreatefromjpeg('path/to/image'); // Prepare image resizing and crop -- Center crop location $newwidth = $dimensions[0] / 2; $newheight = $dimensions[1] / 2; $cropLeft = ($newwidth/2) - ($width/2); $cropHeight = ($newheight/2) - ($height/2); // Generate the cropped image imagecopyresized($canvas, $piece, 0,0, $cropLeft, $cropHeight, $width, $height, $newwidth, $newheight); // Write image or fail if (imagejpeg($canvas,'path/to/save/file',90)) { echo 'Image crop successful'; } else { echo 'Image crop failed'; } // Clean-up imagedestroy($canvas); imagedestroy($piece);
What is your code, can you paste it here?