Repository: Hipo/drf-extra-fields (language: python)

Issue:
Allow WebP format for Base64ImageField
## Feature Request:

Allow [WebP](https://developers.google.com/speed/webp) format in Base64ImageField

## Current Behavior:

When trying to upload a base64 encoded webp image the serializer throw a `ValidationError` with saying: "The type of the image couldn't be determined."

## Expected behavior

Upload webp image success
 


Discussion / hints:

Fix patch:
diff --git a/drf_extra_fields/fields.py b/drf_extra_fields/fields.py
index 2b5eecd..9546960 100644
--- a/drf_extra_fields/fields.py
+++ b/drf_extra_fields/fields.py
@@ -128,7 +128,8 @@ class Base64ImageField(Base64FieldMixin, ImageField):
         "jpeg",
         "jpg",
         "png",
-        "gif"
+        "gif",
+        "webp"
     )
     INVALID_FILE_MESSAGE = _("Please upload a valid image.")
     INVALID_TYPE_MESSAGE = _("The type of the image couldn't be determined.")


Test patch:
diff --git a/tests/test_fields.py b/tests/test_fields.py
index 86b0591..cc24cb4 100644
--- a/tests/test_fields.py
+++ b/tests/test_fields.py
@@ -185,6 +185,20 @@ def test_hybrid_image_field(self):
                 self.assertTrue(mixin_patch.to_internal_value.called)
                 self.assertTrue(image_patch.to_internal_value.called)
 
+    def test_create_with_webp_image(self):
+        """
+        Test for creating Base64 image with webp format in the server side
+        """
+        now = datetime.datetime.now()
+        
+        file = "data:image/webp;base64,UklGRkAAAABXRUJQVlA4IDQAAADwAQCdASoBAAEAAQAc" \
+               "JaACdLoB+AAETAAA/vW4f/6aR40jxpHxcP/ugT90CfugT/3NoAAA"
+        serializer = UploadedBase64ImageSerializer(data={'created': now, 'file': file})
+        uploaded_image = UploadedBase64Image(file=file, created=now)
+        self.assertTrue(serializer.is_valid())
+        self.assertEqual(serializer.validated_data['created'], uploaded_image.created)
+        self.assertFalse(serializer.validated_data is uploaded_image)
+
 
 class PDFBase64FileField(Base64FileField):
     ALLOWED_TYPES = ('pdf',)