Ritvik19 commited on
Commit
3cb2b29
1 Parent(s): abc2c79

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +4 -4
server.py CHANGED
@@ -13,16 +13,16 @@ def parse_pdf_and_return_markdown(pdf_file: bytes , extract_images: bool):
13
  image_data = {}
14
  if extract_images:
15
  for i, (filename, image) in enumerate(images.items()):
16
- image_filepath = f"image_{i+1}.png"
17
- image.save(image_filepath, "PNG")
18
 
19
- with open(image_filepath, "rb") as f:
20
  image_bytes = f.read()
21
 
22
  image_base64 = base64.b64encode(image_bytes).decode('utf-8')
23
  image_data[f'image_{i+1}'] = image_base64
24
 
25
- os.remove(image_filepath)
26
 
27
  return full_text, out_meta, image_data
28
 
 
13
  image_data = {}
14
  if extract_images:
15
  for i, (filename, image) in enumerate(images.items()):
16
+ # image_filepath = f"image_{i+1}.png"
17
+ image.save(filename, "PNG")
18
 
19
+ with open(filename, "rb") as f:
20
  image_bytes = f.read()
21
 
22
  image_base64 = base64.b64encode(image_bytes).decode('utf-8')
23
  image_data[f'image_{i+1}'] = image_base64
24
 
25
+ os.remove(filename)
26
 
27
  return full_text, out_meta, image_data
28