我正在尝试使用给定的X、Y、宽度和高度坐标来裁剪原始图像。但是它无法正确地裁剪图像。
这是我的代码:
header('Content-type: image/jpeg');
$source_x = $_POST['x'];
$source_y = $_POST['y'];
$width = $_POST['w'];
$height = $_POST['h'];
$dest = imagecreatetruecolor($width, $height);
$src = imagecreatefromjpeg('path of the orignal Image');
imagecopy($dest, $src, 30, 30, $source_x, $source_y, $width, $height);
$cropped_image = "Path where to store the cropped image";
imagejpeg($dest, $cropped_image, 100);
使用以上代码,我能够裁剪图像,但它没有在给定坐标处裁剪。任何帮助都将是有用的。