Update server.py
Browse files
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(
|
18 |
|
19 |
-
with open(
|
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(
|
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 |
|