gomfunkel / node-exif

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

Crash when try to look for Makernote data #32

Open axvpast opened 10 years ago

axvpast commented 10 years ago

Library version: 0.4.0 Nodjs version: v0.10.29

Exception:

[some binary garbage] has no method 'getString'
    at ExifImage.extractExifData (/..../node_modules/exif/lib/exif/ExifImage.js:240:55)
    at ExifImage.processImage (/..../node_modules/exif/lib/exif/ExifImage.js:103:29)

Possible solution - add try/catch:

  /***************************** Makernote IFD *****************************/

  // Look for Makernote data in the Exif IFD, check which type of proprietary
  // Makernotes the image contains, load the respective functionality and
  // start the extraction
  if (typeof this.exifData.exif[ExifImage.TAGS.exif[0x927C]] != "undefined") {
      try {
          // Check the header to see what kind of Makernote we are dealing with
          if (this.exifData.exif[ExifImage.TAGS.exif[0x927C]].getString(0, 7) === "OLYMP\x00\x01" || this.exifData.exif[ExifImage.TAGS.exif[0x927C]].getString(0, 7) === "OLYMP\x00\x02") {
              this.extractMakernotes = require('./makernotes/olympus').extractMakernotes;
          } else if (this.exifData.exif[ExifImage.TAGS.exif[0x927C]].getString(0, 7) === "AGFA \x00\x01") {
              this.extractMakernotes = require('./makernotes/agfa').extractMakernotes;
          } else if (this.exifData.exif[ExifImage.TAGS.exif[0x927C]].getString(0, 8) === "EPSON\x00\x01\x00") {
              this.extractMakernotes = require('./makernotes/epson').extractMakernotes;
          } else if (this.exifData.exif[ExifImage.TAGS.exif[0x927C]].getString(0, 8) === "FUJIFILM") {
              this.extractMakernotes = require('./makernotes/fujifilm').extractMakernotes;
          } else if (this.exifData.exif[ExifImage.TAGS.exif[0x927C]].getString(0, 9) === "Panasonic") {
              this.extractMakernotes = require('./makernotes/panasonic').extractMakernotes;
          } else if (this.exifData.exif[ExifImage.TAGS.exif[0x927C]].getString(0, 5) === "SANYO") {
              this.extractMakernotes = require('./makernotes/sanyo').extractMakernotes;
          } else {
              // Makernotes are available but the format is not recognized so
              // an error message is pushed instead, this ain't the best
              // solution but should do for now
              this.exifData.makernote['error'] = 'Unable to extract Makernote information as it is in an unsupported or unrecognized format.';
          }
      } catch (any){
          this.exifData.makernote['error'] = 'Unable to extract Makernote information as it is in an unsupported or unrecognized format.';
      }
    if (typeof this.exifData.makernote['error'] == "undefined") {
      this.exifData.makernote = this.extractMakernotes(data, self.makernoteOffset, tiffOffset);
    }

  }

I am really sorry, bit I cannot attach image file which create such kind error because it contains some private date. So I can show only exif info after suggested fix:

{ image: 
   { Make: 'Nokia',
     Model: '300',
     Orientation: 1,
     XResolution: 300,
     YResolution: 300,
     ResolutionUnit: 2,
     Software: 'V 07.57',
     YCbCrPositioning: 1,
     ExifOffset: 152 },
  thumbnail: 
   { Compression: 6,
     XResolution: 300,
     YResolution: 300,
     ResolutionUnit: 2,
     ThumbnailOffset: 2466,
     ThumbnailLength: 4323 },
  exif: 
   { ExifVersion: [ 48, 50, 50, 48 ],
     DateTimeOriginal: '2014:07:25 07:14:19',
     CreateDate: '2014:07:25 07:14:19',
     ComponentsConfiguration: [ 1, 2, 3, 0 ],
     MakerNote: '\u0012$\u0010\bÀ\u0007\u0000\u0000{r\u0005~þŽ˜%êˆ÷½§‚ÔÖ+f$ÌÈS\u001c\u0000$¬3±\u0007¬÷Ó%4ª‘\u0003Bc•»Èô´¾tÐhÊögWuåÝh<Ù4(ov~U,\u000f•M§ì$Nàá\u0007ýÌ6©Šï¡\u001b‹ñÿ·Yú_ö8Š“ïÙãŒ_ Z\u0000Àͦ\u001d½€#;d\u001b\u0012¿Ìü5\bOº©i©j‰Ó•ÊÞ·ÈÑã\u000e“;\rxB\u0017•y&VO^\u001dëR+\u0012Â\u0012\u0013Ѩ\u0001׍¯#”\'\u0010Óa\nÊ\u0007ÝqdŽ¾‰–‘¡*ÃĊì\u0018±æ•¤Éö\u001c\u0013Krøú<Ý{»ð¡Šp§R\u001bË~\\ŸB¿æ$ \u001fТÙÎ\nÖ<|êüê$ÿ‚NÙ\u0014™¹£ði¤Ø\f>qÿ®\u0017a1ÎÀ~1Žâè\u0004ˆ6½¬‚Ç®ôfÖ\u001f¯ÎV¿Õqùȑ€ƒt&\u0012`ӐÓ*\u000e5—\u001c\u0013°Î\u000f~\u0018é\u0018\u0014¨·%Rp¡§3¥RÞÝï’\u0012uaä\u0000|ˆ üºœý̳©C7ôò™m£VÓ£Lž\u0018Š9ö\u0000õ³\u001chkà\u0019üØ}¶¥˜Á4(Ô/[¢Â65¼ŽÀ\u0017ó9³¦ð\u0005¥gyÐÇöÑã\u000e\t£¨u¤¶\u0007õöήII\u001e\n^N\u0013¢\u0013Ѩ\u0001׍¯#”\'\u0010Óa\nÊ\u0007ÝqdŽ¾‰–‘¡*ÃĊì\u0018±æ•¤Éö\u001c\u0013Krøú<Ý_Ÿ"ãŠp§R\u001bË~\\ŸB«æ$ \u001fТÙÎ\nÖ<-êZ"\u001b\u00039XJ\u001d­0фöj(q-®\u0001–)Î\u0005~þŽ˜%ê÷½§‚ÔÖ+\u000bV\u001egÎv¿0H\u000e\u0007\n€þtì¢@RKR•¤Éö\u001c\u0013KrøúÔ¢‹1:§ê׍\u0001k,¥RÞÝï’ø\u0007l…“M0\u001fx"úõÄz3’µ‹J¡íe¸£Lž\u0018Š9ö\u0000õ³\u001chkà\u0019üØ}¶¥˜Á4(Ô/[¢Â65¼ŽÀ\u0017ó9³¦ð\u0005¥gyÐÇöÑã\u000e\t£¨u¤¶\u0007õöήII\u001e\n^N\u0013¢\u0013Ѩ\u0001׍¯#”\'\u0010Óa\nÊ\u0007ÝqdŽ¾‰–‘¡*ÃĊì\u0018±æ•¤Éö\u001c\u0013Krøú<Ý_Ÿ"ãŠp§R\u001bË~\\ŸB«æ$ \u001fТÙÎ\nÖ<-êZ"\u001b\u00039XJ\u001d­0фöj(q-®\u0001–)Î\u0005~þŽ˜%êˆ÷½§‚ÔÖ+\u000bV\u001egÎv¿0H\u000e\u0007\n€þtì¢@RKR•¤Éö\u001c\u0013KrøúÔ¢‹1:§ê׍\u0001k,¥RÞÝï’ø\u0007l…“M0\u001fx"úõÄz3’µ‹J¡íe¸£Lž\u0018Š9ö\u0000õ³\u001chkà\u0019üØ}¶¥˜Á4(Ô/[¢Â65¼ŽÀ\u0017ó9³¦ð\u0005¥gyÐÇöÑã\u000e\t£¨u¤¶\u0007õöήII\u001e\n^N\u0013¢\u0013Ѩ\u0001׍¯#”\'\u0010Óa\nÊ\u0007ÝqdŽ¾‰–‘¡*ÃĊì\u0018±æ•¤Éö\u001c\u0013Krøú<Ý_Ÿ"ãŠp§R\u001bË~\\ŸB«æ$ \u001fТÙÎ\nÖ<-êZ"\u001b\u00039XJ\u001d­0фöj(q-®\u0001–)Î\u0005~þŽ˜%êˆ÷½§‚ÔÖ+\u000bV\u001egÎv¿0H\u000e\u0007\n€þtì¢@RKR•¤Éö\u001c\u0013KrøúÔ¢‹1:§ê׍\u0001k,¥RÞÝï’ø\u0007l…“M0\u001fx"úõÄz3’µ‹J¡íe¸£Lž\u0018Š9ö\u0000õ³\u001chkà\u0019üØ}¶¥˜Á4(Ô/[¢Â65¼ŽÀ\u0017ó9³¦ð\u0005¥gyÐÇöÑã\u000e\t£¨u¤¶\u0007õöήII\u001e\n^N\u0013¢\u0013Ѩ\u0001׍¯#”\'\u0010Óa\nÊ\u0007ÝqdŽ¾‰–‘¡*ÃĊì\u0018±æ•¤Éö\u001c\u0013Krøú<Ý_Ÿ"ãŠp§R\u001bË~\\ŸB«æ$ \u001fТÙÎ\nÖ<-êZ"\u001b\u00039XJ\u001d­0фöj(q-®\u0001–)Î\u0005~þŽ˜%êˆ÷½§‚ÔÖ+\u000bV\u001egÎv¿0H\u000e\u0007\n€þtì¢@RKR•¤Éö\u001c\u0013KrøúÔ¢‹1:§ê׍\u0001k,¥RÞÝï’ø\u0007l…“M0\u001fx"úõÄz3’µ‹J¡íe¸£Lž\u0018Š9ö\u0000õ³\u001chkà\u0019üØ}¶¥˜Á4(Ô/[¢Â65¼ŽÀ\u0017ó9³¦ð\u0005¥gyÐÇöÑã\u000e\t£¨u¤¶\u0007õöήII\u001e\n^N\u0013¢\u0013Ѩ\u0001׍¯#”\'\u0010Óa\nÊ\u0007ÝqdŽ¾‰–‘¡*ÃĊì\u0018±æ•¤Éö\u001c\u0013Krøú<Ý_Ÿ"ãŠp§R\u001bË~\\ŸB«æ$ \u001fТÙÎ\nÖ<-êZ"\u001b\u00039XJ\u001d­0фöj(q-®\u0001–)Î\u0005~þŽ˜%êˆ÷½§‚ÔÖ+\u000bV\u001egÎv¿0H\u000e\u0007\n€þtì¢@RKR•¤Éö\u001c\u0013KrøúÔ¢‹1:§ê׍\u0001k,¥RÞÝï’ø\u0007l…“M0\u001fx"úõÄz3’µ‹J¡íe¸£Lž\u0018Š9ö\u0000õ³\u001chkà\u0019üØ}¶¥˜Á4(Ô/[¢Â65¼ŽÀ\u0017ó9³¦ð\u0005¥gyÐÇöÑã\u000e\t£¨u¤¶\u0007õöήII\u001e\n^N\u0013¢\u0013Ѩ\u0001׍¯#”\'\u0010Óa\nÊ\u0007ÝqdŽ¾‰–‘¡*ÃĊì\u0018±æ•¤Éö\u001c\u0013Krøú<Ý_Ÿ"ãŠp§R\u001bË~\\ŸB«æ$ \u001fТÙÎ\nÖ<-êZ"\u001b\u00039XJ\u001d­0фöj(q-®\u0001–)Î\u0005~þŽ˜%êˆ÷½§‚ÔÖ+\u000bV\u001egÎv¿0H\u000e\u0007\n€þtì¢@RKR•¤Éö\u001c\u0013KrøúÔ¢‹1:§ê׍\u0001k,¥RÞÝï’ø\u0007l…“M0\u001fx"úõÄz3’µ‹J¡íe¸£Lž\u0018Š9ö\u0000õ³\u001chkà\u0019üØ}¶¥˜Á4(Ô/[¢Â65¼ŽÀ\u0017ó9³¦ð\u0005¥gyÐÇöÑã\u000e\t£¨u¤¶\u0007õöήII\u001e\n^N\u0013¢\u0013Ѩ\u0001׍¯#”\'\u0010Óa\nÊ\u0007ÝqdŽ¾‰–‘¡*ÃĊì\u0018æ±g\u000e5„ãQ',
     FlashpixVersion: [ 48, 49, 48, 48 ],
     ColorSpace: 1,
     ExifImageWidth: 1944,
     ExifImageHeight: 2592,
     CustomRendered: 0,
     ExposureMode: 0,
     WhiteBalance: 0,
     DigitalZoomRatio: 1,
     SceneCaptureType: 0,
     OffsetSchema: 44 },
  gps: {},
  interoperability: {},
  makernote: { error: 'Unable to extract Makernote information as it is in an unsupported or unrecognized format.' } }
tpiros commented 9 years ago

+1

lacombar commented 9 years ago

I created a small utility to separate JPEG metadata from the image data itself. You could git it at https://github.com/aerilon/node-extract-jpeg-metadata, it includes a ready-to-run script. Could you give it a try ? All you need to do is from a command line:

$ ./bin/extract-jpeg-metadata input.jpg output-metadata.jpg

It will allow you to avoid having to make the image itself public

axvpast commented 9 years ago

f2-1-metadata Hi

Looks like it safe to send :). By the way I see a lot of troubles with Makernote - it will be useful if we can disable extracting this data. For my particular case it is useless.

By the way, I see some cases when some Image can cause OOM. I cannot provide info about it to you (because I do not have it yet & it is really complicated to take it).

2015-02-21 0:00 GMT+02:00 Arnaud Lacombe notifications@github.com:

I created a small utility to separate JPEG metadata from the image data itself. You could git it at https://github.com/aerilon/node-extract-jpeg-metadata, it includes a ready-to-run script. Could you give it a try ? All you need to do is from a command line:

$ ./bin/extract-jpeg-metadata input.jpg output-metadata.jpg

It will allow you to avoid having to make the image itself public

— Reply to this email directly or view it on GitHub https://github.com/gomfunkel/node-exif/issues/32#issuecomment-75327149.