SuperAPI AI Directory

super-ppt

Coding & development

View repository

Updated 10-15 22:15

About this skill

Super PPT - Python PPT Editor

A PPT editing tool based on python-pptx, supporting style presets, style extraction, and natural language animations.

Core Features

  1. Edit Existing PPT - Open, modify specified pages, save
  2. Style Preset System - e.g. promotion(promotion defense style), newly added/modified pages automatically stay consistent
  3. Style Extraction - Extract color schemes and fonts from PPT/PDF, save as user-defined themes
  4. Animation Support - Add animations through natural language descriptions, supporting galaxy rotation effects

Quick Start

Install Dependencies

pip install python-pptx lxml Pillow
# PDF 支持需要 poppler
brew install poppler  # macOS

🎨 Style Extraction (New Feature)

Extract style from existing PPT or PDF and save it as a reusable theme.

Extract Style

import sys
sys.path.insert(0, '<skill_directory>/scripts')
from style_extractor import extract_style, list_styles

# 从 PPT 提取样式
style = extract_style("参考文档.pptx", name="my-company")

# 从 PDF 提取样式
style = extract_style("晋升答辩.pdf", name="promotion-v2")

# 查看已保存的样式
print(list_styles())  # ['my-company', 'promotion-v2']

Command-Line Extraction

# 从 PPT 提取
python scripts/style_extractor.py reference.pptx --name company-style

# 从 PDF 提取
python scripts/style_extractor.py document.pdf --name doc-style

# 列出所有样式
python scripts/style_extractor.py --list

# 删除样式
python scripts/style_extractor.py --delete old-style

Use the Extracted Style

from ppt_editor import open_ppt, create_ppt

# 使用用户自定义主题(从 ~/.ppt-styles/ 加载)
editor = open_ppt("my.pptx", theme="my-company")

# 或创建新 PPT 使用自定义主题
editor = create_ppt(theme="promotion-v2")

# 后续所有元素自动使用该主题的配色
editor.add_title(1, "标题")  # 使用提取的主色
editor.add_card(1, ...)       # 使用提取的卡片背景色

User Style Directory

~/.ppt-styles/
├── my-company.json      # 从 PPT 提取的样式
├── promotion-v2.json    # 从 PDF 提取的样式
└── my-corp.json         # 自定义企业样式

Style Configuration Format

{
  "name": "my-company",
  "description": "从 参考文档.pptx 提取的样式",
  "colors": {
    "primary": "fc5a1f",      // 主色(标题、强调)
    "secondary": "3669cd",    // 次色(链接、图标)
    "text_dark": "434343",    // 深色文字
    "text_normal": "707070",  // 正文文字
    "text_light": "a4a4a3",   // 辅助文字
    "background": "ffffff",   // 背景色
    "card_bg": "f8f8f8",      // 卡片背景
    "accent_light": "fca787", // 浅色强调
    "success": "51cf66"       // 成功色
  },
  "fonts": {
    "title": "Microsoft YaHei",
    "body": "Microsoft YaHei",
    "title_size": 28,
    "body_size": 14
  },
  "style_prompt": "## 视觉风格指南\n..."  // AI 风格提示词
}

🤖 Style Prompt (AI-Assisted Design)

When extracting a style, a descriptive style promptis automatically generated to guide the AI in understanding and applying that visual style:

# 获取当前主题的风格 prompt
editor = create_ppt(theme="my-company")
prompt = editor.get_style_prompt()

# 打印风格 prompt
editor.print_style_prompt()

# 输出示例:
# ## 视觉风格指南
# ### 整体风格
# 这是一个暖色调、积极活力的演示文稿风格...
# ### 配色方案
# - **主色调**: #fc5a1f(橙色)- 用于标题、强调...
# ### 设计原则
# 1. 简洁留白...

Purpose:

  • Use this prompt as context when using AI to assist in creating PPTs
  • Ensure that AI-generated content stays consistent with the visual style
  • Serve as a design specification document for team reference

Add a Galaxy Rotation Animation (One-Click Command)

# 为 PPT 第一页的所有圆形添加银河系旋转效果
python scripts/animation_engine.py galaxy your_slide.pptx 1 output.pptx

Use in Python

import sys
sys.path.insert(0, '<skill_directory>/scripts')
from animation_engine import AnimationEngine, add_galaxy_rotation
from pptx import Presentation

# 方式 1: 一键添加银河系效果
add_galaxy_rotation("cover.pptx", slide_number=1, output_path="cover_animated.pptx")

# 方式 2: 精细控制每个形状的动画
prs = Presentation("cover.pptx")
engine = AnimationEngine(prs)

# 为特定形状添加旋转动画
engine.add_spin(slide_number=1, shape_index=5, duration=10.0, repeat="indefinite", clockwise=True)
engine.add_spin(slide_number=1, shape_index=6, duration=6.0, repeat="indefinite", clockwise=False)

# 保存
prs.save("output.pptx")

Open and Edit an Existing PPT

import sys
sys.path.insert(0, '<skill_directory>/scripts')
from ppt_editor import open_ppt, create_ppt

# 打开现有 PPT(自动应用 promotion 风格)
editor = open_ppt("path/to/your.pptx", theme="promotion")

# 查看所有页面
editor.print_slides()

# 获取指定页面
slide = editor.get_slide(3)  # 第 3 页

# 清空并重建某一页
editor.clear_slide(3)
editor.set_background(3)
editor.add_header_bar(3, "新标题")
editor.add_text(3, "这是正文内容", x=0.5, y=1.5)

# 保存
editor.save("output.pptx")

Add Animations

from animation_engine import AnimationEngine, animate

# 方式 1: 自然语言描述
engine = AnimationEngine(editor)
engine.add_from_description("标题从左侧飞入", slide_number=1)
engine.add_from_description("内容依次淡入", slide_number=1)

# 方式 2: 直接 API
engine.add_entrance("fade", slide_number=1, shape_index=0, duration=0.5)
engine.add_slide_transition(1, "push")

Available Themes

Built-in Themes

Theme Description Primary Color
promotion Promotion defense style Orange #fc5a1f
tech Tech sharing style Purple #4a00e0

User-Defined Themes

Themes extracted via style_extractor.py are saved in the ~/.ppt-styles/ directory and can be used directly by name:

# 使用用户主题
editor = open_ppt("my.pptx", theme="my-corp")  # 从 ~/.ppt-styles/my-corp.json 加载

Core API

SuperPPTEditor

editor = open_ppt(path, theme="promotion")  # 打开 PPT
editor = create_ppt(theme="promotion")       # 创建新 PPT

# 页面操作
editor.get_slide(n)      # 获取第 n 页
editor.add_slide()       # 添加新页
editor.clear_slide(n)    # 清空第 n 页
editor.print_slides()    # 打印所有页面概览

# 添加元素(自动应用主题样式)
editor.add_header_bar(n, "标题")
editor.add_title(n, "标题", "副标题")
editor.add_text(n, "内容", x, y, width, height)
editor.add_card(n, x, y, w, h, title, content, card_type)
editor.add_feature_grid(n, features, columns=3)

# 保存
editor.save("output.pptx")

AnimationEngine

engine = AnimationEngine(editor)

# 进入动画
engine.add_entrance("fade", slide_number, shape_index, duration)
# 类型: fade, fly_in, fly_in_left, zoom, bounce, float_up, wipe, split

# 强调动画
engine.add_emphasis("pulse", slide_number, shape_index)
# 类型: pulse, flash, spin, grow

# 旋转动画(银河系效果专用)
engine.add_spin(slide_number, shape_index, duration=10.0, repeat="indefinite", clockwise=True)
# repeat: "1", "2", "indefinite"

# 银河系效果(自动为所有圆形添加旋转)
engine.add_galaxy_effect(slide_number)

# 退出动画
engine.add_exit("fade_out", slide_number, shape_index)
# 类型: fade_out, fly_out, zoom_out

# 页面切换
engine.add_slide_transition(slide_number, "push")
# 类型: fade, push, wipe, split, cube, flip, gallery

# 自然语言
engine.add_from_description("标题淡入", slide_number)
engine.add_from_description("圆形一直旋转", slide_number)

Card Types

add_card() supports the following types:

Type Effect Use Case
normal Gray background General content
highlight Orange emphasis Important content
problem Red marker Problems/pain points
solution Green marker Solutions

Example: Complete Workflow

# 1. 打开现有晋升 PPT
editor = open_ppt("晋升答辩.pptx", theme="promotion")
editor.print_slides()

# 2. 修改第 5 页 - 技术架构
editor.clear_slide(5)
editor.set_background(5)
editor.add_header_bar(5, "技术架构演进")

# 添加对比卡片
editor.add_card(5, x=0.5, y=1.2, width=4.5, height=2,
                title="🚫 旧架构", content="描述旧架构的问题...",
                card_type="problem")

editor.add_card(5, x=5.3, y=1.2, width=4.5, height=2,
                title="✅ 新架构", content="描述新架构的优势...",
                card_type="solution")

# 3. 添加动画
from animation_engine import AnimationEngine
engine = AnimationEngine(editor)
engine.add_from_description("卡片依次从底部弹出", slide_number=5)
engine.add_slide_transition(5, "push")

# 4. 保存
editor.save("晋升答辩-修改版.pptx")

Reference Documentation

  • Color Scheme: references/color-palette.md
  • Animation Commands: references/animation-commands.md

Common Tasks

Modify Specified Pages While Keeping the Style Consistent

editor = open_ppt("existing.pptx", theme="promotion")
# 主题已加载,后续所有 add_* 方法自动使用 promotion 配色
editor.add_title(3, "新标题")  # 自动使用橙色 #fc5a1f
editor.add_text(3, "内容")     # 自动使用灰色 #707070

Batch Add Animations

engine = AnimationEngine(editor)
for i in range(1, editor.get_slide_count() + 1):
    engine.add_slide_transition(i, "fade")
    engine.add_from_description("所有元素依次淡入", slide_number=i)

Create New Pages

n = editor.add_slide()
editor.add_header_bar(n, "新增内容")
editor.add_feature_grid(n, [
    {"icon": "🎯", "text": "目标明确"},
    {"icon": "📈", "text": "数据驱动"},
    {"icon": "🔧", "text": "工具支持"},
])