/firefly-services:firefly-expand-fillfrom firefly-services
Use Adobe Firefly's Generative Expand and Generative Fill APIs — when to use each, masking strategies, placement and aspect ratio control, prompt patterns for clean extension and inpainting, and the difference between filling versus replacing image regions. Use whenever the user mentions "generative expand", "extend canvas", "generative fill", "inpaint", "outpaint", "remove object", "replace background", "expand image", "fill image", "masking", "expand-async", "fill-async", or wants to grow / patch / modify an existing image. Encodes production patterns for background extension on hero assets and for brand-aligned background replacement in high-volume template-driven campaign asset production.
Ships in firefly-services. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Two related but distinct APIs for modifying existing images. Expand grows the canvas and generates new content into the new area. Fill modifies or replaces regions within the existing canvas, guided by a mask. Picking the right one is half the battle; the rest is mask quality.
Use this skill when:
Do NOT use this skill when:
firefly-generate-image-v3-asyncfirefly-generate-similar| Need | Endpoint |
|---|---|
| Grow canvas, generate content in the new region | Expand |
| Change image aspect ratio (1:1 → 16:9) | Expand |
| Remove an object and patch the area | Fill |
| Replace background while keeping subject | Fill with mask covering background |
| Replace a specific region (sky, ground, person's shirt) | Fill |
| Inpaint a damaged or unwanted region | Fill |
| Outpaint (the classic AI-art "generate beyond the frame") | Expand |
In short: canvas grows = Expand. Canvas stays = Fill.
curl --silent -X POST 'https://firefly-api.adobe.io/v3/images/expand' \
-H "Authorization: Bearer $FIREFLY_SERVICES_ACCESS_TOKEN" \
-H "X-Api-Key: $FIREFLY_SERVICES_CLIENT_ID" \
-H 'Content-Type: application/json' \
--data @- <<EOF
{
"image": {"source": {"uploadId": "$SOURCE_UPLOAD_ID"}},
"size": {"width": 2688, "height": 1536},
"prompt": "a sweeping desert landscape continuing into the distance",
"placement": {
"alignment": {"horizontal": "center", "vertical": "center"}
},
"numVariations": 2
}
EOF
(The heredoc keeps the JSON readable while letting $SOURCE_UPLOAD_ID interpolate — a single-quoted -d '...' body would send the literal string $SOURCE_UPLOAD_ID as the uploadId.)
/v3/images/expand responds synchronously: a 200 with { "size": {...}, "outputs": [{ "seed": ..., "image": { "url": ... } }] }. No jobId, no polling. Separate /v3/images/expand-async and /v3/images/fill-async endpoints (documented on developer.adobe.com) return the jobId/statusUrl pattern — use those, with the polling loop from firefly-generate-image-v3-async, when you want queue-style job handling.
Expand also accepts an optional image.mask (a bare binary input, like image.source): the mask defines the expansion region, must be larger than the source, and the target size is taken from (or inferred from) the mask. A mask cannot be combined with placement — pick one mechanism per request.
placement fieldplacement controls where the original image sits within the new (larger) canvas:
"placement": {
"alignment": {"horizontal": "center", "vertical": "center"},
"inset": {"left": 0, "top": 0, "right": 0, "bottom": 0}
}
| Alignment | Effect |
|---|---|
center, center | Original in middle, expanded equally on all sides |
left, center | Original on left, expanded to the right |
right, top | Original in top-right, expanded down and left |
Use inset for fine pixel control. Typical pattern: original at center, expand evenly. For social-media variants (landscape → portrait), place the original off-center so the subject lands in the safe area.
prompt field for expandPrompts describe what the new (expanded) area should contain. The original image stays as-is. Examples:
| Original | Prompt | Result |
|---|---|---|
| Portrait of a person | "the rest of their body in a business suit" | Original head + new body |
| Product on white | "a kitchen counter with morning light" | Product in scene |
| Landscape close-up | "a vast sky with scattered clouds above" | Scene continues upward |
Leave prompt empty to let Firefly extend the existing content stylistically (common for cropping/recropping workflows).
Common production use cases:
| From | To | size | placement.alignment |
|---|---|---|---|
| 1024×1024 (1:1) | 1408×768 (11:6 landscape) | width 1408, height 768 | center, center |
| 1024×1024 (1:1) | 768×1408 (6:11 portrait) | width 768, height 1408 | center, top (lower face) |
| 1408×768 (11:6 landscape) | 2688×1536 (16:9 widescreen) | width 2688, height 1536 | center, center |
| 1024×1024 (square) | 1024×1792 (4:7 story portrait) | width 1024, height 1792 | center, top |
For an exact 16:9 output, use the spec's canonical widescreen size, 2688×1536 (1536×2688 for the vertical counterpart) — 1408×768 is 11:6 (~1.83), close to but not exactly 16:9.
Fill requires a mask that tells Firefly which region to modify. White pixels = fill this. Black pixels = preserve. Grayscale = soft blend.
The mask must be the same dimensions as the source image, and the mask's larger side must be at least 600 px. Generate the mask client-side (image editor, Photoshop API, or programmatically with sharp / pillow) and upload as a storage reference.
# Upload mask
MASK_UPLOAD_ID=$(curl --silent -X POST 'https://firefly-api.adobe.io/v2/storage/image' \
-H "Authorization: Bearer $FIREFLY_SERVICES_ACCESS_TOKEN" \
-H "X-API-Key: $FIREFLY_SERVICES_CLIENT_ID" \
-H "Content-Type: image/png" \
--data-binary "@./mask.png" \
| jq -r '.images[0].id')
curl --silent -X POST 'https://firefly-api.adobe.io/v3/images/fill' \
-H "Authorization: Bearer $FIREFLY_SERVICES_ACCESS_TOKEN" \
-H "X-Api-Key: $FIREFLY_SERVICES_CLIENT_ID" \
-H 'Content-Type: application/json' \
--data @- <<EOF
{
"image": {
"source": {"uploadId": "$SOURCE_UPLOAD_ID"},
"mask": {"uploadId": "$MASK_UPLOAD_ID"}
},
"prompt": "a modern minimalist living room background",
"numVariations": 2
}
EOF
Note the mask shape: image.mask is a bare binary input ({"uploadId": ...} or {"url": ...}) — do not wrap it in a "source" object the way image.source is written. The heredoc body is double-quote territory, so $SOURCE_UPLOAD_ID / $MASK_UPLOAD_ID interpolate correctly.
The endpoint responds synchronously with { "size": {...}, "outputs": [{ "seed": ..., "image": { "url": ... } }] } — no polling.
Optional request fields worth knowing: negativePrompt (up to 1024 chars, describes what to avoid in the fill), promptBiasingLocaleCode (e.g. "en-US", biases output toward regionally relevant content), and seeds (array, one per variation — reusing a seed biases regeneration toward a consistent composition, but does not guarantee byte-identical output; archive the returned artifact if you need an exact copy).
prompt field for fillPrompts describe what should appear in the masked region. The unmasked region stays as-is.
| Mask covers | Prompt | Result |
|---|---|---|
| Background of a product shot | "marble kitchen counter" | Product unchanged, new background |
| An unwanted person | "empty park bench" | Person removed, bench fills the area |
| A label area | "minimal white space" | Label gone, area cleaned up |
| A vehicle's color region | "matte red paint" | Vehicle now red |
| Strategy | Tool | When |
|---|---|---|
| Manual mask | Photoshop, image editor | One-off creative work |
| Programmatic mask | sharp, pillow | Geometric regions (top half, left third) |
| Subject detection | Photoshop Remove Background API (POST /v2/remove-background with mode: "mask") or custom segmentation | Replace background, isolate subject |
| Color-key mask | sharp threshold | Replace a specific colored region |
| AI segmentation | SAM (Segment Anything), Mediapipe | Production segmentation pipelines |
For high-volume template-driven campaign asset production (background extension at batch volume), masks are generated programmatically from subject detection — never by hand.
A common production pipeline:
Source hero asset (1408×768)
↓ Expand (to 2688×1536, prompt extending the scene)
Expanded image
↓ Fill (mask covers text area, prompt: "clean background")
Cleaned widescreen version
↓ Apply Photoshop API actions (text overlay, layer compositing)
Final asset
This is the template-driven compositing pipeline condensed. Each stage is a separate API call (expand and fill respond synchronously; Photoshop actions are async jobs); the pipeline is queue-fronted (see firefly-services-rate-limits).
Given one square hero asset, generate landscape + portrait + story formats:
const aspects = [
{ name: 'landscape-11-6', size: { width: 1408, height: 768 }, alignment: { horizontal: 'center', vertical: 'center' } },
{ name: 'portrait-6-11', size: { width: 768, height: 1408 }, alignment: { horizontal: 'center', vertical: 'top' } },
{ name: 'story-4-7', size: { width: 1024, height: 1792 }, alignment: { horizontal: 'center', vertical: 'top' } },
];
const jobs = await Promise.all(
aspects.map(a => submitExpand({
sourceUploadId: SOURCE_ID,
size: a.size,
placement: { alignment: a.alignment },
prompt: 'continue the scene naturally',
numVariations: 2,
})),
);
Three submissions, ~6 outputs in parallel. Persist each with the aspect tag for the downstream creative team.
For brand-campaign-creator background swaps:
Source image
↓ Photoshop Remove Background API (POST image.adobe.io/v2/remove-background, mode: "mask") → mask (subject white, background black)
↓ Invert mask (subject black, background white) — Sharp/Pillow
Fill request with inverted mask
↓ prompt: "<brand-aligned background>"
Output: subject preserved, new background
The remove-background call is an async job — poll the status URL it returns before moving on. V2 remove-background hosts the result itself: the grayscale mask arrives as an Adobe pre-signed destination.url in the job status (it supersedes the V1 sensei/mask family). The inversion step is critical — mode: "mask" gives you the subject mask; for background replacement you need the inverse.
Expand/Fill pipelines are production-ready when:
placement decisions align with brand safe-area guidelinesnegativePrompt (up to 1024 chars) describing what to keep out of the generated region.placement.alignment — defaults may move the subject.firefly-services-storage-refs — Mask + source uploadfirefly-generate-image-v3-async — Same async patternphotoshop-api-actions — For automated mask generation (POST /v2/remove-background with mode: "mask")firefly-services-rate-limits — For batch pipelinesWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub focus-gts/firefly-services-skills --plugin firefly-services19 skills in this plugin
/firefly-batch-pipelineThe end-to-end production reference architecture for high-volume generative campaign workloads on Adobe Firefly Services — SQS-fronted intake, Lambda worker pool with per-credential token-bucket pacing, Step Functions orchestration for multi-stage PSD composition, DynamoDB job state, S3 result persistence, DLQ replay, and webhook-driven customer notification. Use whenever the user mentions "batch pipeline", "campaign at scale", "thousands of images per day", "generative pipeline", "campaign assembler", "asset factory", "production-grade pipeline", or designs a system that combines Firefly generation with Photoshop composition at volume. Stitches `firefly-services-rate-limits` and `photoshop-api-composition` into a single deployable blueprint./firefly-brand-guardrailsEnforce brand compliance on generative output — custom-model lock-in, prompt and output content filtering, asset tagging for downstream policy, and the human-review queue pattern for regulated or brand-sensitive workloads. Use whenever the user mentions "brand compliance", "brand safety", "regulated industry", "review queue", "approval workflow", "content moderation", "brand guardrails", "legal review", "compliance hold", or generates assets for financial services, pharma, automotive, public sector, or any customer with a brand-review process. Encodes the production guardrail pattern that turns "Firefly generates whatever it wants" into "every asset that ships passes a documented compliance gate."Other plugins' skills for the same job