Skip to content

Export Layer As… opens the Export As sheet for the one selected layer, trimmed to its pixels, named after it - #328

Closed
Garfielk wants to merge 1 commit into
robbietilton:mainfrom
Garfielk:export-layer-as
Closed

Garfielk wants to merge 1 commit into
robbietilton:mainfrom
Garfielk:export-layer-as

Conversation

@Garfielk

@Garfielk Garfielk commented Nov 2, 2026

Copy link
Copy Markdown

Summary

The Layers panel's right-click menu already has a quick PNG export; this adds the full Export As sheet for a single layer, as the File menu has for the canvas:

  contextMenu(for row:)                       (UI/NativeLayerList.swift)
    Export Layer(s) as PNGs…
+   Export Layer As…                          (one selected layer)
      ProjectController.exportLayerAs()
        ImageExporter.layerExportRasters()    (IO/ImageExporter.swift)
          render(isolating(id, in: snapshot)) → trim rect → crop
          + 16-bit / HDR flattenings cropped to the same rect
        ExportAsSheet(raster:, deepRaster:, hdrRaster:, snapshot: nil)
          formats: JPEG · PNG · TIFF · PDF, EXR with HDR pixels
          (no GIF, no Channel Pack)
        savePanel(for:, named: layer.name) → ImageExporter.write

layerExportRasters is shared by the existing layerPNGData, so both exports trim through one path. An empty or adjustment layer alerts "has nothing to export"; several selected layers grey the new item out and keep the batch PNGs flow.

Evidence

  • Before: right-click gave only the fixed-format PNG export (0673a4a).
    After: xcodebuild build succeeds, and LayerExportTests passes 3/3, including the new layerExportRastersTrimToItsPixelsAndDepthFollows:
Test case 'LayerExportTests/layerExportRastersTrimToItsPixelsAndDepthFollows()' passed
Test case 'LayerExportTests/eachLayerExportsOnItsOwnTrimmedToItsPixels()' passed
Test case 'LayerExportTests/layerNamesBecomeFileNames()' passed
  • Full unit suite via scripts/ci-tests.sh: first, rest, windows and filters all passed.

Merge Danger

Door: two-way — additive menu item, sheet flow mirrors the canvas's; revert is a clean revert of one commit.

Blast Radius: export path only. layerPNGData's trim now goes through layerExportRasters, covered by its existing tests; project save, canvas export and the batch layer export are untouched.

@robbietilton

Copy link
Copy Markdown
Owner

Thanks for putting this together, and for the thorough write-up and tests!

The next release, out later today, adds right-click › Export Layer(s) as PNGs… in the Layers panel: each selected layer saved as its own PNG, trimmed to its pixels and named after the layer. That matches how Photoshop handles layer export, which is what most people are used to, so I'd like to keep layer export to that one item for now rather than add a second one beside it.

That said, I'm curious what you're trying to achieve with the full Export As sheet for a layer. Is it a particular format (JPEG, TIFF, EXR), quality or size settings, or something else? If there's a workflow the trimmed PNG doesn't cover, I'd love to hear about it, and we can figure out the best way to fit it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants