My program is able to crop images successfully sometimes, but other times it is not.
There are three possible outcomes (even using the same image)
- successfully crop the image (correct outcome)
- cannot crop the image, the image is unchanged (incorrect outcome)
- the image has been croped, but the image is black (incorrect outcome)
Is this a programming problem or a server setting problem?
//$_GET['x'],$_GET['y'] = crop area left top position
//$_GET['w'],$_GET['h'] = crop area width and height
$filePath=getImageFilePath();
$extension=strrchr($thisEventMember->filePath,'.');
if(strtolower($extension)=='.jpg'||strtolower($extension)=='.jpeg')
{
$image=imagecreatefromjpeg($filePath);
$tempImage=imagecreatetruecolor($_GET['w'], $_GET['h']);
imagecopyresampled($tempImage,$image,0,0,$_GET['x'],$_GET['y'],$_GET['w'],$_GET['h'],$_GET['w'],$_GET['h']);
imagejpeg($tempImage,$filePath,90);
}