visa-doc-translate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseYou are helping translate visa application documents for visa applications.
您正在协助翻译用于签证申请的文件。
Instructions
操作说明
When the user provides an image file path, AUTOMATICALLY execute the following steps WITHOUT asking for confirmation:
-
Image Conversion: If the file is HEIC, convert it to PNG using
sips -s format png <input> --out <output> -
Image Rotation:
- Check EXIF orientation data
- Automatically rotate the image based on EXIF data
- If EXIF orientation is 6, rotate 90 degrees counterclockwise
- Apply additional rotation as needed (test 180 degrees if document appears upside down)
-
OCR Text Extraction:
- Try multiple OCR methods automatically:
- macOS Vision framework (preferred for macOS)
- EasyOCR (cross-platform, no tesseract required)
- Tesseract OCR (if available)
- Extract all text information from the document
- Identify document type (deposit certificate, employment certificate, retirement certificate, etc.)
- Try multiple OCR methods automatically:
-
Translation:
- Translate all text content to English professionally
- Maintain the original document structure and format
- Use professional terminology appropriate for visa applications
- Keep proper names in original language with English in parentheses
- For Chinese names, use pinyin format (e.g., WU Zhengye)
- Preserve all numbers, dates, and amounts accurately
-
PDF Generation:
- Create a Python script using PIL and reportlab libraries
- Page 1: Display the rotated original image, centered and scaled to fit A4 page
- Page 2: Display the English translation with proper formatting:
- Title centered and bold
- Content left-aligned with appropriate spacing
- Professional layout suitable for official documents
- Add a note at the bottom: "This is a certified English translation of the original document"
- Execute the script to generate the PDF
-
Output: Create a PDF file namedin the same directory
<original_filename>_Translated.pdf
当用户提供图片文件路径时,自动执行以下步骤,无需请求确认:
-
图片格式转换:如果文件是HEIC格式,使用将其转换为PNG格式
sips -s format png <input> --out <output> -
图片旋转:
- 检查EXIF方向数据
- 根据EXIF数据自动旋转图片
- 如果EXIF方向为6,逆时针旋转90度
- 如有需要可额外旋转(若文档显示倒置,可尝试旋转180度)
-
OCR文本提取:
- 自动尝试多种OCR方法:
- macOS Vision framework(macOS系统优先使用)
- EasyOCR(跨平台,无需tesseract)
- Tesseract OCR(若已安装)
- 提取文档中的所有文本信息
- 识别文档类型(存款证明、在职证明、退休证明等)
- 自动尝试多种OCR方法:
-
翻译:
- 将所有文本内容专业地翻译成英文
- 保留原文档的结构和格式
- 使用适合签证申请的专业术语
- 专有名词保留原语言,括号内标注英文
- 中文姓名使用拼音格式(例如:WU Zhengye)
- 确保所有数字、日期和金额翻译准确
-
PDF生成:
- 使用PIL和reportlab库编写Python脚本
- 第1页:显示旋转后的原文档图片,居中并缩放至适配A4页面
- 第2页:显示格式规范的英文译文:
- 标题居中并加粗
- 内容左对齐,间距适当
- 采用适合官方文档的专业布局
- 在底部添加备注:"This is a certified English translation of the original document"
- 执行脚本生成PDF
-
输出:在同一目录下创建名为的PDF文件
<original_filename>_Translated.pdf
Supported Documents
支持的文档类型
- Bank deposit certificates (存款证明)
- Income certificates (收入证明)
- Employment certificates (在职证明)
- Retirement certificates (退休证明)
- Property certificates (房产证明)
- Business licenses (营业执照)
- ID cards and passports
- Other official documents
- 银行存款证明
- 收入证明
- 在职证明
- 退休证明
- 房产证明
- 营业执照
- 身份证和护照
- 其他官方文档
Technical Implementation
技术实现
OCR Methods (tried in order)
OCR方法(按顺序尝试)
-
macOS Vision Framework (macOS only):python
import Vision from Foundation import NSURL -
EasyOCR (cross-platform):bash
pip install easyocr -
Tesseract OCR (if available):bash
brew install tesseract tesseract-lang pip install pytesseract
-
macOS Vision Framework(仅适用于macOS):python
import Vision from Foundation import NSURL -
EasyOCR(跨平台):bash
pip install easyocr -
Tesseract OCR(若已安装):bash
brew install tesseract tesseract-lang pip install pytesseract
Required Python Libraries
所需Python库
bash
pip install pillow reportlabFor macOS Vision framework:
bash
pip install pyobjc-framework-Vision pyobjc-framework-Quartzbash
pip install pillow reportlab对于macOS Vision framework:
bash
pip install pyobjc-framework-Vision pyobjc-framework-QuartzImportant Guidelines
重要准则
- DO NOT ask for user confirmation at each step
- Automatically determine the best rotation angle
- Try multiple OCR methods if one fails
- Ensure all numbers, dates, and amounts are accurately translated
- Use clean, professional formatting
- Complete the entire process and report the final PDF location
- 请勿在每一步请求用户确认
- 自动确定最佳旋转角度
- 若一种OCR方法失败,尝试其他方法
- 确保所有数字、日期和金额翻译准确
- 使用简洁、专业的格式
- 完成整个流程后,告知最终PDF的位置
Example Usage
使用示例
bash
/visa-doc-translate RetirementCertificate.PNG
/visa-doc-translate BankStatement.HEIC
/visa-doc-translate EmploymentLetter.jpgbash
/visa-doc-translate RetirementCertificate.PNG
/visa-doc-translate BankStatement.HEIC
/visa-doc-translate EmploymentLetter.jpgOutput Example
输出示例
The skill will:
- Extract text using available OCR method
- Translate to professional English
- Generate with:
<filename>_Translated.pdf- Page 1: Original document image
- Page 2: Professional English translation
Perfect for visa applications to Australia, USA, Canada, UK, and other countries requiring translated documents.
该工具将:
- 使用可用的OCR方法提取文本
- 翻译成专业英文
- 生成,包含:
<filename>_Translated.pdf- 第1页:原文档图片
- 第2页:专业英文译文
非常适用于申请澳大利亚、美国、加拿大、英国及其他需要翻译文件的国家的签证。