summaryrefslogtreecommitdiffstats
path: root/g4f/image.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-13 18:12:21 +0100
committerGitHub <noreply@github.com>2024-01-13 18:12:21 +0100
commit691fac6db61cf91afbe9abe45e8bd3d47f985e01 (patch)
treefd1ddf447d186ee5e4c8977e5b937e4161392b4c /g4f/image.py
parentMerge pull request #1465 from hlohaus/upp (diff)
parentFix process_image in Bing (diff)
downloadgpt4free-691fac6db61cf91afbe9abe45e8bd3d47f985e01.tar
gpt4free-691fac6db61cf91afbe9abe45e8bd3d47f985e01.tar.gz
gpt4free-691fac6db61cf91afbe9abe45e8bd3d47f985e01.tar.bz2
gpt4free-691fac6db61cf91afbe9abe45e8bd3d47f985e01.tar.lz
gpt4free-691fac6db61cf91afbe9abe45e8bd3d47f985e01.tar.xz
gpt4free-691fac6db61cf91afbe9abe45e8bd3d47f985e01.tar.zst
gpt4free-691fac6db61cf91afbe9abe45e8bd3d47f985e01.zip
Diffstat (limited to 'g4f/image.py')
-rw-r--r--g4f/image.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/g4f/image.py b/g4f/image.py
index 4a97247e..01664f4e 100644
--- a/g4f/image.py
+++ b/g4f/image.py
@@ -64,7 +64,6 @@ def get_orientation(image: Image.Image) -> int:
def process_image(img: Image.Image, new_width: int, new_height: int) -> Image.Image:
orientation = get_orientation(img)
- new_img = Image.new("RGB", (new_width, new_height), color="#FFFFFF")
if orientation:
if orientation > 4:
img = img.transpose(Image.FLIP_LEFT_RIGHT)
@@ -74,8 +73,8 @@ def process_image(img: Image.Image, new_width: int, new_height: int) -> Image.Im
img = img.transpose(Image.ROTATE_270)
if orientation in [7, 8]:
img = img.transpose(Image.ROTATE_90)
- new_img.paste(img, (0, 0))
- return new_img
+ img.thumbnail((new_width, new_height))
+ return img
def to_base64(image: Image.Image, compression_rate: float) -> str:
output_buffer = BytesIO()