Bkwld\Croppa\Image::trimPerc PHP Method

trimPerc() public method

Trim the source before applying the crop with offset percentages
public trimPerc ( array $coords )
$coords array Cropping instructions as percentages
    public function trimPerc($coords)
    {
        list($x1, $y1, $x2, $y2) = $coords;
        $size = (object) $this->thumb->getCurrentDimensions();
        // Convert percentage values to what GdThumb expects
        $x = round($x1 * $size->width);
        $y = round($y1 * $size->height);
        $width = round($x2 * $size->width - $x);
        $height = round($y2 * $size->height - $y);
        $this->thumb->crop($x, $y, $width, $height);
        return $this;
    }