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

Not Able to read PSD in Adobe UXP developer environment #219

Open
vishesh-rocketium opened this issue Jan 22, 2025 · 2 comments
Open

Not Able to read PSD in Adobe UXP developer environment #219

vishesh-rocketium opened this issue Jan 22, 2025 · 2 comments
Assignees

Comments

@vishesh-rocketium
Copy link

I tried to read PSD with select options :

const psd1 = readPsd(psdBuffer
  , {
  useRawThumbnail: true,
  useImageData: true, 
 });

getting these errors :

Image

Mostly I think it doesn't have access to a fully featured Canvas in UXP environment . Any way to fix this ?

@Agamnentzar
Copy link
Owner

Agamnentzar commented Jan 22, 2025

It seems that the proper <canvas> element is not available in your environment. Even when you use useImageData: true the library is still using canvas to create ImageData object so it's possible to use layer.imageData to populate <canvas> element. But you can work around that, call this function before any readPsd calls:

initializeCanvas(
    (width, height) => { throw new Error("not supported"); }, // not needed
    undefined, // not needed
    (width, height) => ({ width, height, data: new Uint8ClampedArray(width * height * 4), colorSpace: "srgb" })); // this will manually create ImageData object

@Agamnentzar Agamnentzar self-assigned this Jan 22, 2025
@vishesh-rocketium
Copy link
Author

Working now with this , thanks a lot @Agamnentzar

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

2 participants