From 6eb4648f494cc6ad97aa611d1fc3edec238dd6c0 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sat, 7 Dec 2013 15:29:21 +0100 Subject: [PATCH] Added missing resize implementation --- .../files/lib/system/image/adapter/GDImageAdapter.class.php | 4 ++-- .../files/lib/system/image/adapter/IImageAdapter.class.php | 4 +--- .../files/lib/system/image/adapter/ImageAdapter.class.php | 4 ++-- .../lib/system/image/adapter/ImagickImageAdapter.class.php | 6 ++++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php index 177ab87398..db1da9c5be 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/GDImageAdapter.class.php @@ -158,11 +158,11 @@ class GDImageAdapter implements IImageAdapter { /** * @see \wcf\system\image\adapter\IImageAdapter::resize() */ - public function resize($originX, $originY, $originWidth, $originHeight, $targetX = 0, $targetY = 0, $targetWidth = 0, $targetHeight = 0) { + public function resize($originX, $originY, $originWidth, $originHeight, $targetWidth = 0, $targetHeight = 0) { $image = imageCreateTrueColor($targetWidth, $targetHeight); imageAlphaBlending($image, false); - imageCopyResampled($image, $this->image, $targetX, $targetY, $originX, $originY, $targetWidth, $targetHeight, $originWidth, $originHeight); + imageCopyResampled($image, $this->image, 0, 0, $originX, $originY, $targetWidth, $targetHeight, $originWidth, $originHeight); imageSaveAlpha($image, true); // reload image to update image resource, width and height diff --git a/wcfsetup/install/files/lib/system/image/adapter/IImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/IImageAdapter.class.php index 1f1fef3016..fb8baacd5b 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/IImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/IImageAdapter.class.php @@ -63,13 +63,11 @@ interface IImageAdapter { * @param integer $originY * @param integer $originWidth * @param integer $originHeight - * @param integer $targetX - * @param integer $targetY * @param integer $targetWidth * @param integer $targetHeight * @see \wcf\system\image\adapter\IImageAdapter::getImage() */ - public function resize($originX, $originY, $originWidth, $originHeight, $targetX, $targetY, $targetWidth, $targetHeight); + public function resize($originX, $originY, $originWidth, $originHeight, $targetWidth, $targetHeight); /** * Draws a rectangle, overwrites image resource within instance. diff --git a/wcfsetup/install/files/lib/system/image/adapter/ImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/ImageAdapter.class.php index 86bc95cf60..76e7a820d7 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/ImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/ImageAdapter.class.php @@ -88,14 +88,14 @@ class ImageAdapter implements IImageAdapter { /** * @see \wcf\system\image\adapter\IImageAdapter::resize() */ - public function resize($originX, $originY, $originWidth, $originHeight, $targetX, $targetY, $targetWidth, $targetHeight) { + public function resize($originX, $originY, $originWidth, $originHeight, $targetWidth, $targetHeight) { // use origin dimensions if target dimensions are both zero if ($targetWidth == 0 && $targetHeight == 0) { $targetWidth = $originWidth; $targetHeight = $originHeight; } - $this->adapter->resize($originX, $originY, $originWidth, $originHeight, $targetX, $targetY, $targetWidth, $targetHeight); + $this->adapter->resize($originX, $originY, $originWidth, $originHeight, $targetWidth, $targetHeight); } /** diff --git a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php index 906cc73c19..1b9047ce45 100644 --- a/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php +++ b/wcfsetup/install/files/lib/system/image/adapter/ImagickImageAdapter.class.php @@ -104,8 +104,10 @@ class ImagickImageAdapter implements IImageAdapter { /** * @see \wcf\system\image\adapter\IImageAdapter::resize() */ - public function resize($originX, $originY, $originWidth, $originHeight, $targetX, $targetY, $targetWidth, $targetHeight) { - throw new \Exception("resize() method not implemented yet."); // TODO: Implement resize() method. + public function resize($originX, $originY, $originWidth, $originHeight, $targetWidth, $targetHeight) { + $this->clip($originX, $originY, $originWidth, $originHeight); + + $this->imagick->resizeImage($targetWidth, $targetHeight, \Imagick::FILTER_POINT, 0); } /** -- 2.20.1