You are assisting with the translation of documents for visa applications.
Instructions
When the user provides an image file path,AUTOMATICALLY perform the following steps,WITHOUT requesting confirmation:
-
Image Conversion: If the file is in HEIC format, use
sips -s format png <input> --out <output>to convert it to PNG. -
Image Rotation:
- Check the EXIF orientation data.
- Automatically rotate the image based on the EXIF data.
- If the EXIF orientation is 6, rotate 90 degrees counterclockwise.
- Apply additional rotation as needed (if the document appears upside down, try rotating 180 degrees).
-
OCR Text Extraction:
- Automatically try multiple OCR methods:
- macOS Vision framework (preferred on macOS).
- EasyOCR (cross-platform, no tesseract required).
- Tesseract OCR (if available).
- Extract all text information from the document.
- Identify the document type (bank deposit certificate, employment certificate, retirement certificate, etc.).
- Automatically try multiple OCR methods:
-
Translation:
- Translate all text content into English at a professional level.
- Preserve the structure and formatting of the original document.
- Use professional terminology suitable for visa applications.
- Keep proper nouns in the original language and note the English in parentheses.
- For Chinese names, use the pinyin format (e.g., WU Zhengye).
- Accurately preserve all numbers, dates, and amounts.
-
PDF Generation:
- Create a Python script using the PIL and reportlab libraries.
- Page 1: Display the rotated original image, centered and scaled to fit an 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".
- Run the script to generate the PDF.
-
Output: Create a PDF file named
<original_filename>_Translated.pdfin the same directory.
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)
-
macOS Vision framework(macOS only):
import Vision from Foundation import NSURL -
EasyOCR(cross-platform):
pip install easyocr -
Tesseract OCR(if available):
brew install tesseract tesseract-lang pip install pytesseract
Required Python Libraries
pip install pillow reportlab
For the macOS Vision framework:
pip install pyobjc-framework-Vision pyobjc-framework-Quartz
Important Guidelines
- Do notask the user for confirmation at every step.
- Automatically determine the best rotation angle.
- If one OCR method fails, try multiple methods.
- Ensure all numbers, dates, and amounts are accurately translated.
- Use clean, professional formatting.
- Complete the entire process and report the location of the final PDF.
Example Usage
/visa-doc-translate RetirementCertificate.PNG
/visa-doc-translate BankStatement.HEIC
/visa-doc-translate EmploymentLetter.jpg
Output Example
This Skill will:
- Extract text using available OCR methods.
- Translate into professional English.
- Generate a
<filename>_Translated.pdf:- Page 1: Original document image.
- Page 2: Professional English translation.
Ideal for submitting visa applications to Australia, the United States, Canada, the United Kingdom, and other countries that require translated documents.