newoz commited on
Commit
47c535b
·
1 Parent(s): a6861cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
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
- image_width = 800 # Set the desired width
101
- image_height = 600 # Set the desired height
102
- image = Image.open(io.BytesIO(image_bytes)).resize((image_width, image_height))
103
-
104
- temp_img_path = tempfile.NamedTemporaryFile(delete=False, suffix=".png").name
105
- image.save(temp_img_path)
 
 
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