Commit af77626a authored by Mark Harding's avatar Mark Harding
Browse files

Merge branch 'fix/gif-resize' into 'master'

[Sprint/QuietQuail](fix): GIF resize and cropping.

Closes #907

See merge request !386
parents 8a5e4d6a 988e5b76
Loading
Loading
Loading
Loading
+32 −7
Original line number Original line Diff line number Diff line
@@ -127,14 +127,39 @@ class Resize


        $params = $this->getResizeParameters();
        $params = $this->getResizeParameters();


        // First crop the image
        // If is animated,
        $this->image->cropImage($params['selectionwidth'], $params['selectionheight'], $params['xoffset'],
        if ($this->image->getNumberImages() > 1) {
            $params['yoffset']);
            foreach ($this->image as $frame) {
                // Crop into square.
                $frame->cropImage(
                    $params['selectionwidth'],
                    $params['selectionheight'],
                    $params['xoffset'],
                    $params['yoffset']
                );

                // Resize canvas to new image
                $frame->setImagePage(0, 0, 0, 0);
                
                // If selected with / height differ from selection width/height, then we need to resize
                if ($params['selectionwidth'] !== $params['newwidth'] || $params['selectionheight'] !== $params['newheight']) {
                    $frame->thumbnailImage($params['newwidth'], $params['newheight']);
                }
            }
        } else {
            // Crop the image to selection dimensions
            $this->image->cropImage(
                $params['selectionwidth'],
                $params['selectionheight'],
                $params['xoffset'],
                $params['yoffset']
            );


            // If selected with / height differ from selection width/height, then we need to resize
            // If selected with / height differ from selection width/height, then we need to resize
            if ($params['selectionwidth'] !== $params['newwidth'] || $params['selectionheight'] !== $params['newheight']) {
            if ($params['selectionwidth'] !== $params['newwidth'] || $params['selectionheight'] !== $params['newheight']) {
                $this->image->thumbnailImage($params['newwidth'], $params['newheight']);
                $this->image->thumbnailImage($params['newwidth'], $params['newheight']);
            }
            }
        }


        $this->output = $this->image;
        $this->output = $this->image;