Skip to content

Commit

Permalink
Merge pull request #23 from x-zolezzi/feature/webp-support
Browse files Browse the repository at this point in the history
Add support Webp image
  • Loading branch information
SmetDenis authored Mar 11, 2020
2 parents ec1b14d + 81bb23a commit 14c7146
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ public static function isPng($format): bool
return 'image/png' === $format || 'png' === $format;
}

/**
* @param string $format
* @return bool
*/
public static function isWebp($format): bool
{
$format = strtolower($format);
return 'image/webp' === $format || 'webp' === $format;
}

/**
* Converts a hex color value to its RGB equivalent
*
Expand Down Expand Up @@ -424,10 +434,10 @@ public static function strToBin($imageString): string
* @param string $format
* @return bool
*/
public static function isSupportedFormat($format): bool
public static function isSupportedFormat($format)
{
if ($format) {
return self::isJpeg($format) || self::isPng($format) || self::isGif($format);
return self::isJpeg($format) || self::isPng($format) || self::isGif($format) || self::isWebp($format);
}

return false;
Expand Down

0 comments on commit 14c7146

Please sign in to comment.