Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1742,6 +1742,7 @@ def extract_images_from_pdf(pdf_path: Path):
|
|
1742 |
try:
|
1743 |
image_data = base64.b64decode(
|
1744 |
element["metadata"]["image_base64"])
|
|
|
1745 |
image = Image.open(BytesIO(image_data)).convert("RGB") # Use BytesIO here
|
1746 |
|
1747 |
image = upscale_image(image, scale=2)
|
@@ -1753,7 +1754,7 @@ def extract_images_from_pdf(pdf_path: Path):
|
|
1753 |
image.save(img_buffer, format="PNG")
|
1754 |
img_bytes = img_buffer.getvalue()
|
1755 |
img_base64 = base64.b64encode(img_bytes).decode("utf-8")
|
1756 |
-
|
1757 |
# Optionally save image to disk if desired for debugging/permanent storage
|
1758 |
image_path = extracted_image_subdir / f"Sprite_{i+1}.png"
|
1759 |
image.save(image_path)
|
@@ -1802,6 +1803,8 @@ def extract_images_from_pdf(pdf_path: Path):
|
|
1802 |
"file-path": pdf_dir_path,
|
1803 |
"description": description
|
1804 |
}
|
|
|
|
|
1805 |
sprite_count += 1
|
1806 |
print(f"\n===================manipulated JSON: {manipulated_json}")
|
1807 |
except Exception as e:
|
|
|
1742 |
try:
|
1743 |
image_data = base64.b64decode(
|
1744 |
element["metadata"]["image_base64"])
|
1745 |
+
print(f"\n ------------------------------image_data: {image_data}")
|
1746 |
image = Image.open(BytesIO(image_data)).convert("RGB") # Use BytesIO here
|
1747 |
|
1748 |
image = upscale_image(image, scale=2)
|
|
|
1754 |
image.save(img_buffer, format="PNG")
|
1755 |
img_bytes = img_buffer.getvalue()
|
1756 |
img_base64 = base64.b64encode(img_bytes).decode("utf-8")
|
1757 |
+
print(f"\n------------------------------------------------Image_Base64: {img_base64}")
|
1758 |
# Optionally save image to disk if desired for debugging/permanent storage
|
1759 |
image_path = extracted_image_subdir / f"Sprite_{i+1}.png"
|
1760 |
image.save(image_path)
|
|
|
1803 |
"file-path": pdf_dir_path,
|
1804 |
"description": description
|
1805 |
}
|
1806 |
+
print(f"\n ------------------elemente: {element['metadata']['image_base64']}")
|
1807 |
+
print(f"\n ------------------pdf_dir_path: {pdf_dir_path}")
|
1808 |
sprite_count += 1
|
1809 |
print(f"\n===================manipulated JSON: {manipulated_json}")
|
1810 |
except Exception as e:
|