Pimcore\Model\Asset\Image::getDimensions PHP Метод

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

public getDimensions ( null $path = null, boolean $force = false ) : array | void
$path null
$force boolean
Результат array | void
    public function getDimensions($path = null, $force = false)
    {
        if (!$force) {
            $width = $this->getCustomSetting("imageWidth");
            $height = $this->getCustomSetting("imageHeight");
            if ($width && $height) {
                return ["width" => $width, "height" => $height];
            }
        }
        if (!$path) {
            $path = $this->getFileSystemPath();
        }
        //try to get the dimensions with getimagesize because it is much faster than e.g. the Imagick-Adapter
        if (is_readable($path)) {
            $dimensions = getimagesize($path);
            if ($dimensions[0] && $dimensions[1]) {
                return ["width" => $dimensions[0], "height" => $dimensions[1]];
            }
        }
        $image = self::getImageTransformInstance();
        $status = $image->load($path);
        if ($status === false) {
            return;
        }
        $dimensions = ["width" => $image->getWidth(), "height" => $image->getHeight()];
        return $dimensions;
    }