Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

fix: improve EXIF handling and save PDF logic in pdf_image_tools.py

myhlolibfb304ef1fd5
diff --git a/mineru/utils/pdf_image_tools.py b/mineru/utils/pdf_image_tools.py
index 8ff7bdba..591798da 100644
--- a/mineru/utils/pdf_image_tools.py
+++ b/mineru/utils/pdf_image_tools.py
@@ -232,13 +232,17 @@ def images_bytes_to_pdf_bytes(image_bytes):
# 载入并转换所有图像为 RGB 模式
image = Image.open(BytesIO(image_bytes))
# 根据 EXIF 信息自动转正(处理手机拍摄的带 Orientation 标记的图片)
- ImageOps.exif_transpose(image, in_place=True)
+ image = ImageOps.exif_transpose(image) or image
# 只在必要时转换
if image.mode != "RGB":
image = image.convert("RGB")
# 第一张图保存为 PDF,其余追加
- image.save(pdf_buffer, format="PDF", save_all=True)
+ image.save(
+ pdf_buffer,
+ format="PDF",
+ # save_all=True
+ )
# 获取 PDF bytes 并重置指针(可选)
pdf_bytes = pdf_buffer.getvalue()