Update app.py
Browse files
app.py
CHANGED
|
@@ -1738,7 +1738,8 @@ def extract_images_from_pdf(pdf_stream: io.BytesIO):
|
|
| 1738 |
except Exception as e:
|
| 1739 |
raise RuntimeError(f"❌ Error in extract_images_from_pdf: {str(e)}")
|
| 1740 |
|
| 1741 |
-
def similarity_matching(input_json_path: str, project_folder: str) -> str:
|
|
|
|
| 1742 |
logger.info("🔍 Running similarity matching…")
|
| 1743 |
os.makedirs(project_folder, exist_ok=True)
|
| 1744 |
|
|
@@ -1753,8 +1754,8 @@ def similarity_matching(input_json_path: str, project_folder: str) -> str:
|
|
| 1753 |
# ==============================
|
| 1754 |
# READ SPRITE METADATA
|
| 1755 |
# ==============================
|
| 1756 |
-
with open(input_json_path, 'r') as f:
|
| 1757 |
-
|
| 1758 |
|
| 1759 |
sprite_ids, sprite_base64 = [], []
|
| 1760 |
for sid, sprite in sprites_data.items():
|
|
@@ -2212,7 +2213,11 @@ def save_pdf_to_generated_dir(pdf_stream: io.BytesIO, project_id: str) -> str:
|
|
| 2212 |
# 3) Copy the PDF
|
| 2213 |
# {
|
| 2214 |
# shutil.copy2(pdf_path, target_pdf)
|
| 2215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2216 |
print(f"Copied PDF from {pdf_stream} → {target_pdf}")
|
| 2217 |
logger.info(f"Copied PDF from {pdf_stream} → {target_pdf}")
|
| 2218 |
# }
|
|
|
|
| 1738 |
except Exception as e:
|
| 1739 |
raise RuntimeError(f"❌ Error in extract_images_from_pdf: {str(e)}")
|
| 1740 |
|
| 1741 |
+
# def similarity_matching(input_json_path: str, project_folder: str) -> str:
|
| 1742 |
+
def similarity_matching(sprites_data: str, project_folder: str) -> str:
|
| 1743 |
logger.info("🔍 Running similarity matching…")
|
| 1744 |
os.makedirs(project_folder, exist_ok=True)
|
| 1745 |
|
|
|
|
| 1754 |
# ==============================
|
| 1755 |
# READ SPRITE METADATA
|
| 1756 |
# ==============================
|
| 1757 |
+
# with open(input_json_path, 'r') as f:
|
| 1758 |
+
# sprites_data = json.load(f)
|
| 1759 |
|
| 1760 |
sprite_ids, sprite_base64 = [], []
|
| 1761 |
for sid, sprite in sprites_data.items():
|
|
|
|
| 2213 |
# 3) Copy the PDF
|
| 2214 |
# {
|
| 2215 |
# shutil.copy2(pdf_path, target_pdf)
|
| 2216 |
+
if isinstance(pdf_stream, io.BytesIO):
|
| 2217 |
+
with open(target_pdf, "wb") as f:
|
| 2218 |
+
f.write(pdf_stream.getbuffer())
|
| 2219 |
+
else:
|
| 2220 |
+
shutil.copy2(pdf_stream, target_pdf)
|
| 2221 |
print(f"Copied PDF from {pdf_stream} → {target_pdf}")
|
| 2222 |
logger.info(f"Copied PDF from {pdf_stream} → {target_pdf}")
|
| 2223 |
# }
|