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

how to read the rotation of layer? #161

Open
dogeFu opened this issue Dec 14, 2023 · 2 comments
Open

how to read the rotation of layer? #161

dogeFu opened this issue Dec 14, 2023 · 2 comments
Assignees

Comments

@dogeFu
Copy link

dogeFu commented Dec 14, 2023

image

I read the readme_psd.md,failed to find where to get to rotaion of a layer,can you help me?

@Agamnentzar Agamnentzar self-assigned this Dec 14, 2023
@Agamnentzar
Copy link
Owner

I don't think this value is stored anywhere in PSD file, it's calculated back from the transform (placedLayer.transform) that specifies location of 4 corners of transformation cage.

@zms664011036
Copy link

zms664011036 commented Feb 23, 2024

hello, transform= [12391.430367826988, 1721.516648354885, 2447.364078652975, 8802.809486322956, -70.25686706304622, 5075.064425643115, 9873.809422110964, -2006.2284123249551];) The four corners, how to calculate the rotation Angle, can provide the code to calculate the Angle?

The following is my code, but the calculation will be a little error, can you help me to see what went wrong?

image

const angle = getAngle({
x: 0,
y: img.height,
}, {
x: transform[6] - transform[0],
y: transform[7] - transform[1],
});

function getAngle({x: x1, y: y1}, {x: x2, y: y2}) {
const dot = x1 * x2 + y1 * y2
const det = x1 * y2 - y1 * x2
const angle = Math.atan2(det, dot) / Math.PI * 180
return angle
}

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

No branches or pull requests

3 participants