Skip to content

resizeToCover, like in css? #131

@marcusdiy

Description

@marcusdiy
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;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions