Merge pull request #8464 from dotCooCoo/fix/psd-knockout-layers-merge

PSD import: a layer with a knockout merges with the layers below it in its group
This commit is contained in:
BFlat
2026-11-19 21:01:03 +07:00
committed by GitHub
4 changed files with 1075 additions and 103 deletions
+17 -6
View File
@@ -10465,8 +10465,8 @@ clipping mask into one layer and discards hidden layers that require merging; th
imports one image, and Import Hidden Layers brings hidden layers in. `document.open` does the same, with
`layers: false` for the single image and `hiddenLayers: true` for the hidden layers. The page also merges
adjustment layers, layers with a knockout option, and layers that hold transparent pixels in some blend modes with
the layers below them. `document.open` applies neither adjustments nor knockouts, and it merges a layer by its blend
mode alone, as the rules below say.
the layers below them. `document.open` does not apply adjustments, applies only shallow knockouts inside groups, and
otherwise merges a layer by its blend mode alone, as the rules below say.
The rest are VectorCraft's own rules:
@@ -10486,6 +10486,12 @@ The rest are VectorCraft's own rules:
mask.
- A Dissolve layer's partly transparent pixels are merged as opaque or transparent, opaque at the share of its
pixels their transparency gives, in a fixed pattern that differs from layer to layer.
- A layer or group inside a group with a Knockout value of 1 (shallow) is merged with the visible layers below it
in that group: where it has pixels, shaped by its layer mask, they are cleared to transparency, it is drawn there
at its fill opacity, and its opacity fades the result back toward them. In a Pass Through group this applies only
when it and the visible layers below it are in Normal mode. A knockout at 0 opacity, one that draws nothing, one
with nothing visible below it, and one at 0 fill that covers none of their painted pixels are not merged for the
knockout; one in a mode VectorCraft lacks is still merged by its mode.
- A merged layer is named after the layers it holds, joined with ` + `.
- A layer name the file stores only as a one-byte Pascal string, without its Unicode name, is read as Mac Roman.
- A layer's opacity is multiplied by its fill opacity, in every blend mode. A layer that others are clipped to keeps
@@ -10497,16 +10503,21 @@ The rest are VectorCraft's own rules:
(RGB, CMYK, Grayscale, Lab or HSB) over the canvas. One whose shape is a vector mask isn't drawn, and the layers
clipped to it are left out.
- Adjustment layers, fill layers that store no pixels and whose fill isn't read, layer effects that are switched on,
knockouts and vector masks are not applied; the `warnings` count them.
the other knockouts (top-level layers, clipped layers, layers that others are clipped to, Pass Through groups with
layers in other modes, other Knockout values, and merges that need more memory than allowed) and vector masks are
not applied; the `warnings` count them.
- Layer channels may be raw, PackBits or zipped (with or without prediction) at 8, 16 and 32 bits.
- A file without layers opens as its merged image. A file whose layers can't be read opens as its merged image
with a warning, and when the merged image can't be read either, the file is refused with an error.
Each layer's pixels must fit the memory allowed for one image, and the pixels of all the layers and masks, with the
canvases the merges make, must together fit eight times that; a file past either limit opens as its merged image,
with a warning. The canvases one step of a merge holds at once must also fit the memory allowed for one image; when
they don't, the layer that needed the merge comes in alone, with a warning: in the Normal mode, or as a layer of its
own instead of clipped.
with a warning. A merge being tried may use the whole of that limit beyond what was read before it. The pixels and
canvases of merges that aren't made, including knockouts that turn out to cut nothing, then count against a second
limit of the same size instead. The
canvases one step of a merge holds at once must also fit the memory allowed for one image; when they don't, the
layer that needed the merge comes in alone, with a warning: in the Normal mode, as a layer of its own instead of
clipped, or without its knockout.
```json
{"name":"run_command","arguments":{"command":"document.open","params":{"path":"/tmp/poster.psd","hiddenLayers":true}}}