/** * @param ImageInterface $image * @param ConfigInterface $versionConfig * * @return ImageInterface */ protected function createImageVersion(ImageInterface $image, ConfigInterface $versionConfig) { $width = $versionConfig->getWidth(); if ($width === 0) { $width = PHP_INT_MAX; } $height = $versionConfig->getHeight(); if ($height === 0) { $height = PHP_INT_MAX; } $image = $image->thumbnail(new Box($width, $height), $versionConfig->isFit() ? ImageInterface::THUMBNAIL_INSET : ImageInterface::THUMBNAIL_OUTBOUND); return $image; }
/** * @param ConfigInterface $configObject * @param $parametersConfig */ protected function setParameters(ConfigInterface $configObject, $parametersConfig) { foreach ($parametersConfig as $parameter) { $parameterParts = explode('=', $parameter); $parameterName = $parameterParts[0]; $parameterValue = array_key_exists(1, $parameterParts) ? $parameterParts[1] : null; switch ($parameterName) { case 'quality': if ($parameterValue === null) { throw new InvalidConfigException('Quality value "' . $parameterValue . '" is incorrect.'); } else { $configObject->setQuality(intval($parameterValue)); } break; default: throw new InvalidConfigException('Parameter "' . $parameterName . '" is incorrect.'); } } }