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

Wrong Sizes of layer

Open lordminor opened this issue 8 years ago • 5 comments

Hi, first of all thanks for made this great tool :)

I recently find out that the sizes and coords of the layers are wrong. The main problem are the coords (left, top, bottom, right) because you get the width and height with that info. In some layers you will have 3px wrong in others 4px and others 1px or no error. Is a kind of weird.

Anyone has a solution for it? I tested with a lot of files, and different versions of photoshop and the issue still happen.

An example: a layer that in photoshop has top: 130, left:50, bottom: 220, right 110 , this plugin return this info when is parsing : top: 128, left: 48, bottom: 221, right: 112.

The main problem is not all the layers has the same difference, so you can't made a function or simply subtract the appropriate number.

Thanks for the help!

lordminor avatar May 01 '16 22:05 lordminor

Any chance your layers are extending beyond the visible canvas? Photoshop will record the coordinates regardless of whether they're actually visible.

Ryan LeFevre (@meltingice) Sr. Software Engineer HODINKEE

On Sun, May 1, 2016 at 3:31 PM -0700, "lordminor" [email protected] wrote:

Hi, first of all thanks for made this great tool :)

I recently find out that the sizes and coords of the layers are wrong. The main problem are the coords (left, top, bottom, right) because you get the width and height with that info. In some layers you will have 3px wrong in others 4px and others 1px or no error. Is a kind of weird.

Anyone has a solution for it? I tested with a lot of files, and different versions of photoshop and the issue still happen.

An example: a layer that in photoshop has top: 130, left:50, bottom: 220, right 110 , this plugin return this info when is parsing : top: 128, left: 48, bottom: 221, right: 112.

The main problem is not all the layers has the same difference, so you can't made a function or simply subtract the appropriate number.

Thanks for the help!

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

meltingice avatar May 01 '16 22:05 meltingice

nop. The layers are centered. I tried with webpage mockups for example. maybe one rectangle has right coords, others don't. I spent a few days trying to fix that but I couldn't :( . If you have some layer outside the canvas, you will see left:-24 for example. But also, that coords are in some cases 1 or 2 px wrong.

lordminor avatar May 01 '16 22:05 lordminor

any solution for that? It happens on layers with x and y coords which are floats. in parsePositionAndChannels, the section of: this.top = this.file.readInt(); this.left = this.file.readInt(); this.bottom = this.file.readInt(); this.right = this.file.readInt();

gives back those wrong values, maybe because it is parsed as int?

tomermes avatar Apr 28 '17 05:04 tomermes

this seems to be still happening ? children: [ { type: 'layer', visible: true, opacity: 1, blendingMode: 'normal', name: 'Rectangle 1', left: 734, right: 1186, top: 314, bottom: 766, height: 452, width: 452, mask: {}, text: undefined, image: {} } ] }, is the output of the js https://i.gyazo.com/thumb/1200/ffebaafb0a9ab239dc729e73ffeb154a-png.jpg is the actual size

edit, seems to only happen with grouped layers.

Leigham avatar Dec 31 '18 00:12 Leigham

Just bumping this as I am still seeing this issue

andomain avatar Aug 19 '22 10:08 andomain