Omnibus commited on
Commit
05a6079
·
verified ·
1 Parent(s): 77b6da3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -117,20 +117,23 @@ def make_animation():
117
  if spl3.endswith(".png") or spl3.endswith(".gif") or spl3.endswith(".jpg"):
118
  gif_box.append(f'{get_url}{spl2}{spl3}')
119
  if gif_box:
120
- #frames = [Image.open(image) for image in glob.glob(f"{frame_folder}/*.JPG")]
121
- frames = []
122
- for i,ea in enumerate(gif_box):
123
- print("############")
124
- print(ea)
125
- urllib.request.urlretrieve(ea,f'tmp{i}.png')
126
- frames.append(Image.open(f'tmp{i}.png'))
127
- frame_one = frames[0]
128
- filename=f'{spl3.split(".")[0]}.gif'
129
- print("**************")
130
- print(filename)
131
- frame_one.save(filename, format="GIF", append_images=frames,
132
- save_all=True, duration=100, loop=0)
133
- html_out+=f'<div class="img_class"><img src="{filename}"></div>'
 
 
 
134
  html_out+='</div>'
135
  return html_out
136
 
 
117
  if spl3.endswith(".png") or spl3.endswith(".gif") or spl3.endswith(".jpg"):
118
  gif_box.append(f'{get_url}{spl2}{spl3}')
119
  if gif_box:
120
+ try:
121
+ #frames = [Image.open(image) for image in glob.glob(f"{frame_folder}/*.JPG")]
122
+ frames = []
123
+ for i,ea in enumerate(gif_box):
124
+ print("############")
125
+ print(ea)
126
+ urllib.request.urlretrieve(ea,f'tmp{i}.png')
127
+ frames.append(Image.open(f'tmp{i}.png'))
128
+ frame_one = frames[0]
129
+ filename=f'{spl3.split(".")[0]}.gif'
130
+ print("**************")
131
+ print(filename)
132
+ frame_one.save(filename, format="GIF", append_images=frames,
133
+ save_all=True, duration=100, loop=0)
134
+ html_out+=f'<div class="img_class"><img src="{filename}"></div>'
135
+ except Exception as e:
136
+ print(e)
137
  html_out+='</div>'
138
  return html_out
139