cr8 commited on
Commit
19119d4
·
verified ·
1 Parent(s): 79444a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import gradio as gr
2
  from PIL import Image
3
- import io
4
 
5
  # Function to process and display the images in grid format
6
  def create_collage(uploaded_files, grid_layout):
@@ -36,11 +36,12 @@ def create_collage(uploaded_files, grid_layout):
36
  col = i % cols
37
  collage.paste(img, (col * img.width, row * img.height))
38
 
39
- # Save the collage as a PNG file in memory (using BytesIO)
40
- output_io = io.BytesIO()
41
- collage.save(output_io, format="PNG")
42
- output_io.seek(0) # Reset the pointer to the start of the file
43
- return output_io # Return the BytesIO object for download
 
44
 
45
  # Gradio Interface
46
  with gr.Blocks() as app:
 
1
  import gradio as gr
2
  from PIL import Image
3
+ import os
4
 
5
  # Function to process and display the images in grid format
6
  def create_collage(uploaded_files, grid_layout):
 
36
  col = i % cols
37
  collage.paste(img, (col * img.width, row * img.height))
38
 
39
+ # Save the collage as a PNG file in a temporary directory
40
+ output_path = "temp_collage.png"
41
+ collage.save(output_path, format="PNG")
42
+
43
+ # Return the file path for download
44
+ return output_path
45
 
46
  # Gradio Interface
47
  with gr.Blocks() as app: