Skip to content

Commit f5aaf3a

Browse files
authored
Merge pull request #57 from dadaxr/patch-1
Add support for webp file format
2 parents cdb345f + 4d9cc36 commit f5aaf3a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ImageResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public static function createFromFile($file)
8181
case IMAGETYPE_PNG:
8282
$resource = imagecreatefrompng($file);
8383
break;
84+
case IMAGETYPE_WEBP:
85+
$resource = imagecreatefromwebp($file);
86+
break;
8487
default:
8588
throw new InvalidArgumentException('Unknown image file');
8689
}
@@ -394,6 +397,9 @@ public function toFile($file)
394397
$compression = static::convertJpegQualityToPngCompression(static::$quality);
395398
imagepng($this->resource, $file, $compression);
396399
break;
400+
case IMAGETYPE_WEBP:
401+
imagewebp($this->resource, $file, static::$quality);
402+
break;
397403
default:
398404
throw new \RuntimeException('Unknown image type');
399405
}

0 commit comments

Comments
 (0)