SkillsGrove
SkillsGrove/Дизайн и изображения/JongLeePc/gpt-image2-layered-psd/psd-layer-extractor

psd-layer-extractor

Установка

$npx skills add https://github.com/JongLeePc/gpt-image2-layered-psd --skill psd-layer-extractor
$git clone --depth 1 https://github.com/JongLeePc/gpt-image2-layered-psd.git /tmp/gpt-image2-layered-psd && mkdir -p ~/.claude/skills && cp -r /tmp/gpt-image2-layered-psd/. ~/.claude/skills/psd-layer-extractor
Пожалуйста, установи для меня этот Agent Skill: https://github.com/JongLeePc/gpt-image2-layered-psd/tree/9ec94e8760b54c77cf7f94315db2eef7ef3aabfa/ — сначала прочитай его SKILL.md и скрипты и устанавливай в мою папку навыков только после того, как убедишься, что он безопасен.

Кратко

Исходное описание · MITProcess uploaded or local images into single semantic element PNGs and layered PSD files. Use whenever the user says PSD图层提取, use this skill, process an uploaded image, extract all image elements, split an image into PSD layers, create elements_contact_sheet.png for confirmation, or convert a poster/product/detail image into editable Photoshop layers. Default workflow is image to single element extraction to elements_contact_sheet.png confirmation to PSD assembly.
Приведённый ниже SKILL.md воспроизведён из JongLeePc/gpt-image2-layered-psd (коммит 9ec94e8) под лицензией MIT. Текст не изменён; опущены только метаданные заголовка файла, изображения показаны как ссылки, а очень длинные файлы сокращены. Авторские права: 2026 JongLeePc. Лицензия: LICENSE. Показан только файл с инструкциями; скрипты смотрите в исходном репозитории.

PSD图层提取

Use this skill whenever the user says PSD图层提取, says to use this Skill, process an uploaded image, extract image elements, split a poster/product/detail image, or convert an image to PSD layers.

Default workflow: start from the user's uploaded image or existing local image, extract all single semantic elements, generate elements_contact_sheet.png for review, wait for the user's confirmation, then assemble a Photoshop-editable PSD project. Do not ask the user to restate this workflow unless the image path or API configuration is missing.

For occluded product elements, do not stop at visible-pixel cutout. Produce a complete reconstructed element when the user expects a standalone asset.

Quick Start

Confirm one element first before batch splitting:

  1. Ask or infer the target element, for example "white PLA filament spool".
  2. Extract/generate only that element.
  3. If part of the element is hidden by another object, reconstruct the missing part so the element is complete.
  4. Show the transparent PNG preview and wait for confirmation before batch processing.

Primary workflow for an uploaded/local image:

python ~/.codex/skills/gpt-image2-layered-psd/scripts/generate_layered_psd.py \
  --source /path/to/input.png \
  --slug summer_poster

Optional generation workflow only when the user explicitly asks to create a new source image first:

python ~/.codex/skills/gpt-image2-layered-psd/scripts/generate_layered_psd.py \
  --prompt "Create a vertical summer ecommerce poster with headline, beach product scene, offer badge, and clean layerable composition." \
  --slug summer_poster

Offline structural self-test:

python ~/.codex/skills/gpt-image2-layered-psd/scripts/generate_layered_psd.py \
  --prompt "mock poster" \
  --slug smoke_test \
  --mock-openai

Element-review extraction without PSD assembly:

python ~/.codex/skills/gpt-image2-layered-psd/scripts/generate_layered_psd.py \
  --source /path/to/input.png \
  --slug summer_poster \
  --extract-only

Required Backend

On a newly installed device, do not assume provider credentials are already configured. Before a real API run, check:

  • GPT_IMAGE2_API_KEY or OPENAI_API_KEY
  • GPT_IMAGE2_BASE_URL or OPENAI_BASE_URL

If either the API key or third-party base URL is missing, ask the user to provide it, then set it only in the current shell/session environment. Do not write secrets into the skill files, README, manifests, logs, screenshots, or examples.

When the user explicitly wants official OpenAI, set the base URL to https://api.openai.com/v1.

For OpenAI-compatible third-party image gateways, set GPT_IMAGE2_BASE_URL or pass --base-url.

Default image model: gpt-image-2.

Read the API key from GPT_IMAGE2_API_KEY first, then OPENAI_API_KEY.

The script uses the OpenAI-compatible image generation format:

{
  "model": "gpt-image-2",
  "prompt": "...",
  "size": "1024x1536",
  "quality": "high",
  "output_format": "png"
}

Endpoints used by bundled scripts:

  • <base_url>/images/generations for optional source generation.
  • <base_url>/images/edits for restoration and transparent element extraction.
  • <base_url>/responses for semantic visual analysis.

Workflow

  1. Locate the user-uploaded image or ask for the image path only if no image is available.
  2. Start with one target element confirmation when quality matters.
  3. Decide extraction mode per element:
    • Visible cutout: preserve only pixels actually visible in the source image.
    • Complete element: reconstruct hidden/occluded portions so the element becomes a standalone usable asset.
  4. Run semantic PSD decomposition using the bundled scripts/run_image2_psd.py only after the single-element direction is accepted.
  5. Generate transparent element PNGs for background, subject, text, badges, icons, decorations, shadows, and foreground objects where possible.
  6. Show a contact sheet and the element PNG directory to the user for review.
  7. Wait for explicit user confirmation that all elements are correct before assembling the PSD.
  8. Assemble the PSD and preview only after confirmation with scripts/image2psd.py assemble --manifest <project>/manifest.json.
  9. Inspect the preview and validation report before claiming production readiness.

Bundled Scripts

This skill is self-contained for normal installation. It bundles:

  • scripts/generate_layered_psd.py: entrypoint for uploaded images or optional source generation.
  • scripts/run_image2_psd.py: semantic image analysis, element extraction, contact sheet generation, and optional PSD assembly.
  • scripts/image2psd.py: pure-Python raster PSD writer used for final assembly.

The normal installed skill does not require image2-ai-psd-layerizer or bggg-creator-image2psd to exist on the target machine.

Optional overrides are supported only for advanced local development:

  • GPT_IMAGE2_DOWNSTREAM_SCRIPT or --downstream-script to replace the bundled layerizer.
  • GPT_IMAGE2_PSD_WRITER to replace the bundled PSD writer.

If a damaged/minimal installation is missing the bundled layerizer, the CLI creates a standalone_handoff/ project instead of failing. Treat that as an installation problem to fix, not the final PSD workflow.

Confirmed Single-Element PSD Workflow

Use this workflow when the user wants "single elements", "complete elements", "not chunks", "not cut into blocks", or "elements must be separate".

  1. Build a confirmed element library first:
    • Text and icon elements may be source-fidelity transparent layers.
    • Photo cards, material swatches, labels, dimension marks, arrows, products, props, shadows, and platforms should each be one semantic element.
    • Occluded/cut-off products should be reconstructed into complete standalone transparent PNGs when the user asks for complete elements.
  2. Show a contact sheet of the element library and wait for confirmation.
  3. Do not use loose visible_*_source object masks as final single-element product layers. Those are only acceptable for an original-visible layout candidate, not for a final "single element" PSD.
  4. When assembling PSD after confirmation:
    • Put the background at the bottom.
    • Put shadows and structural supports below products.
    • Place one semantic object per PSD layer.
    • Keep repaired complete products as product layers only when their placement has been checked; otherwise keep them as separate asset PNGs.
  5. Self-check before showing the PSD:
    • Inspect each product/object layer on a dark background to catch white matte, transparent holes, color-key damage, or accidental neighboring objects.
    • Inspect the flattened preview against the source layout.
    • Verify the PSD layer stack opens with the background below all objects.
    • If the candidate is wrong, delete it before showing the user.

Two valid PSD modes exist; do not mix them without saying so:

  • Original-visible layout PSD: uses source-visible layers so the flattened preview matches the uploaded image. These layers may include only visible portions of occluded objects and are not standalone complete assets.
  • Single-complete-elements PSD: uses repaired/complete standalone elements. This satisfies independent element editing, but the flattened preview may differ from the source where the source had occlusion or cropping.

Complete Element Extraction

Use complete extraction when the user says the element is "not complete", "missing bottom", "hidden", "blocked", "occluded", or needs to be usable as an independent product cutout.

Process:

  1. Use source image analysis to identify the target and visible region.
  2. Generate or edit a standalone version of the target element on a flat chroma-key background.
  3. Reconstruct occluded or cropped areas consistently with the object's geometry, material, lighting, perspective, and markings.
  4. Remove the chroma-key background locally into alpha.
  5. Save a cropped transparent PNG for user confirmation.

Chroma-key rule:

  • Never use one fixed key color for every element.
  • Choose a key color that is absent from the subject.
  • Do not use green (#00ff00) for green subjects or subjects with green details.
  • Use magenta (#ff00ff) for green elements such as leaves or green products unless the subject itself contains magenta.
  • Inspect the alpha result; if key removal changes subject colors or deletes details, regenerate with a non-conflicting key color or use a mask-based cutout.

Prompt constraints for completion:

  • Preserve the target object's identity, material, perspective, lighting, and visible markings.
  • Reconstruct missing parts naturally; do not leave pedestal, background, neighboring objects, shadows, or cut-off edges.
  • Use a flat solid chroma-key background for local alpha removal.
  • Do not include checkerboard backgrounds, Photoshop UI, labels outside the object, or watermarks.

The script creates a project under:

~/.codex/skills/gpt-image2-layered-psd/projects/YYYYMMDD_slug/
  input/source.png
  process_notes.md

The bundled layerizer creates:

~/.codex/skills/gpt-image2-layered-psd/projects/YYYYMMDD_slug_from_generation/
  elements_contact_sheet.png
  elements_cropped/
  layer_sources/
  output.psd
  output.preview.png
  manifest.json
  validation_report.json
  psd_full_canvas_layers.zip

Optional JSON Requirement Pattern

Only use JSON instructions when generating a new source image or when the user gives explicit decomposition preferences. For uploaded images, treat the image as the source of truth:

{
  "canvas": {
    "orientation": "vertical",
    "size": "1024x1536",
    "background": "transparent-friendly layered design"
  },
  "subject": "main product or scene",
  "text": [
    {"role": "headline", "content": "Exact headline text"},
    {"role": "subtitle", "content": "Exact subtitle text"},
    {"role": "badge", "content": "Offer badge text"}
  ],
  "style": {
    "palette": ["#007AFF", "#1C1C1E", "#FFFFFF"],
    "mood": "clean, premium, ecommerce-ready"
  },
  "layering": [
    "separate background, main subject, title text, badges, icons, foreground decorations, and shadows",
    "avoid merged text-on-background areas where possible",
    "keep strong visual separation between elements"
  ],
  "constraints": [
    "preserve all requested text exactly",
    "no fake Photoshop UI in the final artwork",
    "design for later PSD decomposition"
  ]
}

Quality Rules

  • Start from the uploaded image when one is provided. Do not replace it with a newly generated image unless the user explicitly asks for redesign/regeneration.
  • Do not claim the image API itself returns native PSD unless the actual response contains a PSD file. This skill creates PSD through post-processing and PSD assembly.
  • Treat text layers as raster layer candidates unless a downstream process reconstructs editable Photoshop text separately.
  • Do not present an occluded visible-pixel cutout as a complete standalone element. If the source hides part of an element, either reconstruct it or label the output as visible-only.
  • Do not assemble the final PSD immediately after extraction. Always stop at the contact-sheet/element-review stage and ask for confirmation first.
  • After PSD assembly, show the preview and treat the PSD as a candidate until the user accepts it. If the user says the generated file is not the desired result, delete that candidate PSD, preview, manifest, saved layer PNGs, and zip outputs automatically; keep only previously confirmed source elements.
  • Do not make the user repeatedly review unverified candidates. Before showing a PSD candidate, inspect the single layers and the composite yourself. If it fails the user's stated criteria, delete it and continue improving it.
  • Do not include duplicate semantic elements in the final set. For each object choose one final layer: source-faithful visible cutout, repaired complete element, or reconstructed clean element.
  • When assembling PSD files for Photoshop, ensure the background layer is written and displayed at the bottom of the layer stack. Opening the PSD must not show a white/background layer covering all other layers.
  • If exact text fidelity matters, keep text short, large, and high contrast, then verify output.preview.png.
  • Keep decomposition honest: report merged areas, uncertain text, missing transparency, or element changes from validation_report.json.
  • If transparent layer extraction fails or changes content, report the limitation from validation_report.json.

References

Read references/api-and-prompting.md when adjusting parameters, adding provider-specific fields, or refining the JSON prompt strategy.

Полный текст лицензии (MIT)
MIT License

Copyright (c) 2026 JongLeePc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.