DEV Community

Super Lewis
Super Lewis

Posted on

Photoshop's Pen Tool Is Done: How AI Splits a Flat Image into Layers

Originally published on the LayerGrab blog. Disclosure: I build LayerGrab, an AI tool that splits images into layers; this post was drafted with AI assistance and edited by me.

Separating a flat image into layers used to be the one job you could not hand off: Pen tool, Layer via Copy, Content-Aware Fill, repeat for every element. Image layer decomposition is the AI task that does it in one pass: a model takes a flat RGB image and returns a stack of RGBA layers, one per element, with the regions behind each element filled in so the layers recompose into the original.

Here is how it works, what we measured on a real poster today, and where it breaks.

What the model has to do

Three things at once, which is why this was hard until recently:

  1. Decide what the elements are. Not pixels by colour, but "headline", "badge", "cup".
  2. Cut each one out as RGBA with a usable alpha edge.
  3. Invent what was behind each element, because the camera or designer never stored it. Without this, moving a layer leaves a hole.

Segmentation models solve step 2 and inpainting models solve step 3. A decomposition model does all three, which is what makes the output a real layered file instead of cutouts on a broken background.

Running the open model: what we measured

Qwen-Image-Layered (Apache 2.0, weights released December 2025) is the open model for this. We ran it through fal's hosted API on an 880 × 1184 coffee shop poster on 2026-10-06. Example request, from fal's public docs:

# Example (fal queue API). FAL_KEY is your own key.
curl -X POST https://queue.fal.run/fal-ai/qwen-image-layered \
  -H "Authorization: Key $FAL_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_url": "https://example.com/poster.png", "num_layers": 4, "output_format": "png"}'
Enter fullscreen mode Exit fullscreen mode

What came back with num_layers: 4:

  • 4 PNGs, each 544 × 736, the full canvas size: the model works at around 640 px on the long side, and its README recommends that resolution.
  • Layer 1 was the fully opaque background; layers 2–4 were transparent everywhere except their element.
  • Text, the discount badge and three small leaves shared one layer; the cup got its own; one large leaf got its own.
  • Stacked back together, the layers matched the downscaled original with a 1.5% mean pixel difference.
  • 18.6 s of inference, 65 s end to end including the queue.

With num_layers: 2, the cup and headline stayed in the background layer, and the second layer held only the small decorations.

Pitfalls that decide whether the layers are usable

  • You choose the layer count, and it groups by depth, not by object. Too few layers and the main subject stays in the background. Start at 4–6.
  • Resolution drops. Expect ~640 px output. Upscale afterwards if you need print size.
  • VRAM. Users in the model's GitHub issues report failures on 16 GB cards and trouble on 24 GB; ComfyUI's guide measured a 45 GB peak at 1024 px.
  • Text is pixels. You get the headline on its own layer, not as editable type. Hide it and retype.
  • Hosted APIs bill per output image. fal charges per image returned, so 4 layers cost 4×.

When you don't want to run it yourself

LayerGrab is an AI tool that splits one image into up to 16 separate transparent layers, one per element, names each layer from what it shows, fills the background behind them, and exports PNG, ZIP or a layered PSD. On the same poster it returned 10 named layers in 100 seconds at the original resolution. It also runs Qwen-Image-Layered itself, with a free 2-layer try, if you want to compare: layergrab.com/qwen-image-layered-free.

Don't use it if your images must stay on your own machine: run the open model locally instead.

Is Photoshop dead?

As a finishing tool, no: we even ship a Photoshop plugin. As the place you go to cut a flat image apart by hand, yes. That job is now a model call.

Have you tried any of these models on real client work? I'm curious where the output broke for you.

Top comments (0)