psd.rb icon indicating copy to clipboard operation
psd.rb copied to clipboard

not clipping to document size when rendering layers

Open catmando opened this issue 11 years ago • 2 comments

Lets say you have a psd in which one layer has an image extending outside of the document clipping area. (for example a 4 X 6 document, but a layer is 8.5 X 11)

If you render a comp it clips just fine, but if you render a layer (or group) it does not clip.

Not sure if this is a feature or a bug.

If a feature how could we turn it off.

Specific code looks something like this

psd.tree.filter_by_comp("front").children_at_path("background").first.save_as_png("...path...")

I am guessing that somehow the renderer distinguishes between rendering a layer and rendering the entire tree, and only if rendering the tree applies the document clipping mask.

catmando avatar Oct 22 '14 19:10 catmando

Yeah, this is currently the intended result. Rendering a single layer simply outputs the image data Photoshop has stored for that layer. Clipping the layer based on the document is something that will have to be added.

This could be passed as an additional argument to to_png or save_as_png. Something like:

psd.tree.filter_by_comp("front").children_at_path("background").first.save_as_png("...path...", clipped_by_document: true)

meltingice avatar Oct 22 '14 20:10 meltingice

hey that's great, if you can give me a rough outline of how to do this, I will do a fork, and implement and test...I looked through the code, and it was not obvious at where render was distinguishing between a layer and a whole comp.

catmando avatar Oct 22 '14 20:10 catmando