【发布时间】:2015-03-02 20:54:43
【问题描述】:
我正在尝试使用给定的 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);
使用上面的代码,我可以裁剪图像,但它不会在给定的坐标中裁剪。
任何帮助都会很有用。
【问题讨论】:
-
@Kiren Siva 我不想调整图像大小。我想裁剪图像的一部分并只保存裁剪后的图像。