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

Error writePsd on big file #206

Open
labsforge opened this issue Oct 23, 2024 · 1 comment
Open

Error writePsd on big file #206

labsforge opened this issue Oct 23, 2024 · 1 comment
Assignees

Comments

@labsforge
Copy link

Hi, I've pin-pointed this problem to when I call writePsd to get an ArrayBuffer or Buffer so I can finally write it to disk:

"RangeError: Array buffer allocation failed
    at new ArrayBuffer (<anonymous>)
    at resizeBuffer (http://localhost:4200/main.js:267873:19)
    at ensureSize (http://localhost:4200/main.js:267883:5)
    at writeBytes (http://localhost:4200/main.js:267382:5)
    at Object.write (http://localhost:4200/main.js:259576:74)
    at http://localhost:4200/main.js:267812:17
    at writeSection (http://localhost:4200/main.js:267477:3)
    at _loop_4 (http://localhost:4200/main.js:267811:7)
    at writeAdditionalLayerInfo (http://localhost:4200/main.js:267820:5)
    at http://localhost:4200/main.js:267595:5"

Everything works fine, but in this case the final file should end up with more than 1Gb.
I there a way to refactor the construction of the ArrayBuffer to be done in chunks?

Kind regards!

@Agamnentzar Agamnentzar self-assigned this Oct 23, 2024
@Agamnentzar
Copy link
Owner

I don't see any way to write file in chunks in browser: https://developer.mozilla.org/en-US/docs/Web/API/File so I'm not sure how adding chunked write api would help in this case. Reducing memory usage could potentially reduce this problem, but it doesn't guarantee that it will be fixed.

Other things that you can try: don't save thumbnail and composite image if you don't need them, they're not needed if you just plan on opening the file in Photoshop later. You can also try passing { compress: true } in writePsd options, it's still experimental feature though.

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