1
0

feat: 移除图片适配模式功能

移除图片 fit 和 background 参数支持,简化图片渲染逻辑。系统恢复到直接使用 python-pptx 原生图片添加功能,图片将被拉伸到指定尺寸。

变更内容:
- 移除 ImageElement 的 fit 和 background 字段
- 移除 metadata.dpi 配置
- 删除 utils/image_utils.py 图片处理工具模块
- 删除 validators/image_config.py 验证器
- 简化 PPTX 和 HTML 渲染器的图片处理逻辑
- HTML 渲染器使用硬编码 DPI=96(Web 标准)
- 删除相关测试文件(单元测试、集成测试、e2e 测试)
- 更新规格文档和用户文档
- 保留 Pillow 依赖用于未来可能的图片处理需求

影响:
- 删除 11 个文件
- 修改 10 个文件
- 净减少 1558 行代码
- 所有 402 个测试通过

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 14:23:12 +08:00
parent 2fd8bc1b4a
commit f34405be36
31 changed files with 494 additions and 1556 deletions

View File

@@ -1,35 +0,0 @@
metadata:
title: "背景色测试"
size: "16:9"
dpi: 96
slides:
- elements:
- type: text
content: "背景色支持测试"
box: [1, 0.5, 8, 0.8]
font:
size: 28
bold: true
align: center
# 白色背景
- type: image
src: "../fixtures/images/test_image.png"
box: [1, 1.5, 2.5, 2]
fit: contain
background: "#ffffff"
# 灰色背景
- type: image
src: "../fixtures/images/test_image.png"
box: [4, 1.5, 2.5, 2]
fit: contain
background: "#cccccc"
# 彩色背景
- type: image
src: "../fixtures/images/test_image.png"
box: [7, 1.5, 2.5, 2]
fit: center
background: "#e3f2fd"

View File

@@ -1,20 +0,0 @@
metadata:
title: "DPI 配置测试"
size: "16:9"
dpi: 150
slides:
- elements:
- type: text
content: "DPI: 150"
box: [1, 0.5, 8, 0.8]
font:
size: 28
bold: true
align: center
- type: image
src: "../fixtures/images/test_image.png"
box: [2, 1.5, 6, 3]
fit: contain
background: "#f5f5f5"

View File

@@ -1,40 +0,0 @@
metadata:
title: "图片适配模式端到端测试"
size: "16:9"
dpi: 96
slides:
# 测试所有 fit 模式
- elements:
- type: text
content: "图片适配模式测试"
box: [1, 0.5, 8, 0.8]
font:
size: 32
bold: true
align: center
# stretch 模式(默认)
- type: image
src: "../fixtures/images/test_image.png"
box: [0.5, 1.5, 2, 1.5]
# contain 模式
- type: image
src: "../fixtures/images/test_image.png"
box: [3, 1.5, 2, 1.5]
fit: contain
background: "#f0f0f0"
# cover 模式
- type: image
src: "../fixtures/images/test_image.png"
box: [5.5, 1.5, 2, 1.5]
fit: cover
# center 模式
- type: image
src: "../fixtures/images/test_image.png"
box: [8, 1.5, 2, 1.5]
fit: center
background: "#ffffff"

View File

@@ -1,19 +0,0 @@
metadata:
title: "无效参数测试"
size: "16:9"
dpi: 96
slides:
- elements:
# 无效的 fit 值
- type: image
src: "../fixtures/images/test_image.png"
box: [1, 1, 3, 2]
fit: invalid_mode
# 无效的背景色
- type: image
src: "../fixtures/images/test_image.png"
box: [5, 1, 3, 2]
fit: contain
background: "not-a-color"