Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure image extensions, vbump #159

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions llama_parse/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ def get_json_result(
def get_images(self, json_result: List[dict], download_path: str) -> List[dict]:
"""Download images from the parsed result."""
headers = {"Authorization": f"Bearer {self.api_key}"}

# make the download path
if not os.path.exists(download_path):
os.makedirs(download_path)

try:
images = []
for result in json_result:
Expand All @@ -318,9 +323,16 @@ def get_images(self, json_result: List[dict], download_path: str) -> List[dict]:
print(f"> Image for page {page['page']}: {page['images']}")
for image in page["images"]:
image_name = image["name"]

# get the full path
image_path = os.path.join(
download_path, f"{job_id}-{image_name}"
)

# get a valid image path
if not image_path.endswith(".png"):
image_path += ".png"

image["path"] = image_path
image["job_id"] = job_id
image["original_pdf_path"] = result["file_path"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "llama-parse"
version = "0.4.1"
version = "0.4.2"
description = "Parse files into RAG-Optimized formats."
authors = ["Logan Markewich <[email protected]>"]
license = "MIT"
Expand Down
Loading