用PHP复制图像后保存图像';的GD库


Save image after copying it with PHP's GD Library

我正在裁剪一个通过带有jQuery裁剪插件的表单提交的图像。我有以下内容。但是,我怎样才能找到到达目的地图像的路径?

$pic = $this->input->post('pic');
//Get the coordinates from the image crop
$x = $this->input->post('x');
$y = $this->input->post('y');
$w = $this->input->post('w');
$h = $this->input->post('h');
$src = imagecreatefromjpeg($pic);
$dest = ImageCreateTrueColor($w, $h);
imagecopy($dest, $src, $x, $y, $x, $y, $w, $h);

您只需要声明路径。

imagejpeg($dest, '/path/to/save.jpg', 90);

或者对于较小的图像

imagepng($dest, '/path/to/save.jpg', 9);