Pimcore\Image\Adapter::cropPercent PHP Метод

cropPercent() публичный Метод

public cropPercent ( $width, $height, $x, $y ) : self
$width
$height
$x
$y
Результат self
    public function cropPercent($width, $height, $x, $y)
    {
        if ($this->isVectorGraphic()) {
            // rasterize before cropping
            $dimensions = $this->getVectorRasterDimensions();
            $this->resize($dimensions["width"], $dimensions["height"]);
        }
        $originalWidth = $this->getWidth();
        $originalHeight = $this->getHeight();
        $widthPixel = ceil($originalWidth * ($width / 100));
        $heightPixel = ceil($originalHeight * ($height / 100));
        $xPixel = ceil($originalWidth * ($x / 100));
        $yPixel = ceil($originalHeight * ($y / 100));
        return $this->crop($xPixel, $yPixel, $widthPixel, $heightPixel);
    }