0

我有一个功能可以将我的图片保存到磁盘:

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返回真或假。

有任何想法吗?

谢谢

4

1 回答 1

0

您可以使用imagejpeg(), 或您需要的等效类型输出它。

imagejpeg($dst_r, 'somepath/someimg.jpg');
于 2012-04-16T20:39:31.770 回答