Layer bounds is incorrect in some situation

I got a .psd file from my user, and the bounds of one layer is wrong.

this layer has 1px outside stroke effect, but the bounds is not equal to boundsNoEffects plus 1px stroke。

I’m not sure if this is a bug

How Can I get correct bounds with effects? is bounds untrustworthy?

by the way: I did not find where to upload attachments to this topic

this layer is a pixel layer(kind=1)

Bounds are always shown in full pixels. However, the stroke effect doesn’t seem to occupy exactly one pixel always - it depends on how soft the edge of your layer is. Here’s an example with two circles that have the same size, but one has a softer edge (semi-transparent pixels):

In this example, both layers have a stroke effect of 1px, the one on the left is clearly wider than 1px though.
Logging the bounds / boundsNoEffects of the left one, I’m getting the same results as you (difference of 3px).

Thank you Simon, as you say, this seems to be a feature rather than a bug.
but I still have a little problem.
can you show me how to create ‘soft edge’ shape and ‘sharp edge’ shape? this allows me to avoid this scenario and give correct tips to my users.

That depends on the type of layer or tool you’re using.
The brush tool is designed to have somewhat soft edges, even if you turn the brush hardness all the way up. All shape tools (for example the ellipsis tool) or the pencil tool will create more sharp results.
If you’re dealing with an image for example, it can happen to have a soft edge if it has been transformed before. What helps there is to duplicate the layer several times and then merge it into one again.

1 Like