cropAndResizeImage() public method

Crops the image path and then resizes, used by the JCrop tool when we upload images via the Devise Sidebar
public cropAndResizeImage ( string $imagePath, integer $width, integer $height, integer $cropWidth, integer $cropHeight, integer $cropX, integer $cropY ) : Imagick
$imagePath string
$width integer
$height integer
$cropWidth integer
$cropHeight integer
$cropX integer
$cropY integer
return Imagick
Exemplo n.º 1
0
 /**
  * Crop and save an image
  *
  * @param $input
  * @return string
  */
 public function cropAndSaveFile($input)
 {
     $imagePath = array_get($input, 'image', null);
     if (is_null($imagePath)) {
         return false;
     }
     // lots of variables to make this code easier to read
     $width = $input['cropper']['width'];
     $height = $input['cropper']['height'];
     $cropWidth = $input['cropper']['w'];
     $cropHeight = $input['cropper']['h'];
     $cropX = $input['cropper']['x'];
     $cropY = $input['cropper']['y'];
     // find the paths
     $croppedName = $this->getNewCroppedName($imagePath, $width, $height);
     $localPath = isset($input['category']) ? $this->CategoryPaths->fromDot($input['category']) : '';
     $serverPath = $this->CategoryPaths->serverPath($localPath);
     $imagePath = $serverPath . $input['image'];
     // resize and crop image and save it to media directory
     $image = $this->Images->cropAndResizeImage($imagePath, $width, $height, $cropWidth, $cropHeight, $cropX, $cropY);
     $this->Images->saveImage($image, $serverPath . $croppedName);
     return $croppedName;
 }