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

Opening a PSD file throws "invalid typed array length" error #40

Closed
nedpals opened this issue Jul 21, 2022 · 5 comments · Fixed by #42
Closed

Opening a PSD file throws "invalid typed array length" error #40

nedpals opened this issue Jul 21, 2022 · 5 comments · Fixed by #42

Comments

@nedpals
Copy link

nedpals commented Jul 21, 2022

I'm trying to open a PSD file i haved created from Photopea into the demo and after selecting the file, the preview did not worked and instead the demo threw an error:

image

When dissecting the stack trace, it leads me to this code which is in line 253 254:
image

Hope it helps 😉 hoping to use it for a project

@nedpals nedpals changed the title Opening a PSD throws "invalid typed array length" error Opening a PSD file throws "invalid typed array length" error Jul 21, 2022
@dlehdanakf
Copy link
Member

If it is not a security problem, can you attach the PSD file that caused the problem?

@nedpals
Copy link
Author

nedpals commented Jul 27, 2022

@dlehdanakf Sure thing: https://we.tl/t-G2lVvra3Uj

There are two files in that zip: test.psd and test2.psd

Here's test.psd
image

Here's test2.psd . This is just a modified version of test.psd that is parseable by the package.
image

image

What I found when scrutinizing the test.psd file is that when I delete the gradient layer, the library has managed to parse it successfully.

Hope it helps 😃

@pastelmind
Copy link
Collaborator

Thank you. It appears that the gradient fill layer does not contain any image data--I assume that Photoshop synthesizes the image on the fly when I open the PSD file--and we weren't prepared for such an edge case.

I'm pushing a fix that renders the layer as an empty 1x1 image. It's not ideal, but synthesizing the gradient fill is currently beyond our goals.

@nedpals
Copy link
Author

nedpals commented Jul 28, 2022

@pastelmind No worries! Atleast it doesn't throw an error now 😄 Great job btw

@chao-mu
Copy link

chao-mu commented Apr 28, 2024

I think there might be a regression of this fix readLayerRecordsAndChannels.ts. readLayerRecordsAndChannels is failing with a RangeError again and it looks like the code may not longer account for this case. Unfortunately I do not have access to photoshop to further debug this issue. Let me know and I can send you a reproduction, but I can't post publically.

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

Successfully merging a pull request may close this issue.

4 participants