/** * @param null|int $width * @param null|int $height * @return string */ private function getResizedImagePath($width, $height) { if ($width === null && $height === null) { $width = $this->image->getWidth(); $height = $this->image->getHeight(); } else { if ($width === null) { $width = $this->image->getWidth(); } else { if ($height === null) { $height = $this->image->getHeight(); } } } $wRatio = max($this->image->getWidth() / $width, 1); $hRatio = max($this->image->getHeight() / $height, 1); if (!$this->crop) { $wRatio = $hRatio = max($wRatio, $hRatio); } $width = round($this->image->getWidth() / $wRatio); $height = round($this->image->getHeight() / $hRatio); $imageSize = $this->fileStorage->createResizedImage($this->image, $width, $height, $this->crop); return $this->fileStorage->getWebPath($this->image, $imageSize); }
/** * @param Image $image * @param int|null $targetWidth * @param int|null $targetHeight * @param bool $crop * @return array */ private function getFullSizeDimensions(Image $image, $targetWidth = null, $targetHeight = null, $crop) { if ($targetWidth === null && $targetHeight === null) { $width = $image->getWidth(); $height = $image->getHeight(); } else { if ($targetWidth === null) { $width = $image->getWidth(); $height = $targetHeight; } else { if ($targetHeight === null) { $width = $targetWidth; $height = $image->getHeight(); } } } $wRatio = max($image->getWidth() / $width, 1); $hRatio = max($image->getHeight() / $height, 1); if (!$crop) { $wRatio = $hRatio = max($wRatio, $hRatio); } $width = round($image->getWidth() / $wRatio); $height = round($image->getHeight() / $hRatio); return array($width, $height); }