ag-psd
ag-psd copied to clipboard
transform data not correct?
I am trying to retrieve transform data from a .psd file.
Most coordinates seem fine, but two of the bottom coordinates are off.
This is the shape that I made with perspective distortion on Photoshop and the following is the transform data I got with ag-psd.
placedLayer: {
id: '1e83f0b1-d71c-11e5-b1ae-a548a96e5f9f',
placed: 'de965410-d71c-11e5-b1ae-a548a96e5f9f',
type: 'raster',
transform: [
1603,
1765.9999999999998,
2154.9999999999995,
1765.9999999999998,
2675.1113560692606,
3886.585932876441,
2123.111356069261,
3886.585932876441
],
width: 552,
height: 1278,
resolution: { value: 72, units: 'Density' },
warp: {
style: 'none',
value: 0,
perspective: 0,
perspectiveOther: 0,
rotate: 'horizontal',
bounds: [Object],
uOrder: 4,
vOrder: 4
}
top left x:1603, y:1765
top right x: 2154, y: 1765
are right, but then way off.
Am I looking at the wrong ones or there's something wrong with it?
hmm, not sure what's happening here, can you send PSD file that give this wrong results?
Should I send it to your email?
Sure, or just include here if you can
This is what github is saying. Just sent it to your email now.
This is the code I wrote to get the transform data.
import * as fs from 'fs';
import 'ag-psd/initialize-canvas.js';
import { createRequire } from 'module';
import { readPsd } from 'ag-psd';
const psdDATA = readPsd(buffer);
console.log(psdDATA.children[1].placedLayer.transform)
It seems like to be working as long as the shape is in a square shape because it still gets it right with rotated square, but it only gets weird when I perspective distort shape.
Updated in version 14.3.2
Added nonAffineTransform
field to placedLayer
, it seems photoshop uses this extra field when transform are non affine (like perspective transform) not sure what the regular transform
field is holding in that case.
AWESOME!! It works perfectly now!! :)
I am so sorry to bother. I do see the nonAffineTransformData, but I do not see the vectorMask.paths.knots
that I used to see for warp transform. Here is the reference link that I asked before.
There are two transform data that I can see now: transform
and nonAffineTransform
. However, neither of them have 16 points that it used to hold.
Is there a way that I can get the 16 transform coordinates?
Thanks!
Can you send me a file that is read incorrectly ?
I do see some 16 points in placedLayer.customEnvelopeWarp.meshPoints
, but they don't seem to be representing the 16 points of warp transformation in Photoshop like it used to.
Ok, so so far I figured out that the points are in this order
And they're all relative to the first point, which is set to (0, 0)
I'm still not sure how the whole thing is positioned though, somehow that (0, 0) point is ending up at it's correct position, it might be some combination of transform and maybe some other value somewhere
So the points I found are actually the 16 points representing the shape of “transform warp” that I created in Photoshop, but they are just relative to the very first point assuming it is at (0,0)
I am having a hard time finding the actual coordinate of this "(0,0)"
Do you, by any chance, know where it is located?