Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ HTML_CONTENT = """
|
|
28 |
<h1>GIF Generator</h1>
|
29 |
<form id="upload-form" enctype="multipart/form-data">
|
30 |
<input type="file" name="images" accept="image/*" multiple>
|
31 |
-
<input type="number" name="
|
32 |
<button type="button" id="generate-button">Generate GIF</button>
|
33 |
</form>
|
34 |
<div id="gif-container" style="display:none;">
|
@@ -76,7 +76,7 @@ def index():
|
|
76 |
def upload():
|
77 |
try:
|
78 |
files = request.files.getlist('images')
|
79 |
-
|
80 |
if not files:
|
81 |
return "No images uploaded", 400
|
82 |
|
@@ -103,9 +103,9 @@ def upload():
|
|
103 |
resized_img = img.resize((max_width, max_height), Image.LANCZOS)
|
104 |
resized_images.append(resized_img)
|
105 |
|
106 |
-
|
107 |
gif_bytes = BytesIO()
|
108 |
-
mimwrite(gif_bytes, [img for img in resized_images], format='GIF',
|
109 |
gif_bytes.seek(0)
|
110 |
gif_base64 = base64.b64encode(gif_bytes.read()).decode('utf-8')
|
111 |
gif_url = f'data:image/gif;base64,{gif_base64}'
|
|
|
28 |
<h1>GIF Generator</h1>
|
29 |
<form id="upload-form" enctype="multipart/form-data">
|
30 |
<input type="file" name="images" accept="image/*" multiple>
|
31 |
+
<input type="number" name="delay" placeholder="Delay (ms)" value="100" min="1" >
|
32 |
<button type="button" id="generate-button">Generate GIF</button>
|
33 |
</form>
|
34 |
<div id="gif-container" style="display:none;">
|
|
|
76 |
def upload():
|
77 |
try:
|
78 |
files = request.files.getlist('images')
|
79 |
+
delay_ms = int(request.form.get('delay', 100))
|
80 |
if not files:
|
81 |
return "No images uploaded", 400
|
82 |
|
|
|
103 |
resized_img = img.resize((max_width, max_height), Image.LANCZOS)
|
104 |
resized_images.append(resized_img)
|
105 |
|
106 |
+
# Generate GIF using imageio with loop and duration
|
107 |
gif_bytes = BytesIO()
|
108 |
+
mimwrite(gif_bytes, [img for img in resized_images], format='GIF', loop=0, duration=delay_ms/1000)
|
109 |
gif_bytes.seek(0)
|
110 |
gif_base64 = base64.b64encode(gif_bytes.read()).decode('utf-8')
|
111 |
gif_url = f'data:image/gif;base64,{gif_base64}'
|