我有一个功能可以将我的图片保存到磁盘:
public function uploadToDiskMulty($folderPath, $filename)
{
// create the transfer adapter
// note that setDestiation is deprecated, instead use the Rename filter
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->addFilter('Rename', array(
'target' => $filename,
'overwrite' => true
));
// try to receive one file
if ($adapter->receive($folderPath)) {
$message = "success";
} else {
$message = "fail";
}
return $message;
}
然后我有一个裁剪图像的功能
public function uploadCroppedImage($image, $x, $y, $w, $h)
{
$targ_w = 200;
$targ_h = 300;
$jpeg_quality = 90;
$img_r = imagecreatefromstring(file_get_contents($image));
$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
imagecopyresampled($dst_r, $img_r, 0, 0, $x, $y, $targ_w, $targ_h, $w, $h);
}
这$image = http://test.com/test_folder/example.jpg
这$folderPath = /var/www/media/test_folder/
和$filename = example.jpg
我的问题是我需要裁剪的图像路径,以便我可以通过该uploadToDiskMulty
功能运行它。
imagecopyresampled
返回真或假。
有任何想法吗?
谢谢