layervault / psd.rb

Parse Photoshop files in Ruby with ease
MIT License
3.12k stars 207 forks source link

not clipping to document size when rendering layers #77

Open catmando opened 10 years ago

catmando commented 10 years ago

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.

meltingice commented 10 years ago

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)
catmando commented 10 years ago

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.