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