Update Image_text_generation.py
Browse files- Image_text_generation.py +3 -3
Image_text_generation.py
CHANGED
@@ -36,7 +36,7 @@ class Image_text_Generator:
|
|
36 |
return part.inline_data.data
|
37 |
return None
|
38 |
|
39 |
-
def upload_image_to_tmp(self,
|
40 |
"""
|
41 |
返回:
|
42 |
str: 上傳後的圖片 URL,如果上傳失敗則返回 None。
|
@@ -46,10 +46,10 @@ class Image_text_Generator:
|
|
46 |
image = PIL.Image.open(io.BytesIO(image_binary))
|
47 |
|
48 |
# 建立暫存檔案以便上傳
|
49 |
-
image.save('tmp/
|
50 |
|
51 |
# 返回圖片的連結
|
52 |
-
return 'tmp/
|
53 |
except Exception as e:
|
54 |
print(f"圖片上傳失敗: {e}")
|
55 |
return None
|
|
|
36 |
return part.inline_data.data
|
37 |
return None
|
38 |
|
39 |
+
def upload_image_to_tmp(self, user_id):
|
40 |
"""
|
41 |
返回:
|
42 |
str: 上傳後的圖片 URL,如果上傳失敗則返回 None。
|
|
|
46 |
image = PIL.Image.open(io.BytesIO(image_binary))
|
47 |
|
48 |
# 建立暫存檔案以便上傳
|
49 |
+
image.save('tmp/'+user_id+'.png', format='PNG')
|
50 |
|
51 |
# 返回圖片的連結
|
52 |
+
return 'tmp/'+user_id+'.png'
|
53 |
except Exception as e:
|
54 |
print(f"圖片上傳失敗: {e}")
|
55 |
return None
|