Vihang28 commited on
Commit
ed99c12
·
verified ·
1 Parent(s): 2a4396e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -18,6 +18,9 @@ def pdf_to_img(pdf_path):
18
  base_img = pdf_document.extract_image(image[0])
19
  image_data = base_img["image"]
20
  img = Image.open(io.BytesIO(image_data))
 
 
 
21
  extention = base_img['ext']
22
  img.save(open(f"image{counter}.{extention}","wb"))
23
  img_list.append(f"image{counter}.{extention}")
 
18
  base_img = pdf_document.extract_image(image[0])
19
  image_data = base_img["image"]
20
  img = Image.open(io.BytesIO(image_data))
21
+ if img.mode == "RGBA":
22
+ # Convert RGBA image to RGB
23
+ img = img.convert("RGB")
24
  extention = base_img['ext']
25
  img.save(open(f"image{counter}.{extention}","wb"))
26
  img_list.append(f"image{counter}.{extention}")