}
break;
+ case IMAGETYPE_WEBP:
+ // suppress warnings and properly handle errors
+ $this->image = @imagecreatefromwebp($file);
+ if ($this->image === false) {
+ throw new SystemException("Could not read webp image '".$file."'.");
+ }
+ break;
+
default:
throw new SystemException("Could not read image '".$file."', format is not recognized.");
- break;
}
}
/**
* @inheritDoc
*/
- public function createThumbnail($maxWidth, $maxHeight, $obtainDimensions = true) {
+ public function createThumbnail($maxWidth, $maxHeight, $preserveAspectRatio = true) {
$x = $y = 0;
$sourceWidth = $this->width;
$sourceHeight = $this->height;
- if ($obtainDimensions) {
+ if ($preserveAspectRatio) {
if ($maxWidth / $this->width < $maxHeight / $this->height) {
$width = $maxWidth;
$height = round($this->height * ($width / $this->width));
else if ($this->type == IMAGETYPE_PNG) {
imagepng($image);
}
+ else if ($this->type == IMAGETYPE_WEBP) {
+ imagewebp($image);
+ }
else if (function_exists('imageJPEG')) {
imagejpeg($image, null, 90);
}