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',
  ...
}
相关推荐
轻竹办公PPT4 小时前
AI一键生成年终总结PPT
人工智能·python·powerpoint
MasonYyp1 天前
安装开源PPT项目
开源·powerpoint
caiyueloveclamp3 天前
【功能介绍03】ChatPPT好不好用?如何用?用户操作手册来啦!——【AI溯源篇】
人工智能·信息可视化·powerpoint·ai生成ppt·aippt
caiyueloveclamp3 天前
【功能介绍05】ChatPPT好不好用?如何用?用户操作手册来啦!——【AI辅写+分享篇】
人工智能·powerpoint·ai生成ppt·aippt·免费aippt
AI工具学习测评4 天前
实测五款AI生成PPT工具,这款国产软件让我工作效率翻倍!
人工智能·powerpoint
William.csj5 天前
PPT——图像模糊的解决办法
powerpoint
paperxie_xiexuo5 天前
面向多场景演示需求的AI辅助生成工具体系研究:十类平台的功能分型、技术实现与合规应用分析
大数据·人工智能·powerpoint·ppt
caiyueloveclamp7 天前
ChatPPT:AI PPT生成领域的“六边形战士“
人工智能·powerpoint·ai生成ppt·aippt·免费aippt
paperxie_xiexuo7 天前
学术与职场演示文稿的结构化生成机制探析:基于 PaperXie AI PPT 功能的流程解构与适用性研究
大数据·数据库·人工智能·powerpoint