jcrop和ImageCopy在yii框架上将裁剪图像重新采样为全黑

jcrop和ImageCopy在yii框架上将裁剪图像重新采样为全黑,yii,jcrop,Yii,Jcrop,我第一次使用jcrop。试图通过jcrop教程,我得到了一个黑色裁剪的图像。这是deepliquid的演示脚本,带有适当的yii更改。这是我的裁剪动作,裁剪并显示图像 public function actionCrop() { $image_record = Images::model()->findByPk(Yii::app()->request->getParam('image')); $imageUrl = '/images/up

我第一次使用jcrop。试图通过jcrop教程,我得到了一个黑色裁剪的图像。这是deepliquid的演示脚本,带有适当的yii更改。这是我的裁剪动作,裁剪并显示图像

public function actionCrop()
    {
        $image_record = Images::model()->findByPk(Yii::app()->request->getParam('image'));
        $imageUrl = '/images/uploads/'.$image_record->id.'/'.$image_record->image;

        $model = new Crop;

        if(isset($_POST['Crop']))
        {
            $model->attributes=$_POST['Crop'];
            if($model->validate())
            {
                // form inputs are valid, do something here

                $targ_w = $targ_h = 500;
                $jpeg_quality = 90;

                $src = $this->createAbsoluteUrl($imageUrl);
                $img_r = imagecreatefromjpeg($src);
                $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );

                imagecopyresampled($dst_r,$img_r,0,0,$model->x1,$model->y1,
                    $targ_w,$targ_h,$model->w,$model->h);

                header('Content-type: image/jpeg');
                imagejpeg($dst_r, null, $jpeg_quality);


            }
        }