SuperAPI AI Directory

document-image-extractor

Office & productivity

View repository

Updated 10-16 09:32

About this skill

Document Image Extractor

A skill for extracting images from Word and PDF documents.

Dependency Installation

Dependencies need to be installed before use (assumed to be already installed by the user):

conda run -n claude-code pip install python-docx pymupdf

Usage

Basic Commands

conda run -n claude-code python scripts/extract_images.py <文档路径> [-o <输出目录>]

Parameter Description

  • 文档路径: Word (.docx) or PDF (.pdf) file path
  • -o, --output: Output directory (optional, by default creates a <文件名>_images folder in the same directory as the document)
  • --dpi: PNG conversion DPI (optional, default 150, higher is clearer)
  • --keep-emf: Keep original EMF/WMF files (for Word vector graphics only)
  • --convert-svg: Convert EMF/WMF to SVG (for Word vector graphics only)

Examples

# 从 Word 文档提取图片(默认只输出 PNG)
conda run -n claude-code python scripts/extract_images.py document.docx

# 提取图片并保留 EMF 源文件
conda run -n claude-code python scripts/extract_images.py document.docx --keep-emf

# 提取图片并转换为 SVG 格式
conda run -n claude-code python scripts/extract_images.py document.docx --convert-svg

# 提取图片并同时保留 EMF 和转换为 SVG
conda run -n claude-code python scripts/extract_images.py document.docx --keep-emf --convert-svg

# 指定更高 DPI 以获得更清晰的 PNG
conda run -n claude-code python scripts/extract_images.py document.docx --dpi 300

# 从 PDF 提取图片
conda run -n claude-code python scripts/extract_images.py document.pdf

# 指定输出目录
conda run -n claude-code python scripts/extract_images.py document.docx -o ./my_images

Output Format

  • Image naming:image_001.png, image_002.jpg, ...
  • PDF images will be labeled with their source page:image_001.png (page 1)

Supported Image Formats

Word Documents

  • PNG, JPEG, JPG, GIF, BMP, TIFF, WebP, SVG
  • EMF/WMF vector graphics (can be converted to PNG/SVG)

PDF Documents

  • PNG, JPEG, JPG, GIF, BMP, TIFF
  • Note: PDF vector graphics cannot be extracted separately (PDF stores them as drawing instructions, not as independent objects)

Notes

  • Word documents: extract embedded images, media files, and SVG
  • PDF documents: only extract embedded bitmap images
  • If there are no images in the document, it will prompt "No images found"