Implements \Drupal\system\Plugin\ImageToolkitInterface::crop().
Overrides ImageToolkitInterface::crop
public function crop($image, $x, $y, $width, $height) {
$res = $this
->createTmp($image, $width, $height);
if (!imagecopyresampled($res, $image->resource, 0, 0, $x, $y, $width, $height, $width, $height)) {
return FALSE;
}
// Destroy the original image and return the modified image.
imagedestroy($image->resource);
$image->resource = $res;
$image->info['width'] = $width;
$image->info['height'] = $height;
return TRUE;
}