alanchen1115 commited on
Commit
1b03958
·
verified ·
1 Parent(s): da72bf2

Update Image_text_generation.py

Browse files
Files changed (1) hide show
  1. 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, image_binary):
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/temp.png', format='PNG')
50
 
51
  # 返回圖片的連結
52
- return 'tmp/temp.png'
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