[Bug]: PDF images saved with save_images_locally=True come back with an empty src in result.media
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 PDF 处理器中的 PDFContentScrapingStrategy.scrap() 开始,检查已保存的图像字典如何传入 ScrapingResult(media={"images": [...]});然后查看 MediaItem schema,了解它保留了哪些字段。使用 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.4k
- 派生
- 9k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 21
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
unclecode/crawl4ai 的其他 Issue
-
[Feature]: Crawl4aiDockerClient has no public option for the API token the 0.9 server requires可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭⚙️ In-progress ✨ Enhancement
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
Bug]: Crawl4aiDockerClient gets 400 with any BrowserConfig: dump() always sends the generated `headers`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭⚙️ In-progress 🐞 Bug 📌 Root caused
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
🐞 Bug 🩺 Needs Triage
难度 2/5 1-3 小时 新手友好度 85/100
unclecode/crawl4ai#2416 · 1 条评论 ·
维护者通常 1 天内回复
-
🐞 Bug 🩺 Needs Triage
难度 2/5 1-3 小时 新手友好度 72/100
unclecode/crawl4ai#2382 · 2 条评论 ·
维护者通常 1 天内回复
-
🐞 Bug 🩺 Needs Triage
难度 2/5 1-3 小时 新手友好度 74/100
unclecode/crawl4ai#2381 · 2 条评论 ·
维护者通常 1 天内回复
查看 unclecode/crawl4ai 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 78/100
elviskahoro/sdk-python-attio#144 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
RenyiELBO raises TypeError when model has no sample sites可能已有人在做 @alibb007 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复