i am trying to upload image in yii and then crop the uploaded image and then save it. what i have achieved till now is i can upload in on form submit but i dont understand to crop it or use jcrop
for that can anyone send some usefull tutorials for that
what i am doing in my controller is
public function actionCreate()
{
$model=new Userprofile;
if(isset($_POST['Userprofile']))
{
$model->attributes=$_POST['Userprofile'];
$model->profilePic=CUploadedFile::getInstance($model,'profilePic');
$ext = $model->profilePic->getExtensionName();
$imagename=date('dmy').time().rand();
$pp=$model->profilePic;
$model->profilePic=$imagename.'.'.$ext;
if($model->save())
mkdir('profilepics/'.$model->id,0777);
$pp->saveAs('profilepics/'.$model->id.'/'.$imagename.'.'.$ext);
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array('model'=>$model,));
}
You can use jquery plugin imageAreaSelect to get coordinates for cropping at client-side. Here is live example http://odyniec.net/projects/imgareaselect/.
Then pass coordinates to model`s beforeSave and crop it using Imagick::cropImage() (instead of Imagick you can use GD or any other library you want)