EPS 转 SVG/PNG 转换器集合
一套全面的 Python 脚本集合,用于将 EPS(封装 PostScript)文件转换为 SVG 或高质量 PNG 格式,提供多种转换策略和诊断工具。excniesNIED/EPS_Converter_Toolkit - Githubhttps://github.com/excniesNIED/EPS_Converter_Toolkit
📋 脚本概览
脚本 | 用途 |
---|---|
eps_to_high_quality_png.py | 将 EPS 转换为超高质量 PNG |
eps_to_svg_diagnostic.py | 带详细错误报告的诊断工具 |
eps_to_svg_robust.py | 多方法 SVG 转换,带备用方案 |
eps_to_svg_ghostscript.py | 基于 Ghostscript 的直接 SVG 转换 |
🚀 快速开始
系统要求
-
Python 3.6+ | Python 3.6 或更高版本
-
Ghostscript (所有脚本必需)
-
Additional tools (可选,详见各脚本要求)
安装
-
安装 Ghostscript
# Windows (使用 Chocolatey) choco install ghostscript # Windows (使用 winget) winget install GNU.Ghostscript # 或从官网下载:https://www.ghostscript.com/download/gsdnld.html
-
克隆此仓库
git clone https://github.com/excniesNIED/EPS_Converter_Toolkit.git cd EPS_Converter_Toolkit
-
安装可选依赖
pip install Pillow # PIL 支持
📖 详细脚本文档
1. eps_to_high_quality_png.py
| 高质量 PNG 转换器
用途: 将 EPS 文件转换为可自定义 DPI 设置的超高质量 PNG 图像。
功能:
-
多种质量预设(300-900 DPI)
-
24位真彩色输出
-
抗锯齿支持
-
自动文件大小估算
使用方法:
python eps_to_high_quality_png.py
环境要求:
-
Ghostscript (必需)
-
Python 3.6+ (必需)
质量选项:
-
标准(300 DPI): 适合打印
-
高质量(450 DPI): 3倍缩放,推荐
-
超高质量(600 DPI): 4倍缩放
-
极高质量(900 DPI): 6倍缩放,文件较大
2. eps_to_svg_diagnostic.py
| 诊断工具
用途: 全面的诊断工具,用于排查 EPS 转换问题,提供详细的错误报告。
功能:
-
文件格式验证
-
多种转换方法测试
-
详细错误信息
-
单文件测试模式
使用方法:
python eps_to_svg_diagnostic.py
操作模式:
-
单文件诊断: 测试单个文件,提供详细分析
-
批量转换: 转换所有文件并输出诊断信息
-
样本测试: 测试前 5 个文件以进行快速评估
环境要求:
-
Ghostscript (必需)
-
Python 3.6+ (必需)
3. eps_to_svg_robust.py
| 强健 SVG 转换器
用途: 多方法 SVG 转换器,具有自动备用策略,实现最大兼容性。
功能:
-
多种转换引擎
-
自动工具检测
-
备用策略
-
支持多种输出格式
转换方法:
-
Inkscape 直接转换: 原生 SVG 转换
-
Ghostscript + Inkscape: 两步处理
-
Ghostscript 直接转换: 直接 SVG 输出
-
PIL + Inkscape: 备用方法
使用方法:
python eps_to_svg_robust.py
环境要求:
-
Ghostscript (必需)
-
Inkscape (推荐) | 下载地址: Inkscape - Draw Freely. | Inkscape
-
PIL/Pillow (可选) |
pip install Pillow
4. eps_to_svg_ghostscript.py
| Ghostscript SVG 转换器
用途: 使用 Ghostscript 直接转换 SVG,采用优化参数以获得最佳质量输出。
功能:
-
纯 Ghostscript 实现
-
优化的 SVG 参数
-
自动 EPS 边界检测
-
可缩放输出(默认3倍)
使用方法:
python eps_to_svg_ghostscript.py
环境要求:
-
Ghostscript (必需)
-
Python 3.6+ (必需)
输出设置:
-
格式:SVG
-
缩放:3倍(216 DPI)
-
边界:自动裁剪
🔧安装指南
Windows
-
安装 Ghostscript:
-
从官网下载: Ghostscript : Releases
-
64位 Windows 选择64位版本
-
使用默认设置安装
-
-
安装 Inkscape(可选):
-
下载地址: Download Inkscape 1.4.2 | Inkscape
-
eps_to_svg_robust.py
需要
-
-
安装 Python 包:
pip install Pillow # 可选,用于增强兼容性
macOS
# 安装 Ghostscript brew install ghostscript # 安装 Inkscape (可选) brew install inkscape # 安装 Python 包 pip install Pillow
Linux (Ubuntu/Debian)
# 安装 Ghostscript sudo apt update sudo apt install ghostscript # 安装 Inkscape (可选) sudo apt install inkscape # 安装 Python 包 pip install Pillow
📊 对比矩阵
Feature | PNG Converter | Diagnostic | Robust SVG | Ghostscript SVG |
---|---|---|---|---|
输出格式 | 仅 PNG | 多种 | 主要 SVG | 仅 SVG |
质量选项 | 4档 | 不适用 | 固定3倍 | 固定3倍 |
错误报告 | 基础 | 详细 | 中等 | 基础 |
工具依赖 | 仅 GS | 仅 GS | GS + INK | 仅 GS |
最适合 | 高质量图像 | 问题排查 | 兼容性 | 简单 SVG |
GS = Ghostscript, INK = Inkscape
🚨 故障排除
常见问题
-
"未找到 Ghostscript"
-
确保 Ghostscript 正确安装
-
检查是否在系统 PATH 中
-
尝试使用默认设置重新安装
-
-
"未找到 EPS 文件"
-
确保在正确的目录中
-
检查文件扩展名(.eps 或 .EPS)
-
-
"转换失败"
-
首先使用诊断脚本
-
检查 EPS 文件是否有效
-
尝试不同的转换方法
-
-
Unicode/编码错误
-
确保文件路径不包含特殊字符
-
尝试将文件移动到简单路径
-
性能提示
-
大批量处理: 使用 PNG 转换器以提高速度
-
矢量输出: 首先尝试强健 SVG 转换器
-
调试: 始终从诊断脚本开始
📝 输出示例
成功转换
[1/25] 转换: example.eps -> example.svg✓ 成功: example.svg (45.2 KB, 3x)
转换失败
[1/25] 转换: broken.eps -> broken.svg❌ Ghostscript错误: Invalid EPS format
诊断输出
检测EPS文件: example.eps文件大小: 196740 字节 (192.1 KB)文件头: %!PS-Adobe-2.0 EPSF-2.0✓ 检测到PostScript文件头✓ Ghostscript可以解析此文件