diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 11:33:38 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-23 11:33:38 +0100 |
commit | 51264fe20cda57eff47ac9a386edb3563eac4568 (patch) | |
tree | 29233c3c384ebc8cc493e68842aa0dcff499cd49 /g4f/image.py | |
parent | Add missing file (diff) | |
download | gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.gz gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.bz2 gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.lz gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.xz gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.tar.zst gpt4free-51264fe20cda57eff47ac9a386edb3563eac4568.zip |
Diffstat (limited to 'g4f/image.py')
-rw-r--r-- | g4f/image.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/g4f/image.py b/g4f/image.py index 6370a06f..d77654a6 100644 --- a/g4f/image.py +++ b/g4f/image.py @@ -97,17 +97,17 @@ def is_accepted_format(binary_data: bytes) -> bool: ValueError: If the image format is not allowed. """ if binary_data.startswith(b'\xFF\xD8\xFF'): - pass # It's a JPEG image + return "image/jpeg" elif binary_data.startswith(b'\x89PNG\r\n\x1a\n'): - pass # It's a PNG image + return "image/png" elif binary_data.startswith(b'GIF87a') or binary_data.startswith(b'GIF89a'): - pass # It's a GIF image + return "image/gif" elif binary_data.startswith(b'\x89JFIF') or binary_data.startswith(b'JFIF\x00'): - pass # It's a JPEG image + return "image/jpeg" elif binary_data.startswith(b'\xFF\xD8'): - pass # It's a JPEG image + return "image/jpeg" elif binary_data.startswith(b'RIFF') and binary_data[8:12] == b'WEBP': - pass # It's a WebP image + return "image/webp" else: raise ValueError("Invalid image format (from magic code).") |