ag-psd icon indicating copy to clipboard operation
ag-psd copied to clipboard

transform data not correct?

Open DOEHOONLEE opened this issue 3 years ago • 12 comments

I am trying to retrieve transform data from a .psd file.

Most coordinates seem fine, but two of the bottom coordinates are off.

Screen Shot 2021-09-14 at 8 23 05 AM

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?

DOEHOONLEE avatar Sep 13 '21 23:09 DOEHOONLEE

hmm, not sure what's happening here, can you send PSD file that give this wrong results?

Agamnentzar avatar Sep 13 '21 23:09 Agamnentzar

Should I send it to your email?

DOEHOONLEE avatar Sep 13 '21 23:09 DOEHOONLEE

Sure, or just include here if you can

Agamnentzar avatar Sep 13 '21 23:09 Agamnentzar

This is what github is saying. Just sent it to your email now.

Screen Shot 2021-09-14 at 8 47 41 AM

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)

DOEHOONLEE avatar Sep 13 '21 23:09 DOEHOONLEE

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.

DOEHOONLEE avatar Sep 13 '21 23:09 DOEHOONLEE

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.

Agamnentzar avatar Sep 14 '21 00:09 Agamnentzar

AWESOME!! It works perfectly now!! :)

DOEHOONLEE avatar Sep 14 '21 05:09 DOEHOONLEE

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!

DOEHOONLEE avatar Sep 24 '21 07:09 DOEHOONLEE

Can you send me a file that is read incorrectly ?

Agamnentzar avatar Sep 24 '21 15:09 Agamnentzar

smile.psd.zip

Screen Shot 2021-09-26 at 4 47 36 PM

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.

Screen Shot 2021-09-26 at 4 41 57 PM

DOEHOONLEE avatar Sep 26 '21 07:09 DOEHOONLEE

Ok, so so far I figured out that the points are in this order image 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

Agamnentzar avatar Sep 26 '21 15:09 Agamnentzar

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?

DOEHOONLEE avatar Sep 27 '21 01:09 DOEHOONLEE