Created an AI agent skill to make official ID photos from everyday photos: complete the process from changing into a suit to convenience store printing in one go
- AI
- Python
- Image generation
- Agent
- LLM
Job application resumes, passport renewals, driver's licenses, My Number cards——.
Have you ever had to search for photo booths (boxes) or photo studios every time you needed an ID photo due to procedures every few years or urgent situations?
Even if you think, "My smartphone camera is nice, I'll take a self-shot photo at home and save some money," when you try to do it yourself, you might face issues like shadows from the walls, dark skin tones from room lighting, slightly tilted gaze or head, or not even wearing a suit... Additionally, you might have spent hours manually trimming to precise millimeter specifications like "3mm head space" or "34mm face length," and arranging the face for L-size photo paper (4-part layout) using tools like Photoshop or Word, only to end up with a half-day wasted.
Therefore, by simply asking your regularly used AI agent, "Please create passport and resume ID photos from this photo,"I have open-sourced an Agent Skill that seamlessly performs all steps from naturally changing into a suit, correcting posture, trimming to official millimeter standards, to creating a printable sheet for convenience store 300DPI printing.
[!NOTE]
📁 GitHub repositoryhttps://github.com/lumichy/skills/tree/main/skills/id-photo-studio
※Includes a complete collection of prompts, millimeter-precision trimming & layout scripts, and sample images.
In this article, we will detail the design philosophy of this skill, the actual conversion steps using outdoor snapshots, prompts, usage in agents, and the technical considerations and precautions for why we chose hybrid processing instead of using a single image generation AI.
Quick Reference for Basic Information
| Item | Content |
|---|---|
| Skill Name | id-photo-studio (ID Photo Studio / ID Photo Studio) | Source code | github.com/lumichy/skills/tree/main/skills/id-photo-studio |
| License | MIT License |
| Supported standards | Passport (40×30mm), My Number Card・Passport (45×35mm), Driver's License (30×24mm), U.S. Visa (51×51mm), TOEIC (40×30mm), Custom size |
| Output format | Digital submission single JPEG + Convenience store printing face sheet (L size 89×127mm / 2L size 127×178mm, 300 DPI, with 50mm ruler scale for proofing) |
| Core technologies | AI image generation and editing + Python precise image processing (tilt horizontal correction, frequency separation face lock synthesis, standard trimming) |
| Required libraries | pillow, numpy, scipy |
1. Actual conversion process: converting an outdoor 2-shot snap into an ID photo
As the saying goes, "a picture is worth a thousand words," so let's look at the process of converting an input photo into an ID photo, along with the actual prompts, based on the sample included in the repository.
Original photo: outdoor 2-shot snap (with two people)
The original image is a casual outdoor snap photo of two people standing side by side, with their heads slightly tilted to the left and right.

Original photo: head tilt, casual civilian clothes, outdoor natural light and tree background, 2 people side-by-side snap photo
From here, the agent will autonomously proceed through the steps of geometric correction, AI editing, frequency separation synthesis, and millimeter standard trimming.
Brother: Head tilted +17.93 degrees to the right shoulder up, corrected to horizontalThis results in a standard 3:4 portrait where the line connecting both eyes is perfectly horizontal.
Step 2: AI Suit Change and Studio Lighting (Actual Prompt)
Input the horizontally corrected portrait image into the image generation/editing AI to instruct it to create a studio-style official ID photo (証明写真) and save it to <OUTPUT_PATH>.
This skill prepares three prompt patterns according to the intended use.
Prompt for Pattern A (Suit Change + Closed-Mouth Official Photo Expression)
For purposes where a "serious expression without showing teeth" is essential, such as official documents like passports, My Number cards, or job application resumes.
Prompt for Pattern B (Maintain Original Clothing + Studio Photo Background, Lighting, and Posture)
Prompt for when you want to use the student ID, favorite casual clothes, or uniform as is.
Prompt for Pattern C (100% preservation of the original facial features and expression + suit replacement and background change)
Prompt for when you want to create an ID photo (proof photo) such as a staff ID or profile photo, maintaining the original natural smile and teeth alignment without any distortion, even by 1 millimeter, while changing the suit.
Step 3: Frequency Separation Lock Composite of the Subject's Facial Parts (Python)
When outputting solely with AI, the eyes, nose, and mouth, as well as dental alignment, are inevitably slightly redrawn.
Therefore, using the script (composite_original_head.py), the inner facial parts (eyebrows, eyes, nose, mouth, and moles) are extracted with high-frequency component lock plus Gaussian low-pass color correction from the original photo, and seamlessly blended into the AI-generated suit and neckline images.
- Case C:: The entire face (eyes, nose, mouth, smile, and dental alignment) is completely locked from the original photo
- Case A:: The mouth area adopts the AI's closed-mouth expression while the eye area to eyebrow region is completely locked with original pixels
Step 4: Millimeter-Specification Trimming & Convenience Store Printing Sheet Generation
Finally, the script (process_id_photo.py) performs millimeter-level pixel calculations according to public standards, outputting individual photos and convenience store printing sheets.
Considering smartphone viewing, we will introduce the details of each completed sample in a vertical scroll format.
① Brother: Pattern A (Closed-Mouth Expression of ID Photo + Suit)
The eyes are kept at 100% original pixels, the mouth area is corrected to a natural closed-mouth state, and it is an official ID photo with a suit worn.

Passport/My Number Card Specification (45×35mm)/ Tilt Level Correction (+17.93°) + 100% Original Eye Area Lock + Closed-Mouth Correction
② Brother: Pattern C (100% Maintenance of Original Smile, Eyes, and Dental Alignment + Suit)
This is a portrait that maintains the original smile, gaze, and dental alignment without any changes, achieving a suit change and studio lighting with a blue background.

Passport/My Number Card Specification (45×35mm)/ Tilt Level Correction (+17.93°) + 100% Maintenance of Face, Smile, and Dental Alignment
③ Brother: Convenience Store Printing L-Size Sheet
An L-size sheet for 4-side mounting that can be printed immediately at multi-copy machines such as Seven-Eleven and Lawson.

L-size (89×127mm) 300 DPI / Cutter guide (cut line) with 50mm ruler scale for actual size confirmation
④ Sister: Pattern A (closed-mouth proof photo expression + formal)
- Correcting the head tilted at -25.02 degrees to horizontal, while preserving the original facial features, to create a calm formal proof photo.

Passport/My Number specification (45×35mm) / Tilt horizontal correction (-25.02°) + 100% face lock for the eyes + closed-mouth correction
⑤ Sister: Pattern C (100% maintenance of original smile + formal)
The sister's original cute smile expression is completely preserved, converting it into a formal wear and proof photo background.

Passport/My Number specification (45×35mm) / Tilt horizontal correction (-25.02°) + 100% maintenance of face, smile, and teeth alignment
⑥ Sister: Convenience store printing L-size print sheet
It's a 4-sided proof photo sheet for the sister. A 50mm ruler scale is attached at the bottom for checking actual size after printing.
2. Why is it not possible with "AI-generated alone" or "Python alone"?
Actually, before developing this skill, I failed with two approaches.
First, I thought, "If I ask an image generation AI to create a proof photo with the person's face wearing a suit, it should work instantly." However, even with the latest image generation models, during the AI's image encoding and decoding process,the eye size, double eyelid width, teeth alignment, nasal bridge shape, and mole positions subtly change, resulting in a different person. In public proof photos, if the face is different from the original, it's immediately rejected.
Next, I tried, "What if I use Python's OpenCV or Pillow to cut out the face into an ellipse and composite it with a free suit素材?" However, the human face and neck area have complex shadows. When pasting, the neck and collar boundary becomes prominent, leaving a strong sense of dissonance, like a collage image.
Therefore, I adoptedthe hybrid design that divides the strengths of AI image generation and Python's precise image processing.
Summary of How to Choose Among the 3 Correction Patterns
-
Pattern A (Suit Replacement + Closed-mouth Proof Photo Expression):
Ideal for situations where official standards require "no smile" and "suit wearing", such as passports, My Number cards, and job hunting. -
Pattern B (Keep the Original Clothing + Background, Lighting, and Posture Correction):
Ideal for situations where you want to use your original student ID, qualification certificate, or favorite casual clothes or office casual. -
Pattern C (Maintain 100% Original Smile and Expression + Suit Replacement):
Ideal for situations where you want to combine your natural smile and suit appearance, such as employee ID cards, business SNS profile icons, and speaker profiles.
3. How to Use the Skill and Recommended Execution Environment
This skill can be used simply by placing it in the AI agent's skill directory.
Recommended Agent Environment: Codex or Antigravity is Best
For the agent environment to run this skill, we strongly recommend using Codex or Google Antigravity, which are proficient in both text reasoning and advanced image generation and multimodal processing.
These environments come with high-performance image generation and visual tools built-in, so the most natural suit replacement and collar harmony can be achieved without any additional settings.
Notes When Using with Claude Code: We Recommend Connecting to the Free "AGNES"
On the other hand, if you use Claude Code, a CLI-type coding agent that is very popular, the standard environment does not include an image generation tool.
Therefore, if you are using Claude Code, you need to prepare an external tool or skill that can perform image generation in advance.
If you don't have a paid image generation API or environment, we recommend using the fully free multimodal AI tool "AGNES" locally. By integrating the following skill into Claude Code, you can immediately build a free and high-precision image editing and generation pipeline.
- AGNES Skill (GitHub): skills/agnes-local-generation on GitHub
- Detailed explanation article: AGNES-2: A Guide to Creating a Multi-modal AI Image Generation Tool that is Completely Free and Runs Locally
Example instructions for the agent
In the agent's chat window, you can talk naturally in natural language by specifying the path of the original photo and who's proof photo you want to create. Even if the photo includes multiple people, the agent will extract and process the target individual if you specify them.
If you want to create a proof photo for the sister on the right side, you can give instructions by changing the target as follows.
Once the agent receives the instructions, it will autonomously proceed through the following steps.
- Requirement confirmation and target identification: Confirm the target person (older brother/sister, etc.), the purpose (passport/resume, etc.), the print paper (L-size/2L-size/only individual data), background color, and correction pattern (A / B / C).
- Tilt and horizontal correction: Measure the coordinates of the target person's eyes using --draw-grid, and then use --level-and-crop to correct the head tilt with horizontal rotation, extracting a single portrait.
- AI studio processing: Call the image generation tool within the environment, generating studio lighting and a base image of the suit.
- Identity blending: Restore and composite the eyes and facial parts of the original photo using composite_original_head.py.
- Millimeter specification trimming & sheet generation: Accurately cut out to passport size (45×35mm) using process_id_photo.py, and output an L-size sheet with a border and a 50mm scale for actual size confirmation.
Printing procedure at convenience stores (extremely important)
Save the generated *_sheet_L.jpg to your smartphone, and print it at a multi-copy machine (photo printer) at places such as Seven-Eleven, Lawson, FamilyMart, etc.
There is one important note here. When printing, always select ``Border included printing'' (to fit the entire paper).
If you select ``borderless (full page printing)'', the machine will automatically enlarge it by several percent, which will cause the ratio of the face, calculated precisely in millimeters, to become distorted. If you place a ruler against the printed ``50mm actual size confirmation scale'' at the bottom of the sheet and it measures exactly 50mm, it proves that the sheet is the correct size.
4. Notes and limitations when using
This is a very useful skill, but there are two important points to keep in mind when actually using it.
Note 1: The agent must have an "image generation and editing tool"
Since this skill is a hybrid setup, the agent environment needs to have not only a Python environment but also "tools or skills that can load and edit or generate images".
- Use an environment that has built-in image generation capabilities, such as Codex or Antigravity, or connect with tools like Claude Code, etc., as mentioned earlier. If the environment does not have any image editing tools, AI-based outfit changes or corrections to the neck area cannot be performed. In such cases, the agent will operate in a mode that only performs "background color replacement via Python scripts (--replace-bg) and 100% specification trimming and face alignment, keeping the original casual clothes".
Note 2: If the reasoning ability or generation model is weak, it may look unnatural (especially in Pattern C)
The most important point to be cautious about is the reasoning ability of the agent and the quality of the image generation model used.
In particular, for "Pattern C (mode that maintains 100% of the original photo's face and expression)", it is necessary to let the AI seamlessly blend the original head's neck area, contours, suit collar, and background lighting in Stage 1.
Using a low-reasoning small LLM or a weak image generation model that doesn't follow instructions well can easily lead to the following failures:
- The angle between the neck and the suit collar is mismatched, making the neck look unnaturally long.
- The AI redraws the contours of the original face, resulting in unnatural steps or double chins at the boundaries.
- Boundary noise remains between the background color and the suit's outline.
If you find the generated results unnatural, please switch to a more advanced model (frontier model) or adjust the original head extraction range wider and re-instruct the agent.
5. Summary
The strength of AI agents lies in their ability to automatically complete complex tasks that cannot be achieved by a single tool such as "generating images with prompts" or "executing scripts" by combining them appropriately.
- Role of AI: Outfit change, natural harmony of the neck and background, reproduction of studio lighting
- Role of Python: Eye-level correction via angle calculation, 100% locking of the person's features using frequency separation, specification trimming in millimeters, and face alignment for 300DPI printing
Before you suddenly need a passport photo and end up paying hundreds of yen to take one or struggling with Photoshop, please definitely try this skill by integrating it into your local AI agent.
[!TIP]
📁 Related Links Collection
- ID Photo Studio Skill (GitHub):
https://github.com/lumichy/skills/tree/main/skills/id-photo-studio- AGNES Local Image Generation Skill (GitHub):
https://github.com/lumichy/skills/tree/main/skills/agnes-local-generation- AGNES Explanation Article:
https://qiita.com/lumichy/items/d243184dcb54f80bfeda
What do you usually do when you need a passport photo? If you have any ideas like 'I also want this specification size or feature,' please let me know in the comments section!
Go to list of users who liked
Go to list of comments
Register as a new user and use Qiita more conveniently



