Skip to content

Pinvou/pinvou-agent / pinvou3-app/src-tauri/resources/common/skill-marketplace/tencent-docs-skill

tencent-docs

Unverified

腾讯文档(docs.qq.com)-在线云文档平台,是创建、编辑、管理**在线**文档的首选 skill。仅当用户明确指向腾讯文档/在线文档/docs.qq.com,或任务需要在线协作文档时使用;泛指"做个文档/保存成文件/PPT"且未点名在线平台时,默认走本地工具(本地 pptx 技能等),不要误用本 skill。支持能力:(1) 创建各类在线文档(文档/Word/Excel/幻灯片/思维导图/流程图/智能表格/收集表)(2) 管理知识库空间(创建空间、查询空间列表)(3) 管理空间节点、文件夹结构 (4) 读取/搜索文档内容 (5) 编辑操作智能表 (6) 编辑操作在线文档 (7) 文件管理(重命名、移动、删除、复制、导入导出)(8) 网页剪藏、本地文件/html/文档上云。

FileKindSize
SKILL.mdskill md22.1 KB
aipage_pack.jsscript19.0 KB
doc/doc_format/README.mdmarkdown2.9 KB
doc/doc_format/prompt/pure_text_system_prompt.txtmarkdown2.3 KB
doc/doc_format/prompt/scenario_recognition_prompt.txtmarkdown1.7 KB
doc/doc_format/prompt/style_customization_prompt.txtmarkdown2.5 KB
doc/doc_format/templates/contract.jsonconfig1.0 KB
doc/doc_format/templates/essay.jsonconfig489 B
doc/doc_format/templates/general.jsonconfig2.7 KB
doc/doc_format/templates/government.jsonconfig1019 B
doc/doc_format/templates/paper.jsonconfig4.6 KB
doc/entry.mdmarkdown800 B
references/aipage_references.mdmarkdown5.0 KB
references/auth.mdmarkdown1.2 KB
references/diagram_references.mdmarkdown2.2 KB
references/docengine_references.mdmarkdown87.2 KB
references/manage_references.mdmarkdown31.9 KB
references/ocr_references.mdmarkdown3.3 KB
references/slideengine_references.mdmarkdown76.2 KB
references/smartsheet_references.mdmarkdown31.5 KB
references/space_references.mdmarkdown7.0 KB
references/unsupported_feature_reporting.mdmarkdown1.1 KB
references/workflows.mdmarkdown7.9 KB
sheet/api/mcp-api.mdmarkdown55.2 KB
sheet/entry.mdmarkdown15.5 KB
sidebar-pptx-generator/references/component-box.mdmarkdown4.0 KB
sidebar-pptx-generator/references/component-chart.mdmarkdown10.5 KB
sidebar-pptx-generator/references/component-codeblock.mdmarkdown1.6 KB
sidebar-pptx-generator/references/component-diagram.mdmarkdown2.7 KB
sidebar-pptx-generator/references/component-faicon.mdmarkdown2.9 KB
sidebar-pptx-generator/references/component-image.mdmarkdown5.5 KB
sidebar-pptx-generator/references/component-math.mdmarkdown2.1 KB
sidebar-pptx-generator/references/component-qrcode.mdmarkdown1.1 KB
sidebar-pptx-generator/references/component-slide.mdmarkdown3.9 KB
sidebar-pptx-generator/references/component-svg.mdmarkdown1.3 KB
sidebar-pptx-generator/references/component-table.mdmarkdown3.2 KB
sidebar-pptx-generator/references/component-text.mdmarkdown3.0 KB
sidebar-pptx-generator/references/design-principle.mdmarkdown4.5 KB
sidebar-pptx-generator/scripts/doc_image_extractor.pyscript12.4 KB
sidebar-pptx-generator/scripts/get_slide_info.shexecutablescript4.3 KB
slide/entry.mdmarkdown20.6 KB
smartcanvas/entry.mdmarkdown45.5 KB
smartcanvas/mdx_references.mdmarkdown22.7 KB
smartcanvas/template/12_week_muscle_building_workout_plan.mdxmarkdown16.8 KB
smartcanvas/template/2025_ai_industry_trend_analysis_report.mdxmarkdown16.1 KB
smartcanvas/template/2026_family_annual_budget_plan.mdxmarkdown12.2 KB
smartcanvas/template/2026_personal_annual_goal_plan.mdxmarkdown14.2 KB
smartcanvas/template/annual_holiday_greeting_messages.mdxmarkdown16.4 KB
smartcanvas/template/app_2_project_retrospective.mdxmarkdown6.2 KB
smartcanvas/template/british_shorthair_cat_care_guide.mdxmarkdown17.0 KB
smartcanvas/template/career_growth_books_and_movies_recommendations.mdxmarkdown17.0 KB
smartcanvas/template/chinese_modern_wedding_planning_guide.mdxmarkdown12.6 KB
smartcanvas/template/coffee_shop_location_analysis_report.mdxmarkdown21.6 KB
smartcanvas/template/community_fresh_delivery_feasibility_report.mdxmarkdown21.1 KB
smartcanvas/template/community_group_buying_annual_operation_plan.mdxmarkdown10.3 KB
smartcanvas/template/company_5th_anniversary_event_plan.mdxmarkdown8.8 KB
smartcanvas/template/ecommerce_membership_points_prd.mdxmarkdown12.2 KB
smartcanvas/template/english_self_introduction_for_interview.mdxmarkdown7.0 KB
smartcanvas/template/family_weekly_healthy_meal_plan.mdxmarkdown10.9 KB
smartcanvas/template/finance_graduate_career_plan.mdxmarkdown12.7 KB
smartcanvas/template/food_review_self_media_operation_plan.mdxmarkdown10.9 KB
smartcanvas/template/graduate_admission_recommendation_letter.mdxmarkdown3.8 KB
smartcanvas/template/internet_product_manager_cover_letter.mdxmarkdown4.0 KB
smartcanvas/template/internet_product_manager_interview_checklist.mdxmarkdown7.2 KB
smartcanvas/template/maternity_ecommerce_user_persona_report.mdxmarkdown20.8 KB
smartcanvas/template/new_tea_brand_annual_promotion_plan.mdxmarkdown20.9 KB
smartcanvas/template/office_worker_knowledge_side_business_plan.mdxmarkdown16.0 KB
smartcanvas/template/online_education_summer_marketing_plan.mdxmarkdown16.2 KB
smartcanvas/template/online_office_tool_user_research_report.mdxmarkdown16.4 KB
smartcanvas/template/p6_to_p7_promotion_report.mdxmarkdown9.0 KB
smartcanvas/template/principles_ray_dalio_book_notes.mdxmarkdown15.9 KB
smartcanvas/template/q1_quarterly_marketing_operations_summary.mdxmarkdown6.8 KB
smartcanvas/template/quanzhou_3_day_travel_guide.mdxmarkdown7.9 KB
smartcanvas/template/shared_apartment_moving_checklist.mdxmarkdown7.1 KB
smartcanvas/template/shared_powerbank_business_model_report.mdxmarkdown16.8 KB
smartcanvas/template/short_video_platform_competitive_analysis_2026.mdxmarkdown31.2 KB
smartcanvas/template/smart_home_iot_business_plan.mdxmarkdown20.3 KB
smartcanvas/template/smartwatch_comparison_apple_watch_vs_huawei_gt.mdxmarkdown12.7 KB
smartcanvas/template/space_theme_6th_birthday_party_plan.mdxmarkdown9.2 KB
smartcanvas/template/summer_internship_report_data_analyst.mdxmarkdown6.6 KB
smartcanvas/template/ui_designer_probation_summary.mdxmarkdown5.1 KB

sidebar-pptx-generator/scripts/doc_image_extractor.py

View on GitHub
#!/usr/bin/env python3
"""
doc_image_extractor.py

从多种文档格式中提取内嵌图片。
支持格式:PPTX、DOCX、XLSX

依赖安装:
    pip install python-pptx python-docx openpyxl

用法:
    # 单个文件
    python3 doc_image_extractor.py <文档路径> [输出目录]

    # 多个文件
    python3 doc_image_extractor.py file1.pptx file2.docx file3.xlsx [输出目录]

    # 批量扫描目录
    python3 doc_image_extractor.py --dir <目录路径> [输出目录]
    python3 doc_image_extractor.py -d <目录路径> [输出目录]
"""

import sys
import os
import argparse
from pathlib import Path
from typing import Optional, List, Dict

MIN_IMAGE_SIZE = 100 * 1024

# -------------------- 依赖检查 --------------------

def _require(package_name: str, install_cmd: str):
    """尝试导入包,失败时提示安装并退出。"""
    try:
        __import__(package_name)
    except ImportError:
        print(f"❌ 缺少依赖: {package_name}")
        print(f"   请运行: {install_cmd}")
        sys.exit(1)


# -------------------- PPTX 图片提取 --------------------

def extract_images_from_pptx(filepath: str, output_dir: str) -> int:
    """使用 python-pptx 从 PPTX 中提取图片。"""
    _require("pptx", "pip install python-pptx")
    from pptx import Presentation

    prs = Presentation(filepath)
    image_count = 0

    for slide_num, slide in enumerate(prs.slides, start=1):
        for shape in slide.shapes:
            if hasattr(shape, "image") and shape.image:
                try:
                    image = shape.image
                    image_bytes = image.blob
                    # 跳过过小图片
                    if len(image_bytes) < MIN_IMAGE_SIZE:
                        continue

                    # 确定扩展名(content_type 来自文档内部声明,白名单净化防路径穿越)
                    content_type = image.content_type
                    ext = content_type.split("/")[-1] if "/" in content_type else "png"
                    if ext == "jpeg":
                        ext = "jpg"
                    ext = "".join(c if c.isalnum() else "" for c in ext) or "png"

                    image_count += 1
                    image_filename = f"pptx_s{slide_num}_img{image_count}.{ext}"
                    image_path = os.path.join(output_dir, image_filename)
                    with open(image_path, "wb") as f:
                        f.write(image_bytes)
                except Exception:
                    continue

    return image_count


# -------------------- DOCX 图片提取 --------------------

def extract_images_from_docx(filepath: str, output_dir: str) -> int:
    """使用 python-docx 从 DOCX 中提取图片。"""
    _require("docx", "pip install python-docx")
    from docx import Document

    doc = Document(filepath)
    image_count = 0

    for rel in doc.part.rels.values():
        if "image" in rel.reltype:
            try:
                image = rel.target_part
                image_bytes = image.blob
                # 跳过过小图片
                if len(image_bytes) < MIN_IMAGE_SIZE:
                    continue

                # 确定扩展名(content_type 来自文档内部声明,白名单净化防路径穿越)
                content_type = image.content_type if hasattr(image, "content_type") else "image/png"
                ext = content_type.split("/")[-1] if "/" in content_type else "png"
                if ext == "jpeg":
                    ext = "jpg"
                ext = "".join(c if c.isalnum() else "" for c in ext) or "png"

                image_count += 1
                image_filename = f"docx_img{image_count}.{ext}"
                image_path = os.path.join(output_dir, image_filename)
                with open(image_path, "wb") as f:
                    f.write(image_bytes)
            except Exception:
                continue

    return image_count


# -------------------- XLSX 图片提取 --------------------

def extract_images_from_xlsx(filepath: str, output_dir: str) -> int:
    """使用 openpyxl 从 XLSX 中提取图片。"""
    _require("openpyxl", "pip install openpyxl")
    from openpyxl import load_workbook

    wb = load_workbook(filepath)
    image_count = 0

    for sheet_name in wb.sheetnames:
        sheet = wb[sheet_name]
        if hasattr(sheet, "_images"):
            for img in sheet._images:
                try:
                    image_bytes = img._data()
                    if len(image_bytes) < MIN_IMAGE_SIZE:
                        continue

                    # 确定扩展名
                    ext = img.format.lower() if img.format else "png"
                    if ext == "jpeg":
                        ext = "jpg"

                    image_count += 1
                    image_filename = f"xlsx_{sheet_name}_img{image_count}.{ext}"
                    # 清理文件名中的非法字符
                    image_filename = "".join(c if c.isalnum() or c in "._-" else "_" for c in image_filename)
                    image_path = os.path.join(output_dir, image_filename)
                    with open(image_path, "wb") as f:
                        f.write(image_bytes)
                except Exception:
                    continue

    return image_count


# -------------------- 核心数据 --------------------

SUPPORTED_FORMATS = {
    ".pptx": extract_images_from_pptx,
    ".docx": extract_images_from_docx,
    ".xlsx": extract_images_from_xlsx,
}


def scan_directory(directory: str) -> List[str]:
    """扫描目录中所有支持的文档文件(不包含子目录)。"""
    files = []
    for entry in os.listdir(directory):
        path = os.path.join(directory, entry)
        if os.path.isfile(path) and Path(path).suffix.lower() in SUPPORTED_FORMATS:
            files.append(path)
    return files


def extract_images_from_file(filepath: str, output_dir: str) -> int:
    """从单个文件中提取图片。"""
    filepath = os.path.abspath(filepath)
    if not os.path.exists(filepath):
        raise FileNotFoundError(f"文件不存在: {filepath}")

    ext = Path(filepath).suffix.lower()
    if ext not in SUPPORTED_FORMATS:
        raise ValueError(
            f"不支持的文件格式: {ext}\n"
            f"支持的格式: {', '.join(SUPPORTED_FORMATS.keys())}"
        )

    os.makedirs(output_dir, exist_ok=True)
    extractor = SUPPORTED_FORMATS[ext]
    return extractor(filepath, output_dir)


def extract_images(
    inputs: List[str],
    output_dir: str,
    flat: bool = False
) -> Dict[str, int]:
    """
    批量提取图片。

    参数:
        inputs: 文件路径或目录路径列表
        output_dir: 根输出目录
        flat: 为 True 时所有图片输出到同一目录;为 False 时按文件名分子目录

    返回:
        {文件路径: 提取图片数量}
    """
    results = {}

    # 收集所有文件
    all_files = []
    for item in inputs:
        item = os.path.abspath(item)
        if os.path.isdir(item):
            files = scan_directory(item)
            all_files.extend(files)
            if not files:
                print(f"⚠️ 目录中未找到支持的文档: {item}")
        elif os.path.isfile(item):
            all_files.append(item)
        else:
            print(f"⚠️ 路径不存在或不是文件/目录: {item}")

    if not all_files:
        print("⚠️ 没有找到可处理的文件")
        return results

    # 去重并保持顺序
    seen = set()
    unique_files = [f for f in all_files if not (f in seen or seen.add(f))]

    total_files = len(unique_files)
    print(f"📦 共发现 {total_files} 个待处理文件")
    print("=" * 50)

    # 如果输出目录不存在,提示正在创建
    output_dir = os.path.abspath(output_dir)
    if not os.path.exists(output_dir):
        print(f"📁 输出目录不存在,正在创建: {output_dir}")
    os.makedirs(output_dir, exist_ok=True)
    total_images = 0

    for idx, filepath in enumerate(unique_files, start=1):
        basename = Path(filepath).stem
        ext = Path(filepath).suffix.lower()

        if flat:
            # 所有图片放一起,文件名加前缀区分
            file_output_dir = output_dir
            prefix = f"{basename}_"
        else:
            # 每个文件一个子目录
            file_output_dir = os.path.join(output_dir, basename)
            prefix = ""

        print(f"\n[{idx}/{total_files}] 📄 {filepath}")
        print(f"     输出到: {file_output_dir}")

        try:
            # 创建临时子目录(flat 模式下不需要)
            if not flat:
                os.makedirs(file_output_dir, exist_ok=True)

            # 提取到临时目录,再重命名(flat 模式下需要加前缀)
            import tempfile
            tmp_dir = tempfile.mkdtemp()
            count = extract_images_from_file(filepath, tmp_dir)

            if flat and count > 0:
                # flat 模式:把文件移到根目录并加前缀
                for fname in os.listdir(tmp_dir):
                    src = os.path.join(tmp_dir, fname)
                    dst = os.path.join(file_output_dir, f"{prefix}{fname}")
                    # 处理重名
                    counter = 1
                    orig_dst = dst
                    while os.path.exists(dst):
                        stem = Path(orig_dst).stem
                        suffix = Path(orig_dst).suffix
                        dst = os.path.join(file_output_dir, f"{stem}_{counter}{suffix}")
                        counter += 1
                    os.rename(src, dst)
                os.rmdir(tmp_dir)
            elif count > 0:
                # 子目录模式:直接移过去
                for fname in os.listdir(tmp_dir):
                    src = os.path.join(tmp_dir, fname)
                    dst = os.path.join(file_output_dir, fname)
                    counter = 1
                    orig_dst = dst
                    while os.path.exists(dst):
                        stem = Path(orig_dst).stem
                        suffix = Path(orig_dst).suffix
                        dst = os.path.join(file_output_dir, f"{stem}_{counter}{suffix}")
                        counter += 1
                    os.rename(src, dst)
                os.rmdir(tmp_dir)
            else:
                # 没提取到图片,清理临时目录
                import shutil
                shutil.rmtree(tmp_dir, ignore_errors=True)
                if not flat:
                    # 空目录也清理
                    try:
                        os.rmdir(file_output_dir)
                    except OSError:
                        pass

            results[filepath] = count
            total_images += count
            print(f"     ✅ 提取 {count} 张图片")

        except Exception as e:
            results[filepath] = 0
            print(f"     ❌ 失败: {e}")

    # 汇总
    print("\n" + "=" * 50)
    print(f"🎉 处理完成: {total_files} 个文件, 共 {total_images} 张图片")
    print(f"📁 输出目录: {os.path.abspath(output_dir)}")
    return results


# -------------------- CLI --------------------

def build_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(
        description="从文档中提取内嵌图片",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog="""
示例:
  %(prog)s report.docx
  %(prog)s report.docx slides.pptx -o ./images
  %(prog)s --dir ./docs -o ./images
  %(prog)s --dir ./docs --flat -o ./all_images
        """,
    )
    parser.add_argument(
        "inputs",
        nargs="*",
        help="要处理的文件或目录路径(可多选)",
    )
    parser.add_argument(
        "-d", "--dir",
        action="append",
        default=[],
        help="扫描目录中的所有支持文件(可多次使用)",
    )
    parser.add_argument(
        "-o", "--output",
        default="extracted_images",
        help="输出目录(默认: extracted_images)",
    )
    parser.add_argument(
        "--flat",
        action="store_true",
        help="扁平输出:所有图片放到同一目录,不按文件分目录",
    )
    return parser


def main():
    parser = build_parser()
    args = parser.parse_args()

    # 收集所有输入
    all_inputs = list(args.inputs) if args.inputs else []
    for d in args.dir:
        all_inputs.append(d)

    if not all_inputs:
        parser.print_help()
        sys.exit(1)

    extract_images(all_inputs, args.output, flat=args.flat)


if __name__ == "__main__":
    main()
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall