Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -97,16 +97,25 @@ if uploaded_file is not None:
|
|
| 97 |
image_bytes = query({
|
| 98 |
"inputs": 'A picture without text about: ' + summary[0]['summary_text']
|
| 99 |
})
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
image
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
| 106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
left = Inches(1)
|
| 108 |
top = Inches(2)
|
| 109 |
pic = slide.shapes.add_picture(temp_img_path, left, top, width, height)
|
|
|
|
| 110 |
|
| 111 |
i += 1
|
| 112 |
|
|
|
|
| 97 |
image_bytes = query({
|
| 98 |
"inputs": 'A picture without text about: ' + summary[0]['summary_text']
|
| 99 |
})
|
| 100 |
+
image = Image.open(io.BytesIO(image_bytes))
|
| 101 |
+
|
| 102 |
+
# Define the desired image width and height
|
| 103 |
+
image_width = 800 # Adjust as needed
|
| 104 |
+
image_height = 600 # Adjust as needed
|
| 105 |
+
|
| 106 |
+
# Resize the image to the desired dimensions
|
| 107 |
+
image = image.resize((image_width, image_height), Image.ANTIALIAS)
|
| 108 |
|
| 109 |
+
# Create a temporary file to save the resized image
|
| 110 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as temp_img_file:
|
| 111 |
+
temp_img_path = temp_img_file.name
|
| 112 |
+
image.save(temp_img_path, format="PNG")
|
| 113 |
+
|
| 114 |
+
# Add the image to the slide
|
| 115 |
left = Inches(1)
|
| 116 |
top = Inches(2)
|
| 117 |
pic = slide.shapes.add_picture(temp_img_path, left, top, width, height)
|
| 118 |
+
|
| 119 |
|
| 120 |
i += 1
|
| 121 |
|