gomfunkel / node-exif

A node.js library to extract Exif metadata from images.
MIT License
581 stars 104 forks source link

Out-of-memory issues with certain jpegs #5

Closed cianclarke closed 10 years ago

cianclarke commented 12 years ago

Hi - I've created a node-gallery component ( http://www.github.com/cianclarke/node-gallery), but users (me included) have been having trouble with certain JPEG's. I'm not sure if it's invalid EXIF, or just 'different' EXIF, but it causes unfortunate out of memory issues - as per https://github.com/cianclarke/node-gallery/issues/2

I've made a fix myself, as per here: https://github.com/cianclarke/node-exif/blob/master/lib/exif/ExifImage.js#L149 and here: https://github.com/cianclarke/node-exif/blob/master/lib/exif/ExifImage.js#L168 but it's pretty woeful. A proper fix & publish to NPM would be great!

cianclarke commented 12 years ago

http://dieter.plaetinck.be/files/tekoop/meubels_interieur/ikea_kastje.jpg here's an image where this occurs

gomfunkel commented 11 years ago

I just made some changes that hopefully fix your issue. Could you please try again with the latest version (not on npm yet) and post your results?

bwindels commented 11 years ago

Hi, the same issue was bothering me, and thanks for providing a fix, but it's not working for me. Now I get this error on the first jpg I am parsing:

TypeError: Object # has no method 'push' at ExifImage.extractExifData (/Users/bwindels/node_modules/exif/lib/exif/ExifImage.js:251:28) at ExifImage.processImage (/Users/bwindels/node_modules/exif/lib/exif/ExifImage.js:102:25) at ExifImage.loadImage (/Users/bwindels/node_modules/exif/lib/exif/ExifImage.js:61:8) at new ExifImage (/Users/bwindels/node_modules/exif/lib/exif/ExifImage.js:43:8)

bwindels commented 11 years ago

Ok, when trying to fix that issue by replacing line 251 with

this.exifData.makernote.error = { error: 'Unable to extract Makernote information as it is in an unrecognized format.' } ;

I get the error: No Exif segment found in the given image.

gomfunkel commented 11 years ago

The first error is now fixed.

What about the second error you posted? Is there really no Exif data available in the image and the error message thus correct, or is it available and there is another bug. In the latter case please provide the image for testing purposes.

bwindels commented 11 years ago

Hey, sorry for not getting back to you. Can't remember the specifics on your question about the second image, sorry. I've written an exif parser myself and continued with that, because I found it hard to try to fix issues myself and add functionality on this library. It is at https://github.com/bwindels/exif-parser if you are interested. I've referenced you in the LICENSE since I was only able to write the code after extensively reading yours and also reusing your tag list.

Best regards, Bruno

cianclarke commented 11 years ago

@gomfunkel I haven't revisited my node gallery project in many months - but none the less, thanks for taking the time to fix this issue, and my apologies for not replying to your original comments above!

fjhub commented 10 years ago

I ran into the following memory error for a jpeg file: FATAL ERROR: JS Allocation failed - process out of memory.

I believe that the error was in the section 'EXIF IFD' because if I disabled this portion of the code, it parsed fine. I think the image had some adobe meta data associated with it...but I'm not sure because it isn't my image. I'll try to see if I can get permission from the owner to see if it is ok to distribute the image.

gomfunkel commented 10 years ago

Any luck on getting permission from the image owner, @fjhub?

As the other problems of this issue seem to be fixed I'm closing this one now. Please open a new ticket when you are able to provide a test image. Thanks!

fjhub commented 10 years ago

I never got permission from the owner because he pulled the image off the net and didn't remember where he got it. I tracked down another image which I pulled from: http://windows.microsoft.com/en-ie/windows/colors-india-download-theme

I have 2 different versions of an image from this site, one of which crashes 0.3.3 and the other which works fine. I just upgraded to the latest and both images process fine. The one which crashes (pepperV2) appears to not have a thumbnail. I've included them here.

pepperv2_1920x1200 pepperv1_1920x1200

And many thanks for addressing these issues...muchly appreciated!

gomfunkel commented 10 years ago

Thanks for the yummy example chilis. I couldn't reproduce the out of memory issues with the latest version either so I'm closing this issue. If you run into further errors, please open a new issue. Thanks!