y-a-v-a / node-gd

🎨 GD graphics library (libgd) C++ bindings for Node.js.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing .png encoded as .jpg does not throw error

bsansone opened this issue · comments

Was sent a .jpg image, needed it .png. When downloading the image from Gmail, set format to All Files:

screen shot 2017-09-12 at 3 38 27 pm

Changed extension from .jpg to .png:

screen shot 2017-09-12 at 3 38 35 pm

Having been passing this file which I assumed to be a .png into gd.openPng(), when the img being passed gets to the next method it's used by img.colorAllocate() received error:
"Cannot read property 'colorAllocate' of null". Took me awhile to come to the conclusion it was originally a .jpg that had its extension changed and gd.openPng() couldn't read it because it wasn't encoded as a .png.

Hi thanks for reaching out and sorry for my late reply.
I could see if it's possible to do a check wether there's actually image data to act upon when someone tried to open e.g. a jpg with gd.openPng().
I understand from your comment you would have preferred to be informed earlier that the assumed png is not a png, right?
I'll see what I can do in the upcoming weeks.
🍻 Cheers! Vincent

I also just spent half an hour trying to figure why loading my png was coming up null (it was a jpg I saved at a .png)