summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/bing/upload_image.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-13 15:53:53 +0100
committerGitHub <noreply@github.com>2024-01-13 15:53:53 +0100
commit88bfe2ce426258e2cb85072721004b6abdf746ba (patch)
tree44e3827128489f13fd6fbe7d18171d81176abc86 /g4f/Provider/bing/upload_image.py
parentMerge pull request #1462 from hlohaus/img (diff)
parentMerge branch 'main' into main (diff)
downloadgpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.gz
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.bz2
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.lz
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.xz
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.tar.zst
gpt4free-88bfe2ce426258e2cb85072721004b6abdf746ba.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/bing/upload_image.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/g4f/Provider/bing/upload_image.py b/g4f/Provider/bing/upload_image.py
index a7413207..041905fd 100644
--- a/g4f/Provider/bing/upload_image.py
+++ b/g4f/Provider/bing/upload_image.py
@@ -3,14 +3,17 @@ from __future__ import annotations
import string
import random
import json
-import numpy as np
+import io
+import base64
+import math
+from PIL import Image
from ...typing import ImageType
from aiohttp import ClientSession
from ...image import to_image, process_image, to_base64
image_config = {
"maxImagePixels": 360000,
- "imageCompressionRate": 0.7,
+ "imageComp.ssionRate": 0.7,
"enableFaceBlurDebug": 0,
}
@@ -24,8 +27,8 @@ async def upload_image(
width, height = image.size
max_image_pixels = image_config['maxImagePixels']
if max_image_pixels / (width * height) < 1:
- new_width = int(width * np.sqrt(max_image_pixels / (width * height)))
- new_height = int(height * np.sqrt(max_image_pixels / (width * height)))
+ new_width = int(width * math.sqrt(max_image_pixels / (width * height)))
+ new_height = int(height * math.sqrt(max_image_pixels / (width * height)))
else:
new_width = width
new_height = height
@@ -55,8 +58,7 @@ async def upload_image(
else "https://www.bing.com/images/blob?bcid="
+ result['bcid']
)
- return result
-
+ return result
def build_image_upload_api_payload(image_bin: str, tone: str):
payload = {