【发布时间】:2012-04-16 20:37:40
【问题描述】:
我有一个将我的图片保存到磁盘的功能:
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 返回真或假。
有什么想法吗?
谢谢
【问题讨论】:
标签: php zend-framework image-processing crop