---
name: visa-doc-translate
description: Translate visa document images into English and make a two-page PDF with the source image and translation.
---

# Visa Document Translation

Help the user translate an image of a visa document into English. Make a PDF that shows both the source image and the English text.

## Main Rule

When the user gives a valid image path, start the work at once. Do not ask for approval at each step.

Ask the user only if:

- The file is missing or cannot be read.
- The image is too blurry or cut off to read.
- A name, date, number, or money value cannot be read with care.
- The user must choose between two meanings that could change the document.
- The output file already exists and replacing it may remove user work.

Never guess key facts. Mark text that cannot be read as `[unclear]`. Mark text that is cut off as `[text cut off]`.

## Steps

### 1. Check the Input

- Make sure the file exists.
- Accept HEIC, PNG, JPG, JPEG, TIFF, and other common image files.
- If the user gives more than one image, keep the given page order.
- Do not change or remove the source files.

### 2. Convert the Image

If the file is HEIC on macOS, convert it to PNG:

```bash
sips -s format png "<input.heic>" --out "<output.png>"
```

Use quoted paths so spaces in file names work.

If `sips` is not present, use a local image tool that can read HEIC. If no local tool can read the file, report the problem and stop.

### 3. Fix Page Direction

- Read the EXIF direction tag when it is present.
- Apply the EXIF change before OCR.
- Check that the text is upright after the change.
- If EXIF direction is `6`, test a 90-degree clockwise turn. Confirm the result by checking the text.
- If the page still looks wrong, test turns of 90, 180, and 270 degrees.
- Pick the view with the clearest upright text.
- Do not mirror the image unless the source is clearly mirrored.

EXIF tags can be wrong. Use the page text as the final check.

### 4. Read the Text

Try local OCR tools in this order:

1. macOS Vision, on macOS
2. EasyOCR
3. Tesseract, if installed

Use the language that matches the source document. Add English only when it helps read mixed text.

For hard pages:

- Try a larger image.
- Try gray color.
- Try better light and contrast.
- Read key fields with more than one OCR tool.
- Check names, dates, ID numbers, account numbers, and money values against the image.

Keep the reading order. Save rows, labels, stamps, seals, notes, and table links when they can be read.

Find the type of document, such as:

- Bank balance proof
- Income proof
- Work proof
- Job exit proof
- Property proof
- Business license
- ID card
- Passport
- Other public or legal document

### 5. Translate into English

- Translate all text that can be read.
- Keep the same sections, labels, rows, and order.
- Use clear terms fit for a visa file.
- Do not add facts that are not in the source.
- Keep every number, date, ID, and money value exact.
- Keep the source date style when its meaning is clear.
- If a date may mean two things, show the source form and add a short note.
- Keep the money unit and currency code when shown.
- Do not change names to a new spelling without proof.

For names:

- Keep the source name when the script can be shown.
- Add the English form in brackets when known.
- For Chinese names, use the spelling shown on the passport or document.
- If no official spelling is shown, use standard pinyin and state that it is a transliteration.
- Keep the family name clear. Example: `WU Zhengye`.
- Do not guess the order of a name.

For stamps, seals, and marks:

- Translate readable text.
- Use notes such as `[seal]`, `[stamp]`, `[signature]`, or `[handwritten text]`.
- Use `[unclear]` when the words cannot be read.

### 6. Check the Work

Before making the PDF, compare the translation with the image.

Check each:

- Person and company name
- Date
- Money value and currency
- ID, account, phone, and file number
- Address
- Job title
- Bank name
- Table row and label
- Stamp or seal text

Run a second OCR tool for key facts when the first result is not clear.

### 7. Make the PDF

Use Python with Pillow and ReportLab.

Install local packages only when needed:

```bash
pip install pillow reportlab
```

For macOS Vision:

```bash
pip install pyobjc-framework-Vision pyobjc-framework-Quartz
```

For EasyOCR:

```bash
pip install easyocr
```

For Tesseract on macOS:

```bash
brew install tesseract tesseract-lang
pip install pytesseract
```

Do not make web calls. Do not upload the document. Keep all work on the local device.

PDF layout:

- Use A4 pages.
- Page 1 shows the fixed source image.
- Center the image.
- Scale it to fit without stretching or cutting it.
- Page 2 shows the English translation.
- Center the bold title.
- Keep the main text left-aligned.
- Use clear space, page breaks, and simple tables.
- Use a font that can show every needed mark.
- Add more translation pages if the text does not fit.
- For many source pages, place each source page first, then its matching translation.

Do not call the translation "certified" unless it was made or signed by a person who has the legal right to certify it.

Use this note by default:

> English translation of the attached source document. This file is not a certified translation.

Use this note only when the user has given valid proof of certification:

> This is a certified English translation of the original document.

### 8. Save the File

Save the PDF in the same folder as the source file:

```text
<original_filename>_Translated.pdf
```

Remove only the last file suffix from the source name.

Example:

```text
Bank.Statement.HEIC
Bank.Statement_Translated.pdf
```

For many input files that form one document, use the first file name unless the user gave a document name.

Check that:

- The PDF opens.
- All pages are present.
- No text runs off a page.
- The source image is clear.
- The output name is correct.

Report the full path to the final PDF. Also list any text marked `[unclear]` or any fact that still needs a human check.

## Supported Documents

This skill can work with:

- Bank deposit or balance proof
- Income proof
- Work or job proof
- Retirement proof
- Property proof
- Business licenses
- ID cards and passports
- Other public or legal records

A visa office may have its own rules. Do not claim that the PDF will be accepted. Tell the user when a human translator, sworn translator, seal, or signed statement may still be needed.

## Concrete Example

User command:

```bash
/visa-doc-translate "/Users/me/Visa Files/RetirementCertificate.PNG"
```

Expected work:

1. Check the file.
2. Fix its direction.
3. Read all visible text with local OCR.
4. Check names, dates, numbers, and money values.
5. Translate the text into English.
6. Make an A4 PDF with the image first and the translation next.
7. Save it as:

```text
/Users/me/Visa Files/RetirementCertificate_Translated.pdf
```

8. Report the saved path and any unclear text.