ImageWorkshop icon indicating copy to clipboard operation
ImageWorkshop copied to clipboard

resizeToCover, like in css?

Open marcusdiy opened this issue 4 years ago • 0 comments

Q A
Bug report? no
Feature request? no
Usage question? yes
PHP version used 7.4

Hi, i was looking for a way to resize an image, without squashing it or blackbars, and to make sure that all the area should be cover. I found that there is a similar method called resizeToFit ...so maybe you could add another method in the same class. It would be resizeToCover, it should work just like the CSS cover attribute. What do you think?

    /**
     * Resize the layer to cover a bounding box by specifying pixel
     *
     * @param integer $width
     * @param integer $height
     * @param integer $positionX
     * @param integer $positionY
     * @param string $position
     */
    public function resizeToCover($width, $height, $px = 0, $py = 0, $position = 'MM')
    {
        $this->cropToAspectRatioInPixel($width, $height, $px, $py, $position);
        $this->resizeInPixel($width, $height);
        return $this;
    }

marcusdiy avatar Oct 22 '20 21:10 marcusdiy