DEV Community

xiaodong Zhang
xiaodong Zhang

Posted on

Geometry Locked, Material Variable: Building a Fabric-Swap Workflow for Garment Images


Changing a garment's fabric sounds like a simple image-editing request: “make this sweater silk.” In practice, it is a constrained transformation with two competing requirements:
1.the garment geometry must remain stable;
2.the surface appearance and fold behavior must change enough to communicate a different material.
The open-source fabric-on-body skill turns that tension into an Agent workflow. It takes a garment style image and a fabric swatch, then instructs an image-editing model to render a visual preview of the same design in the new material.
This is not virtual try-on, and it is not a cloth simulator. Its useful role is narrower: helping a team compare material directions before committing to physical samples.
Model the task as invariants and variables
A useful mental model is:
preview = locked_geometry(style_reference)
+ variable_material_appearance(fabric_swatch)

The style reference should control the invariants:
•silhouette and cut;
•body and sleeve length;
•neckline, cuffs, and hem construction;
•seam placement;
•camera angle, crop, and layout.
The swatch should control the variables:
•color and weave;
•reflectance and surface sheen;
•apparent thickness;
•drape stiffness;
•fold frequency and radius;
•transparency or pile.
If a prompt says only “replace the knit with silk,” the model still has to guess which pixels may move and what “silk” should look like under the scene lighting. The skill therefore adds an explicit geometry lock:
Keep the pattern identical: same cut, same body length, same sleeve length,
same collar/cuff/hem construction, same seam positions, layout and camera angle.
Replace only the material.

That sentence is not a geometric guarantee. It is a constraint expressed in natural language. A probabilistic image editor can still drift, so the workflow needs multiple candidates and a validation pass.
Translate material names into visible behavior
The strongest part of the skill is its material vocabulary. A model cannot touch a swatch or measure its tensile properties. It can only infer visible evidence. Good prompts convert a material label into renderable features.
Material Visible prompt attributes
Silk or satin Specular highlights along folds, fluid drape, continuous gradients
Chunky knit Visible yarn twist, matte fibre halo, heavy structured drape
Denim Diagonal twill, subtle slub, stiff drape, sharp fold creases
Corduroy Vertical wales, matte pile, medium-stiff drape
Chiffon Semi-transparency, fine ripples, soft transmitted light
Leather Broad low-frequency sheen, grain, stiff drape, wide creases
Fleece Dense short pile, fuzzy silhouette edge, little specular highlight

This suggests a general prompt-engineering rule: when a request contains a category label, expand it into observable attributes. “Silk” is semantic. “Narrow specular highlights on fold peaks with a fluid drape” is visual.
A minimal execution pattern
The skill uses the dLazy CLI and calls its hosted gpt-image-2 tool. The repository recommends installing skills through the skills CLI:
npx skills add https://github.com/dlazyai/ecommerce-skills --list
npx skills add https://github.com/dlazyai/ecommerce-skills \
--skill fabric-on-body

The Vercel skills CLI documents support for Codex, Claude Code, Cursor, and other agents. After installation, verify that your agent actually discovers the skill. The source repository uses a lowercase skill.md, while the published Agent Skills specification defines the canonical file as uppercase SKILL.md; the repository's ClawHub publishing flow explicitly renames it. That distinction can matter on case-sensitive systems.
A reduced generation call looks like this:
dlazy gpt-image-2 \
--prompt 'Fabric replacement. Image 1 is the garment pattern reference. \
Image 2 is the target fabric. Keep the pattern identical: same cut, body \
length, sleeve length, collar/cuff/hem construction, seam positions, layout \
and camera angle. Replace only the material. Render the target fabric through \
its visible weave, reflectance, drape stiffness and fold behavior. Neutral \
studio light, clean background, no text.' \
--images style-sheet.jpg fabric-swatch.jpg \
--size 1024x1024 \
--quality high \
--imageFormat jpeg \
--batch 2 \
--save output-style-fabric.jpg

Use --dry-run before a paid request. Prices, model availability, and latency are service state, not constants; inspect the current response rather than relying on numbers copied from an article.
Input quality is part of the algorithm
The skill's documented input constraints are 20 KB–15 MB, dimensions above 400×400, and JPG/JPEG/PNG/WebP. More important than those mechanical limits is image quality.
For the style image:
•use a front-facing flat lay or mannequin image;
•keep the silhouette fully visible;
•prefer a plain background;
•avoid complex prints when evaluating a new material.
For the swatch:
•shoot close enough to resolve the weave;
•use neutral light to avoid a color cast;
•include a gentle fold when drape matters;
•avoid environmental reflections that the model may interpret as material color.
Bad input does not merely produce a lower-resolution version of the right answer. It changes the inferred task. A distant swatch may collapse into a color chip. A warm-lit white fabric may become beige. A heavily printed style reference may compete with the requested surface.
Validate with measurable checks
Do not approve the output because it “looks realistic.” Compare it against both inputs.
Geometry check
•Is the silhouette aligned with the style reference?
•Are body length, sleeve length, and proportions unchanged?
•Are the neckline, cuffs, hem, seams, and closures still present?
•Did the crop or camera angle move?
Material check
•Does the hue match a neutrally lit swatch?
•Is the original texture fully removed?
•Are weave scale and directional texture plausible?
•Do highlights match the target reflectance?
•Are folds consistent with the intended stiffness?
Manufacturing plausibility check
•Is this fabric plausible for the design and construction?
•Did the model preserve ribbing or seams in a way that can actually be made?
•Is the image being used only for directional review, not as evidence of physical performance?
The final check is the most important. A photorealistic image can be physically wrong with great confidence.
Failure modes are more useful than a perfect demo
The source skill documents several predictable failures:
•silhouette drift when geometry is under-specified;
•color shift caused by the swatch lighting;
•the original texture surviving under the new texture;
•paper-like folds when drape stiffness is missing;
•lost ribbing, topstitching, or zippers;
•physically incompatible fabric/design combinations.
Each failure should be treated as a test case. For example, a regression set could pair the same style reference with satin, denim, corduroy, and chiffon. Instead of evaluating “beauty,” record whether each candidate passes explicit geometry and material checks.
Data flow and operational boundaries
The skill discloses that prompts and parameters go to api.dlazy.com, local assets are uploaded to files.dlazy.com, and generated results are hosted there. That is a normal hosted-generation architecture, but it matters for unreleased collections, supplier materials, and NDA-protected designs.
Before using it in a company workflow, verify:
•who may upload the source designs;
•the service's current storage and retention terms;
•whether generated assets can enter your product lifecycle system;
•who signs off on visual accuracy;
•when a physical sample becomes mandatory.
The skill file is instructions, not a local model. Installing it does not remove the hosted API dependency.
The right KPI: fewer bad sampling decisions
It is tempting to market this as “replace physical sampling.” That is the wrong claim and the wrong metric. A fabric photo does not encode hand feel, stretch recovery, shrinkage, sewing behavior, abrasion, or production tolerances.
A more defensible KPI is the percentage of weak material directions rejected before physical sampling. If a team uses visual previews to narrow eight ideas to three, then samples those three and measures real performance, the AI has compressed the decision loop without pretending to simulate the factory.
That is where fabric-on-body is most interesting: not as a magic image prompt, but as a small, auditable operating procedure around a probabilistic model.
Next steps
If you evaluate the skill, start with one clean style image and four materials with visibly different behavior. Run multiple candidates, score them against the same checklist, and keep the physical sample as the source of truth.
Would you trust a geometry-locked visual preview for internal material selection? Which measurement would you require before putting it into a production workflow?
Suggested cover prompt
Editorial technical illustration for a developer article. A flat-lay garment silhouette is locked by precise cyan geometry guides while its surface transitions across satin, denim, corduroy and chiffon quadrants. On the left, a clean garment style reference; on the right, macro fabric swatches; in the center, an AI transformation pipeline. Dark neutral background, crisp diagrammatic lighting, realistic textile detail, no logos, no text, 16:9.

Top comments (0)