From 7e5f01b82db02fa19a95d952df788ac2c6ed50ac Mon Sep 17 00:00:00 2001 From: io mintz Date: Mon, 18 May 2020 02:03:31 +0000 Subject: [PATCH] support WEBP --- utils/errors.py | 4 ++-- utils/image.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/errors.py b/utils/errors.py index adf7a3e..67bdcdf 100644 --- a/utils/errors.py +++ b/utils/errors.py @@ -60,14 +60,14 @@ class FileTooBigError(EmoteManagerError): self.limit = limit class InvalidFileError(EmoteManagerError): - """The file is not a zip, tar, GIF, PNG, or JPG file.""" + """The file is not a zip, tar, GIF, PNG, JPG, or WEBP file.""" def __init__(self): super().__init__('Invalid file given.') class InvalidImageError(InvalidFileError): """The image is not a GIF, PNG, or JPG""" def __init__(self): - super(Exception, self).__init__('The image supplied was not a GIF, PNG, or JPG.') + super(Exception, self).__init__('The image supplied was not a GIF, PNG, JPG, or WEBP file.') class PermissionDeniedError(EmoteManagerError): """Raised when a user tries to modify an emote without the Manage Emojis permission""" diff --git a/utils/image.py b/utils/image.py index 0a9cf6e..ac78443 100755 --- a/utils/image.py +++ b/utils/image.py @@ -87,6 +87,8 @@ def mime_type_for_image(data): return 'image/jpeg' if data.startswith((b'GIF87a', b'GIF89a')): return 'image/gif' + if data.startswith(b'RIFF') and data[8:12] == b'WEBP': + return 'image/webp' raise errors.InvalidImageError def image_to_base64_url(data):