我是第一次使用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);
}
}