[Bug]: PDF images saved with save_images_locally=True come back with an empty src in result.media
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu tại bộ xử lý PDF ở PDFContentScrapingStrategy.scrap() và kiểm tra cách các từ điển hình ảnh đã lưu được truyền vào ScrapingResult(media={"images": [...]}); sau đó xem schema MediaItem để biết những trường nào được giữ lại. Tái hiện lỗi bằng ví dụ PDF Pillow trong issue. Hoàn tất khi mỗi hình ảnh đã lưu trong result.media.images có cách để xác định vị trí tệp của nó trong image_save_dir, đồng thời hành vi hình ảnh nội tuyến vẫn được giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
crawl4ai version
0.9.5 (develop at 78405d6)
Expected Behavior
With PDFContentScrapingStrategy(extract_images=True, save_images_locally=True), each entry in result.media.images should point at the image file that was written to image_save_dir.
Current Behavior
The image is written to disk, but the MediaItem in result.media.images has src == "" and data == "", so there is no way to find the file from the result.
The PDF processor reports a saved image as {"path": ..., "format": ..., "width": ..., ...}. scrap() passes these dicts straight into ScrapingResult(media={"images": [...]}), and MediaItem has no path field, so pydantic drops it. Same kind of schema mismatch as #2374 for links. Inline images (save_images_locally=False) are fine because data is a MediaItem field.
Is this reproducible?
Yes
Inputs Causing the Bug
Any PDF with an embedded image, e.g. one made by Pillow (below).
Steps to Reproduce
1. Make a one-page PDF containing an image.
2. Scrape it with PDFContentScrapingStrategy(extract_images=True, save_images_locally=True, image_save_dir=...).
3. Look at result.media.images.
Code snippets
import os, tempfile
from PIL import Image
from crawl4ai.processors.pdf import PDFContentScrapingStrategy
d = tempfile.mkdtemp()
pdf = os.path.join(d, "doc.pdf")
Image.new("RGB", (40, 30), "red").save(pdf)
strategy = PDFContentScrapingStrategy(
extract_images=True, save_images_locally=True, image_save_dir=os.path.join(d, "imgs")
)
result = strategy.scrap(pdf, "")
print(os.listdir(os.path.join(d, "imgs")))
print(result.media.images[0].model_dump())
Output:
['page_1_img_1.jpg']
{'src': '', 'data': '', 'alt': '', 'desc': '', 'score': 0, 'type': 'image', 'group_id': 0, 'format': 'jpeg', 'width': 40}
OS
Linux
Python version
3.12
Browser
N/A (PDF scraping strategy called directly)
Browser version
N/A
Error logs & Screenshots (if applicable)
No error; success is True.
- Ngôn ngữ chính
- Python
- Star
- 86.8k
- Fork
- 9k
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 26
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của unclecode/crawl4ai
-
[Bug]: Hardened docker-compose (read_only) keeps full Chromium from starting: crashpad needs a writable ~/.configCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[Feature]: Crawl4aiDockerClient has no public option for the API token the 0.9 server requiresĐang mở⚙ Done ✨ Enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 2 ngày
-
⚙ Done 🐞 Bug 📌 Root caused
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
🐞 Bug 🩺 Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
unclecode/crawl4ai#2416 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
⚙ Done 🐞 Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
unclecode/crawl4ai#2382 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của unclecode/crawl4ai
Issue tương tự
-
flow-measurement measurement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
MichaelYcJo/SpecSeal#1366 ·
-
bug c/evals c/ui size:L
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Arize-ai/phoenix#17633 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
TransformerLensOrg/TransformerLens#1980 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Module: Solr Needs: Lead Needs: Triage Theme: Search Type: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
internetarchive/openlibrary#14284 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 69/100
SpaceCowMedia/commander-spellbook-backend#1292 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày