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

Empty PNG File with "TypeError: pxData.copy is not a function" (pngjs/lib/filter.js:213) #4

Open
artisan-digital opened this issue Feb 21, 2017 · 6 comments

Comments

@artisan-digital
Copy link

artisan-digital commented Feb 21, 2017

Hi, I'm new to nodejs, long time on Debian/Ubuntu.

This is on Ubuntu Trusty 14.04.5 LTS.

I installed nodejs 6.9.5-1nodesource1~trusty1 from the trusty repository at https://deb.nodesource.com/node_6.x according to the instructions at https://nodejs.org/en/download/package-manager/.

Then I installed psd with:

sudo npm install -g psd-cli

And received this output:

$ psd -c PATIENT\ PHOTO1.psd 

Processing PATIENT PHOTO1.psd ...
/usr/lib/node_modules/psd-cli/node_modules/pngjs/lib/filter.js:213
        pxData.copy(rawData, rawRowLength * y + 1, pxRowLength * y, pxRowLength * (y + 1));
               ^

TypeError: pxData.copy is not a function
  at Filter._filterNone (/usr/lib/node_modules/psd-cli/node_modules/pngjs/lib/filter.js:213:16)
  at Filter.filter (/usr/lib/node_modules/psd-cli/node_modules/pngjs/lib/filter.js:196:27)
  at Packer.pack (/usr/lib/node_modules/psd-cli/node_modules/pngjs/lib/packer.js:54:23)
  at .<anonymous> (/usr/lib/node_modules/psd-cli/node_modules/pngjs/lib/png.js:68:22)
  at _combinedTickCallback (internal/process/next_tick.js:67:7)
  at process._tickCallback (internal/process/next_tick.js:98:9)

$

I hope there is some missing package or library that I can install.

Thanks.

@artisan-digital artisan-digital changed the title Get Empty PNG File. "TypeError: pxData.copy is not a function Empty PNG File with "TypeError: pxData.copy is not a function" (pngjs/lib/filter.js:213) Feb 21, 2017
@kartsims
Copy link
Owner

Could you please provide the PSD file ?

This seems to be an issue with NPM's psd library that uses an outdated version of pngjs (uses ~0.4.0,latest is 3.0.1)

See this open issue for details

@kartsims
Copy link
Owner

fix might be to install latest pngjs as a dependency to psd-cli but I would need to reproduce the bug...

@artisan-digital
Copy link
Author

I agree the problem seems very similar to the other referenced issue.

The psd file is 288k in size. I attempted to attach the psd file but the github issue page doesn't allow that file type. Please advise on where/how you would like me to transmit the file.

Thank you.

@kartsims
Copy link
Owner

kartsims commented Mar 1, 2017

You may send it to me directly kartsims@gmail.com

Thanks

@kartsims
Copy link
Owner

kartsims commented Mar 1, 2017

I have tried forking psd.js to update pngjs, according to the issue linked, but it didn't work for me. I left a comment there, but not sure if I'll get an answer, it's pretty old.

Installing pngjs as a dependency to psd-cli didn't work either as it is used by psd.js (I should have figured that...)

I looked around for forks that would have an updated dependency to pngjs but didn't find any. There are plenty of libraries out there, but there doesn't seem to be any that would be fully compliant and support all PSD files... Seems that not many people do PSD in Node :/

I tried adding an imagemagick fallback but I can't even catch the error ! The psd.image.saveAsPng function is async but just crashed instead of returning an error...

I tried using pngjs directly to use the Buffer output by PSD.js but couldn't parse it, throws an error.

I don't know what else to try... If you have any suggestions, I am open to it.

@kartsims
Copy link
Owner

kartsims commented Mar 1, 2017

In case anyone is interested in following this issue, I put up a branch pngjs with my tests, that intends to bypass PSD.js's use of the pngjs module.

I feel like I am not far but can't finish.

https://github.com/kartsims/psd-cli/compare/pngjs?expand=1

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