[Bug]: PDF images saved with save_images_locally=True come back with an empty src in result.media
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
PDFプロセッサで PDFContentScrapingStrategy.scrap() を確認し、保存された画像辞書がどのように ScrapingResult(media={"images": [...]}) に渡されるかを調べます。次に MediaItem スキーマを確認し、どのフィールドが保持されるかを確認します。Issue の Pillow PDF の例で再現します。保存された各画像について、result.media.images から image_save_dir 配下のファイルを特定できる方法があり、インライン画像の動作も維持されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 86.8k
- フォーク
- 9k
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 21
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
unclecode/crawl4ai のほかの issue
-
⚙ Done ✨ Enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
⚙ Done 🐞 Bug 📌 Root caused
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
🐞 Bug 🩺 Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
unclecode/crawl4ai#2416 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
⚙ Done 🐞 Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
unclecode/crawl4ai#2382 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
⚙ Done 🐞 Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
unclecode/crawl4ai#2381 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
unclecode/crawl4ai の issue をすべて見る
似ている issue
-
New Internshipオープンnew_internship
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
get_graph warns that the oneway column is missing when no way has a oneway tag対応中かも @HTenkanen が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cython/cython#8110 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
fix: security 🔐 style: article/section 📝 system: data-mgmt 🗃️ system: security 🔐 system: software 💻
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
uabrc/uabrc.github.io#1267 ·
-
Link Checker ReportオープンBot Type: Bug Type: Documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信