You are here

public function ImageCrop::applyCrop in Image javascript crop 7

Apply all the crop settings to the given image source.

Parameters

$image image object from image module:

File

includes/imagecrop.class.inc, line 479
Imagecrop class to handle the javascript imagecrop.

Class

ImageCrop
@file Imagecrop class to handle the javascript imagecrop.

Code

public function applyCrop(&$image) {
  if (!$this->hasSettings && $this->disableIfNoData) {
    return;
  }

  // Scale first if requested
  if ($this->scale != 'original') {
    $data = array(
      'width' => $this->scale,
      'height' => PHP_INT_MAX,
    );
    image_scale_effect($image, $data);
  }

  // Rotate if requested
  if ($this->rotation > 0) {
    $data = array(
      'degrees' => $this->rotation,
    );
    image_rotate_effect($image, $data);
  }
  $data = array(
    'anchor' => $this->xoffset . '-' . $this->yoffset,
    'width' => $this->width,
    'height' => $this->height,
  );
  image_crop_effect($image, $data);
}