feat: 添加图片适配模式支持
- 支持四种图片适配模式:stretch、contain、cover、center - 支持背景色填充功能(contain 和 center 模式) - 支持文档级 DPI 配置(metadata.dpi) - PPTX 渲染器集成 Pillow 实现高质量图片处理 - HTML 渲染器使用 CSS object-fit 实现相同效果 - 添加完整的单元测试、集成测试和端到端测试 - 更新 README 文档和架构文档 - 模块化设计:utils/image_utils.py 图片处理工具模块 - 添加图片配置验证器:validators/image_config.py - 向后兼容:未指定 fit 时默认使用 stretch 模式
This commit is contained in:
@@ -89,6 +89,19 @@ class TestImageElement:
|
||||
assert elem.type == 'image'
|
||||
assert elem.src == "test.png"
|
||||
assert elem.box == [1, 1, 4, 3]
|
||||
assert elem.fit is None
|
||||
assert elem.background is None
|
||||
|
||||
def test_create_with_fit_and_background(self):
|
||||
"""测试创建带 fit 和 background 的 ImageElement"""
|
||||
elem = ImageElement(
|
||||
src="test.png",
|
||||
box=[1, 1, 4, 3],
|
||||
fit="contain",
|
||||
background="#ffffff"
|
||||
)
|
||||
assert elem.fit == "contain"
|
||||
assert elem.background == "#ffffff"
|
||||
|
||||
def test_empty_src_raises_error(self):
|
||||
"""测试空 src 会引发错误"""
|
||||
|
||||
Reference in New Issue
Block a user