From 51264fe20cda57eff47ac9a386edb3563eac4568 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Fri, 23 Feb 2024 11:33:38 +0100 Subject: Add GeminiPro API provider Set min version for undetected-chromedriver Add api_key to the new client --- g4f/image.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'g4f/image.py') 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).") -- cgit v1.2.3