我的程序有时可以成功裁剪图像,但有时则不能。
有三种可能的结果(即使使用相同的图像)
这是编程问题还是服务器设置问题?
//$_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);
}