예제 #1
0
 /**
  * Crop avatar image by request data.
  *
  * @param User $user
  */
 protected function _cropAvatar(User $user)
 {
     if ($imageName = $user->get('image')) {
         $folderPath = $this->_path->entityFolderPath($user->get('id'), DS);
         $imagePath = $folderPath . $imageName;
         //  Resize and crop thumb.
         $Thumbnail = new ImageThumbnail($imagePath);
         $Thumbnail->setResize(false);
         $Thumbnail->setX($this->_data['x1']);
         $Thumbnail->setY($this->_data['y1']);
         $Thumbnail->setSize($this->_data['w'], $this->_data['h']);
         $Thumbnail->save($folderPath . $user->getThumbName());
     }
 }