Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,9 +15,9 @@ def create_gif(editor1_output, editor2_output, transition_type):
|
|
15 |
|
16 |
frames = []
|
17 |
duration = 100 # Duration for each frame in milliseconds
|
18 |
-
total_frames =
|
19 |
|
20 |
-
size = (
|
21 |
img1 = img1.resize(size, Image.LANCZOS)
|
22 |
img2 = img2.resize(size, Image.LANCZOS)
|
23 |
|
@@ -27,13 +27,15 @@ def create_gif(editor1_output, editor2_output, transition_type):
|
|
27 |
draw = ImageDraw.Draw(mask)
|
28 |
|
29 |
# Calculate position with reversal
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
progress = 2 - (i / (total_frames // 2 - 1))
|
34 |
|
35 |
x_position = int(size[0] * progress)
|
36 |
|
|
|
|
|
|
|
37 |
# Determine which image should be on the left based on direction
|
38 |
if i < total_frames // 2:
|
39 |
left_img, right_img = img1, img2
|
|
|
15 |
|
16 |
frames = []
|
17 |
duration = 100 # Duration for each frame in milliseconds
|
18 |
+
total_frames = 18 # Total number of frames (increased for smoother animation)
|
19 |
|
20 |
+
size = (256, 256) # Increased size for better quality
|
21 |
img1 = img1.resize(size, Image.LANCZOS)
|
22 |
img2 = img2.resize(size, Image.LANCZOS)
|
23 |
|
|
|
27 |
draw = ImageDraw.Draw(mask)
|
28 |
|
29 |
# Calculate position with reversal
|
30 |
+
progress = (i / (total_frames - 1)) * 2
|
31 |
+
if progress > 1:
|
32 |
+
progress = 2 - progress
|
|
|
33 |
|
34 |
x_position = int(size[0] * progress)
|
35 |
|
36 |
+
# Ensure x_position is within valid range
|
37 |
+
x_position = max(0, min(x_position, size[0]))
|
38 |
+
|
39 |
# Determine which image should be on the left based on direction
|
40 |
if i < total_frames // 2:
|
41 |
left_img, right_img = img1, img2
|