Jung commited on
Commit
a390c29
·
verified ·
1 Parent(s): 3239856

fix avatar error

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -68,8 +68,14 @@ def display_image(url, scale=0.5, enable_flag = False):
68
  enable_flag = False if display_img_flag != 'Yes' else True # adhoc code, should send this variable properly
69
 
70
  if enable_flag: # default to False as imgur server seems to refuse our request and cause permanent error
71
- image = Image.open(urlopen(url))
72
- st.image(image.resize(( int(image.width * scale), int(image.height * scale))))
 
 
 
 
 
 
73
 
74
  def display_heroes_from_df(df,display_cols=display_cols, show_df=True):
75
  vtob = "is" if len(df)<=1 else "are"
@@ -209,8 +215,8 @@ with st.sidebar:
209
 
210
  display_img_flag = st.radio(
211
  "Display Avatar in Description",
212
- ["No", "Yes"],
213
- captions = ["Currently default to 'no' since the server seems to ban our service", "If problem occur, set to 'no'"]
214
  )
215
 
216
  #########################################
 
68
  enable_flag = False if display_img_flag != 'Yes' else True # adhoc code, should send this variable properly
69
 
70
  if enable_flag: # default to False as imgur server seems to refuse our request and cause permanent error
71
+ # image = Image.open(urlopen(url))
72
+ # st.image(image.resize(( int(image.width * scale), int(image.height * scale))))
73
+
74
+ """
75
+ The problem occur because imgur remove file extension e.g. 'jpg',
76
+ so either url is wrong with urlopen or Image.open does not know image type if use requests/urllib3
77
+ """
78
+ st.image(url)
79
 
80
  def display_heroes_from_df(df,display_cols=display_cols, show_df=True):
81
  vtob = "is" if len(df)<=1 else "are"
 
215
 
216
  display_img_flag = st.radio(
217
  "Display Avatar in Description",
218
+ ["Yes", "No"],
219
+ captions = ["Default", "If problem occur, set to 'no'"]
220
  )
221
 
222
  #########################################