image-portrait
Original:🇺🇸 English
Translated
3 scriptsChecked / no sensitive code detected
Identity-consistent portrait generation: professional headshots, dating photos, style transfers, themed portraits, photo series, avatars, ID photos. Use when generating styled portraits from a reference photo (e.g. professional headshot, anime avatar, cyberpunk portrait, travel photo, dating profile photo, ID photo).
248installs
Added on
NPX Install
npx skill4agent add starchild-ai-agent/official-skills image-portraitTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →image-portrait
Use this skill for all identity-consistent portrait generation requests on Starchild.
Covers: professional headshots, dating/social photos, artistic style transfers, themed/holiday portraits, photo series, digital avatars, children/family photos, ID/passport photos.
Core principle: call the provided script. Do not re-implement proxy/billing plumbing.
1. Quick start — single portrait (most common)
python
exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_portrait(
image_path="path/to/user/photo.jpg",
style="professional",
)
# result -> {"success": True, "images": [{"local_path": "output/images/..."}], ...}The script reads the local file, base64-encodes it, and sends it to fal.ai as a data URI — no manual URL publishing needed.
2. Quick start — public URL
python
exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_portrait(
face_image_url="https://example.com/photo.jpg",
style="anime",
)3. Quick start — text-to-image (no reference photo)
python
exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_portrait(
prompt="a young woman in cyberpunk armor, neon city background, rain",
model="nanopro",
)When no or is provided, the script uses the text-to-image endpoint (no suffix).
image_pathface_image_url/editDelivering the result to the user — IMPORTANT
Never hand the user the raw fal.media URL. fal serves files with restrictive CSP headers. The only reliable delivery path is the already-downloaded local file:
- Use each image's (e.g.
local_path) — the script always downloads on success.output/images/xxx.png - Tell the user the files are saved to and viewable in the workspace file panel.
output/images/ - On Web channel, embed inline so the user can preview in chat:
markdown
 - On Telegram / WeChat: send via or
send_to_telegram(file_path="output/images/...", message_type="image").send_to_wechat(file_path="output/images/...", message_type="image")
4. Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
| no | — | Local workspace file path to the user's face photo |
| no | — | Public HTTPS URL of the user's face photo |
| no | | Preset style key (see §5) |
| no | | Custom scene description (appended to style prompt) |
| no | | Fully custom prompt — overrides style+scene when set |
| no | | Model: |
| no | | Number of images to generate (1–8) |
| no | | Output ratio: |
Image input rules:
- Provide OR
image_pathfor identity-consistent generation (edit mode).face_image_url - If both are given, takes priority.
image_path - Omit both for pure text-to-image generation (generate mode).
Prompt priority: > > > default ().
promptstyle + scenestyleprofessional5. Style presets
A: Identity-consistent character styles
| Style | Key | Best for |
|---|---|---|
| Professional headshot | | LinkedIn, resume, corporate |
| Artistic portrait | | Creative portfolio, gallery |
| Anime | | Social media, fun avatar |
| Cyberpunk | | Gaming profile, sci-fi fan |
| Oil painting | | Art gift, classical look |
| Watercolor | | Soft artistic portrait |
| Vintage | | Retro aesthetic, nostalgia |
| Casual lifestyle | | Social media, personal blog |
B: Personal showcase / dating / social
| Style | Key | Best for |
|---|---|---|
| Dating — cafe | | Dating app, warm vibe |
| Dating — beach | | Dating app, summer vibe |
| Dating — city | | Dating app, urban vibe |
| Dating — restaurant | | Dating app, elegant vibe |
| Travel — Europe | | Travel blog, social media |
| Travel — Japan | | Travel blog, cultural |
| Travel — tropical | | Vacation, resort |
| Sports — gym | | Fitness profile |
| Sports — running | | Athletic profile |
| Social media | | Instagram, TikTok |
| Professional networking | |
| Personal brand | | Entrepreneur, creator |
D: Themed / scene portraits
| Style | Key | Best for |
|---|---|---|
| Christmas | | Holiday greeting, social |
| Halloween | | Holiday fun |
| Graduation | | Milestone celebration |
| Wedding | | Wedding planning, save-the-date |
| Business speech | | Speaker profile |
| Musician | | Music promotion |
| Chef | | Food blog, restaurant |
| Outdoor adventure | | Adventure blog |
| Pet together | | Pet lover profile |
| Reading | | Book club, literary |
| Night city | | Urban lifestyle |
| Hanfu (Chinese traditional) | | Cultural, cosplay |
O: Digital avatar
| Style | Key | Best for |
|---|---|---|
| 3D cartoon | | Social avatar, Pixar style |
| Gaming avatar | | Game profile, RPG |
| VTuber | | Streaming, VTuber |
T: Children & family
| Style | Key | Best for |
|---|---|---|
| Child portrait | | Family keepsake |
| Family photo | | Family portrait |
U: ID / passport photos
| Style | Key | Best for |
|---|---|---|
| ID photo (white bg) | | Passport, driver's license |
| ID photo (blue bg) | | Visa, work permit |
6. Model selection guide
| Model | Key | Speed | Quality | Best for |
|---|---|---|---|---|
| Nano Banana 2 | | ~15s | Good | Quick drafts, fast iteration, bulk generation. |
| NanoPro | | ~25s | Better | Default for all requests. Balanced speed and quality. |
| GPT Image 2 | | ~150s | Best | When user explicitly asks for "highest quality" or "best quality". Complex scenes. |
Decision rules:
- Default: always use unless the user explicitly requests otherwise.
nanopro - Use when: user wants fastest results, is iterating on styles, generating many images, or says "quick", "draft", "fast".
nano2 - Use when: user says "highest quality", "best quality", "premium", or the scene is very complex with many specific details.
gpt
python
# Default (fast)
result = generate_portrait(image_path="photo.jpg", style="anime")
# High quality (user requested)
result = generate_portrait(image_path="photo.jpg", style="anime", model="gpt")7. Custom scene examples
python
# Style + custom scene
result = generate_portrait(
image_path="uploads/my_photo.jpg",
style="professional",
scene="in a modern office with city skyline view",
)
# Custom scene only (defaults to professional style base)
result = generate_portrait(
image_path="uploads/my_photo.jpg",
scene="standing on a beach at sunset, golden hour lighting",
)
# Fully custom prompt (overrides everything)
result = generate_portrait(
image_path="uploads/my_photo.jpg",
prompt="portrait of a person as a medieval knight, full plate armor, castle background, dramatic lighting, oil painting style",
)
# Different aspect ratio
result = generate_portrait(
image_path="uploads/my_photo.jpg",
style="cyberpunk",
aspect_ratio="9:16",
)
# Multiple images
result = generate_portrait(
image_path="uploads/my_photo.jpg",
style="dating_cafe",
count=4,
)8. Prompt engineering best practices
When the user's request doesn't match any preset style, or when you need to construct a custom , follow these guidelines (derived from reference skills: ai-headshot-generation, ai-avatar-generation, style-transfer, portrait-enhancement, character-design-sheet, avatar-portrait, nano-banana-pro, pet-portrait-generation).
promptAutomatic likeness preservation
When a reference image is provided (edit mode), the script automatically prepends a likeness preservation instruction to every prompt. This ensures the generated portrait preserves the subject's facial identity. You do NOT need to add likeness instructions manually — the script handles it.
Exception: avatar styles (, , ) skip the likeness prefix because stylization takes priority over photographic likeness.
avatar_3davatar_gamingavatar_vtuberThe 7-element prompt structure
Every effective portrait prompt should include these elements (from nano-banana-pro skill):
[subject], [outfit/attire], [pose/action], [expression], [background/setting], [lighting], [style/quality modifiers]Key principles
-
Likeness vs. style balance (from avatar-portrait skill):
- Too photorealistic = ignores requested style
- Too stylized = loses resemblance to source person
- For stylized portraits: emphasize "stylized but maintains individual features"
- For photorealistic: emphasize "keep facial features recognizable"
-
Lighting is critical — always specify lighting type:
- Studio: "soft diffused studio lighting", "Rembrandt chiaroscuro lighting"
- Natural: "golden hour warm light", "dappled sunlight through trees"
- Dramatic: "dramatic rim lighting", "volumetric light beams", "neon glow"
- Flat: "even flat lighting with no shadows" (for ID photos)
-
Background specificity — vague backgrounds produce poor results:
- ❌ "nice background"
- ✅ "blurred modern office with glass windows and city view"
- ✅ "clean neutral gray gradient studio background"
- ✅ "background style should match the character style" (for avatars)
-
Lens/camera hints — help the model understand framing:
- "85mm lens look, shallow depth of field" (portrait)
- "head and shoulders framing" (headshot)
- "full body, clean white background" (character design)
- "close-up face, portrait orientation" (expression/avatar)
-
Quality anchors — add style quality references:
- "professional photography quality", "magazine cover quality"
- "National Geographic photography style" (adventure)
- "League of Legends splash art style" (gaming)
- "Pixar and Disney animation style" (3D avatar)
- "Studio Ghibli inspired" (anime)
- "fine art watercolor painting look" (watercolor)
-
Texture and material — for artistic styles, specify medium:
- "visible impasto brushstrokes, canvas texture" (oil painting)
- "loose expressive watercolor style, soft edges, beautiful color bleeds and washes" (watercolor)
- "natural film grain, Kodak Portra emulation" (vintage)
- "cel-shaded, clean line art, bold outlines" (anime)
- "visible pixels but NOT a pixelated photo filter" (pixel art)
-
Expression guidance — be specific about mood:
- ❌ "smiling"
- ✅ "warm genuine smile, confident approachable expression"
- ✅ "neutral calm expression with mouth closed" (ID photo)
- ✅ "passionate expression, energetic" (musician)
Example: building a custom prompt
User: "I want a photo of me as a wizard in a magical forest"
python
result = generate_portrait(
image_path="uploads/photo.jpg",
prompt=(
"fantasy wizard portrait, wearing mystical purple robes with glowing runes, "
"ancient wooden staff with crystal orb, wise powerful expression, "
"enchanted forest background with bioluminescent plants and floating particles, "
"dramatic magical lighting with ethereal glow, "
"high fantasy art style, detailed digital painting quality"
),
)
# Note: likeness prefix is auto-added because image_path is providedExample: pixel art avatar (from avatar-portrait skill)
User: "Make me a retro pixel art avatar"
python
result = generate_portrait(
image_path="uploads/photo.jpg",
prompt=(
"retro 16-bit pixel art portrait, visible pixels with clean lines, "
"rich colors, consistent shading, stylized but maintains individual features, "
"warm sunset cityscape background in matching pixel art style, "
"head and shoulders, square format"
),
)9. Photo series
Generate a coordinated set of themed portraits in one call. Pass a custom list of styles/scenes — the agent assembles the list based on the user's request.
python
exec(open('skills/image-portrait/generate_portrait.py').read())
result = generate_series(
image_path="uploads/my_photo.jpg",
series=[
{"style": "professional"},
{"style": "casual", "scene": "at a rooftop bar, sunset"},
{"style": "anime"},
{"prompt": "portrait as a superhero, cape flowing, city skyline"},
],
)
# result -> {"success": True, "images": [...4 images...], "series": "custom"}Each item in the list is a dict with optional keys:
- — any style key from §7 (e.g.
style,"professional","anime")"cyberpunk" - — override the scene description (combined with the style template)
scene - — fully custom prompt (ignores style/scene)
prompt
10. Intent recognition guide
Use this table to map user requests to the correct style/parameters:
| User says | Style | Notes |
|---|---|---|
| "professional photo", "headshot", "LinkedIn photo" | | |
| "dating photo", "dating app", "Tinder photo" | | Ask which vibe |
| "anime me", "anime version", "cartoon me" | | |
| "cyberpunk", "sci-fi portrait" | | |
| "oil painting", "classical portrait" | | |
| "watercolor portrait" | | |
| "vintage photo", "retro" | | |
| "casual photo", "lifestyle" | | |
| "travel photo in Paris/Europe" | | |
| "travel photo in Japan/Tokyo/Kyoto" | | |
| "beach photo", "tropical" | | |
| "gym photo", "fitness" | | |
| "Christmas photo" | | |
| "Halloween photo" | | |
| "graduation photo" | | |
| "wedding photo" | | |
| "chef photo", "cooking" | | |
| "musician", "on stage" | | |
| "with my dog/pet" | | |
| "reading", "bookish" | | |
| "night city", "urban night" | | |
| "hanfu", "Chinese traditional" | | |
| "3D avatar", "Pixar style" | | |
| "gaming avatar", "RPG character" | | |
| "VTuber avatar" | | |
| "kid photo", "children's portrait" | | |
| "family photo" | | |
| "passport photo", "ID photo" | | White bg default |
| "visa photo" | | Blue bg |
| "photo series", "set of photos" | Use | Assemble custom list from styles |
| "highest quality", "best quality" | Any style + | |
| Custom scene not in presets | Use |
11. Provided scripts
| File | Purpose |
|---|---|
| Core script: submit → poll → download. Handles local files (base64) and URLs, all styles, custom scenes, three models (nano2/nanopro/gpt). |
| Re-exports |
| Cost tracking helper — records per-call costs via sc-proxy headers. |
12. Local testing
Set env var to call fal.ai directly (bypasses sc-proxy):
FAL_KEYbash
# Single portrait
FAL_KEY=your-fal-key python3 skills/image-portrait/generate_portrait.py photo.jpg anime 1 nanopro
# Args: <image_path_or_url> [style] [count] [model]13. Troubleshooting
| Problem | Fix |
|---|---|
| Check the workspace path; the file must exist |
| Use |
| Resize to under 10 MB before uploading |
| Use |
| Top up balance; cost is pre-charged on submit |
| sc-proxy only allows approved fal endpoints; contact admin |
Generation | Simplify prompt, ensure face photo is clear and well-lit, retry |
Job stuck | Save |
| Poor face consistency | Use a clear, front-facing photo with good lighting; avoid group photos |
| Switch to |
14. Infrastructure (reference)
- Caller → →
sc-proxy→ fal model providersqueue.fal.run/{model} - All requests must include (proxy injects the real
Authorization: Key fake-falai-key-12345)FAL_KEY - Pre-charge happens at submit. Poll/result calls are free.
- Local files are base64-encoded as data URIs — no separate upload step needed.
- Final images live at — public CDN, no auth needed for download.
https://*.fal.media/... - Cost tracking via — records
_cost_track.pyfrom sc-proxy response headers.X-Credits-Used
Model endpoints
| Model | Edit (with ref image) | Generate (text only) |
|---|---|---|
| nano2 | | |
| nanopro | | |
| gpt | | |