DOC-104 实现图片 metadata 读取 #9

Closed
opened 2026-05-30 19:49:01 +08:00 by wangdl · 2 comments
Owner

读取图片 width/height/format/file_size。

使用 image crate,features: png, jpeg, webp, gif。

非目标:不做 OCR、不做图片文字选择、不做复杂滤镜。

验收标准:能读取 png/jpg/webp/gif 尺寸、错误文件返回明确错误、有单元测试

读取图片 width/height/format/file_size。 使用 image crate,features: png, jpeg, webp, gif。 非目标:不做 OCR、不做图片文字选择、不做复杂滤镜。 验收标准:能读取 png/jpg/webp/gif 尺寸、错误文件返回明确错误、有单元测试
wangdl added this to the M1:Document Core v0.1 milestone 2026-05-30 19:49:01 +08:00
wangdl added the
priority:p0
type:implementation
area:image
labels 2026-05-30 19:49:01 +08:00
Author
Owner

完成项

read_image_meta(file_path) 已实现
ImageMeta {width, height, format, file_size}
支持 PNG/JPEG/WebP/GIF
错误文件返回 DocumentError::ParseError

依赖

  • image = 0.25 (features: png, jpeg, webp, gif)

测试

  • 3 个单元测试,29 个总计
  • 包含真实 1x1 PNG fixture 测试
  • serde 序列化往返测试

待跟进

DOC-105 ReadingPosition 模型

## 完成项 ✅ read_image_meta(file_path) 已实现 ✅ ImageMeta {width, height, format, file_size} ✅ 支持 PNG/JPEG/WebP/GIF ✅ 错误文件返回 DocumentError::ParseError ## 依赖 - image = 0.25 (features: png, jpeg, webp, gif) ## 测试 - 3 个单元测试,29 个总计 - 包含真实 1x1 PNG fixture 测试 - serde 序列化往返测试 ## 待跟进 ⬜ DOC-105 ReadingPosition 模型
Author
Owner

审查修复 (2026-06-02)

image_meta::read_image_meta 之前用文件扩展名作为 format 字段,现已修复为使用 image::ImageReader::format() 获取实际解码格式:

  • 优先使用真实解码格式(Png/Jpeg/Gif/WebP/Bmp/Tiff/Ico)
  • 如果无法识别格式,fallback 到扩展名
  • 避免 .jpg 文件实际是 PNG 时 format 字段错误

测试 test_read_fixture_png 继续通过。

## 审查修复 (2026-06-02) `image_meta::read_image_meta` 之前用文件扩展名作为 format 字段,现已修复为使用 `image::ImageReader::format()` 获取实际解码格式: - 优先使用真实解码格式(Png/Jpeg/Gif/WebP/Bmp/Tiff/Ico) - 如果无法识别格式,fallback 到扩展名 - 避免 .jpg 文件实际是 PNG 时 format 字段错误 测试 `test_read_fixture_png` 继续通过。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/zhixi-document-runtime#9
No description provided.