Skip to content

Commit

Permalink
Merge pull request #57 from dadaxr/patch-1
Browse files Browse the repository at this point in the history
Add support for webp file format
  • Loading branch information
bobdenotter authored Feb 27, 2023
2 parents cdb345f + 4d9cc36 commit f5aaf3a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ImageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public static function createFromFile($file)
case IMAGETYPE_PNG:
$resource = imagecreatefrompng($file);
break;
case IMAGETYPE_WEBP:
$resource = imagecreatefromwebp($file);
break;
default:
throw new InvalidArgumentException('Unknown image file');
}
Expand Down Expand Up @@ -394,6 +397,9 @@ public function toFile($file)
$compression = static::convertJpegQualityToPngCompression(static::$quality);
imagepng($this->resource, $file, $compression);
break;
case IMAGETYPE_WEBP:
imagewebp($this->resource, $file, static::$quality);
break;
default:
throw new \RuntimeException('Unknown image type');
}
Expand Down

0 comments on commit f5aaf3a

Please sign in to comment.