Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crop layers to bounding box #1

Open
vpdn opened this issue May 20, 2014 · 1 comment
Open

Crop layers to bounding box #1

vpdn opened this issue May 20, 2014 · 1 comment

Comments

@vpdn
Copy link
Owner

vpdn commented May 20, 2014

Currently all layers are rendered in full size of the window, which makes the resulting psd unnecessarily big. The file is automatically trimmed by photoshop, but only after the user opens and resaves the file. We need to find a way to trim the whitespace out to make the PSD smaller and easier to transport via Email.

One way of doing it would be to:

  • Inspect the generated layer images and scan line by line. This has the advantage of detecting empty layers (i.e. layers with only transparent pixels), but will require image analysis on each layer.
  • A more elegant and efficient method would be to calculate the required layer bounds by recursing through the child layers and 'unioning' the layer rects. This however won't detect empty (transparent) layers

A combination of both might be the best approach.

@vpdn vpdn added this to the 0.1.1 milestone May 20, 2014
@vpdn vpdn modified the milestones: 0.1.1, 1.0.0 May 28, 2014
@vpdn vpdn mentioned this issue Jul 4, 2014
@nicolasgoutaland
Copy link
Contributor

Hi, did just make a PR on this.
My first optimization is on layer content. Layer are no longer rendered from there parent, but directly on them, and I did compute offset from parent layer
Generated PSD files size is divided by 3 to 4 with my tests.
Next step is to crop generated document size in

SFPSDWriter, - (SFPSDLayer *)addLayerWithCGImage:(CGImageRef)image andName:(NSString*)name andOpacity:(float)opacity andOffset:(CGPoint)offset

But all my tests did fail. Still working on it.

See PR #20

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

No branches or pull requests

2 participants