PPT 主题颜色解释(Theme Color Scheme)

每个 PPTX 文件包含一个主题文件:

复制代码

ppt/theme/theme1.xml

其中定义了 12 种主题颜色:

名称 含义
bg1 Background 1
tx1 Text 1
bg2 Background 2
tx2 Text 2
accent1 强调色 1
accent2 强调色 2
accent3 强调色 3
accent4 强调色 4
accent5 强调色 5
accent6 强调色 6
hlink 超链接颜色
folHlink 访问过的超链接

accent6 就是 PPT 主题的第六个强调色。

不同模板 RGB 会不同。


🔍 如何获取 accent6 的 RGB 颜色?

Python-pptx 不支持直接取 theme 色的 RGB,需要解析 XML:

代码:读取主题颜色(精准版)

复制代码
复制代码
from pptx import Presentation
from lxml import etree

def get_theme_colors(ppt_path):
    prs = Presentation(ppt_path)
    theme_part = prs.part.theme.part
    xml = etree.fromstring(theme_part.blob)

    ns = {"a": "http://schemas.openxmlformats.org/drawingml/2006/main"}

    colors = {}
    scheme_clrs = xml.xpath("//a:themeElements/a:clrScheme/*", namespaces=ns)

    for clr in scheme_clrs:
        name = clr.tag.split("}")[-1]  # accent1, accent2...
        rgb = None

        srgbClr = clr.find("a:srgbClr", ns)
        if srgbClr is not None:
            rgb = srgbClr.get("val")

        colors[name] = rgb

    return colors

print(get_theme_colors("你的PPT路径.pptx"))

返回示例:

复制代码
复制代码
{
  'accent1': '4472C4',
  'accent6': '70AD47',
  'bg1': 'FFFFFF',
  ...
}
相关推荐
reasonsummer2 小时前
【办公类-133-02】20260319_学区化展示PPT_02_python(图片合并文件夹、提取同名图片归类文件夹、图片编号、图片GIF)
前端·数据库·powerpoint
reasonsummer2 天前
【办公类-133-01】20260319_学区化展示PPT_01_“豆包大纲文字”+“天工AI”制作基础模版
powerpoint
科技圈快讯2 天前
文多多AIPPT:部分开源+私有化部署重构PPT创作体验
重构·开源·powerpoint
zzh940772 天前
2026年AI文件上传功能实战:聚合站处理图片、PDF、PPT全指南
人工智能·pdf·powerpoint
百事牛科技3 天前
更新你的保护:如何修改PPT“打开密码”
windows·powerpoint
张书名3 天前
【资源分享】北京理工大学简历模板 PPT版
powerpoint
伟贤AI之路4 天前
原创分享:用Markdown优雅地制作报告和PPT演示
powerpoint·markdown
楚歌歌5 天前
用自己的声音实现PPT转视频加AI配音,小米坡PPT转视频工具v2.25操作教程
powerpoint
小真zzz6 天前
导入生成PPT评测:全链路AI闭环工具
人工智能·ai·aigc·powerpoint·chatppt
tinygone7 天前
使用OpenClaw读取和生成PPT
经验分享·powerpoint