X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Fsrc%2FPlugin%2FImageToolkit%2FOperation%2Fgd%2FScaleAndCrop.php;h=ad53ec3fa156ce3944cd0032c886f706e8a4ad11;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=510020f8d8c85b4edc70dd1f25e68ee3bcddaea7;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php b/web/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php index 510020f8d..ad53ec3fa 100644 --- a/web/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php +++ b/web/core/modules/system/src/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php @@ -20,6 +20,16 @@ class ScaleAndCrop extends GDImageToolkitOperationBase { */ protected function arguments() { return [ + 'x' => [ + 'description' => 'The horizontal offset for the start of the crop, in pixels', + 'required' => FALSE, + 'default' => NULL, + ], + 'y' => [ + 'description' => 'The vertical offset for the start the crop, in pixels', + 'required' => FALSE, + 'default' => NULL, + ], 'width' => [ 'description' => 'The target width, in pixels', ], @@ -38,8 +48,12 @@ class ScaleAndCrop extends GDImageToolkitOperationBase { $scaleFactor = max($arguments['width'] / $actualWidth, $arguments['height'] / $actualHeight); - $arguments['x'] = (int) round(($actualWidth * $scaleFactor - $arguments['width']) / 2); - $arguments['y'] = (int) round(($actualHeight * $scaleFactor - $arguments['height']) / 2); + $arguments['x'] = isset($arguments['x']) ? + (int) round($arguments['x']) : + (int) round(($actualWidth * $scaleFactor - $arguments['width']) / 2); + $arguments['y'] = isset($arguments['y']) ? + (int) round($arguments['y']) : + (int) round(($actualHeight * $scaleFactor - $arguments['height']) / 2); $arguments['resize'] = [ 'width' => (int) round($actualWidth * $scaleFactor), 'height' => (int) round($actualHeight * $scaleFactor),