EyalAr / lwip

Light Weight Image Processor for NodeJS
MIT License
2.37k stars 230 forks source link

Getting "Invalid PNG buffer" for a valid image #229

Open IonicaBizau opened 8 years ago

IonicaBizau commented 8 years ago

The image is valid, but lwip can't understand it. Where should we start debugging?

IonicaBizau commented 8 years ago

:bell: @EyalAr

EyalAr commented 8 years ago

Can you please upload the original image?

Otherwise I'd try to open this image with libpng's example program.

IonicaBizau commented 8 years ago

@EyalAr I uploaded it here (note I will remove it once the issue is fixed or obsolete).

gcemaj commented 8 years ago

This is still happening, any idea what the fix is/was? what to do?

IonicaBizau commented 8 years ago

@gabox8888 I think it's still an issue... @EyalAr :bell:

IonicaBizau commented 8 years ago

@EyalAr :bell: Please....!

acoyfellow commented 8 years ago

I can confirm this is happening with perfectly valid .PNG's.

IonicaBizau commented 8 years ago

Just a little update: in my case, it was a JPG file, with the png extension.

@acoyfellow Double check if your image is really a PNG file or it's just a valid image but with a wrong extension. Some programs may display it correctly, but when parsing it you must specify the type.

acoyfellow commented 8 years ago

@IonicaBizau thanks for the tip. I did realize that was happening for some cases.

But I still get this error with iOS generated .PNG files from screenshots, when uploading files via fetch (using React Native).

Edit: Yeah, weird iOS specific bug I suppose. Screenshots are saved in camera roll as .PNG's, but lwip throws invalid PNG buffer. I rename the file to jpg, and it works. I suppose this has nothing to do with lwip.

Thank you very much for all the hard work all contributors have put in. <3

ChristianRich commented 8 years ago

I can confirm that changing the affected PNG's file extension to jpg indeed fixes the problem.

IonicaBizau commented 8 years ago

But still, lwip should be smart enough to detect the image buffer type (and not by using the extension).

ChristianRich commented 8 years ago

@IonicaBizau That would certainly be a nice feature, that the type is determined not by the file extension but the header. Still I find the workaround perfectly acceptable. As long as you can intercept the error and handle it I'm fine.