exif-reader icon indicating copy to clipboard operation
exif-reader copied to clipboard

data: buffer should start with "Exif"

Open stefanocudini opened this issue 7 years ago • 6 comments

trying to read a buffer created using: var exifreader = Npm.require('exif-reader');

var buf = Buffer.from(fileObj.blob, 'binary'); var meta = exifreader(buf);

stefanocudini avatar Nov 20 '18 20:11 stefanocudini

the same for me, I tried another lib that worked and also expected a buffer => the problem is in the lib I guess. here is a photo failing : SAM_2127_d47a

Benibur avatar Apr 22 '19 10:04 Benibur

Hello, the EXIF data must be extracted from the JPEG image first.

For the image above try something like:

const sharp = require('sharp');
const exifReader = require('exif-reader');

sharp('56497304-40e89a80-64fd-11e9-9684-ee95b5d58567.JPG')
  .metadata()
  .then(({ exif }) => {
    const exifProperties = exifReader(exif);
    console.log(exifProperties);
  });

which outputs:

{ image:
   { Make: 'SAMSUNG',
     Model: 'SAMSUNG PL20,PL21 / VLUU PL20,PL21 ',
     Orientation: 1,
     XResolution: 96,
     YResolution: 96,
     ResolutionUnit: 2,
     Software: 'Microsoft Windows Photo Viewer 6.1.7600.16385',
     ModifyDate: 2019-01-14T11:31:13.000Z,
     YCbCrPositioning: 2,
     Copyright: 'COPYRIGHT, 2011',
     ExifOffset: 2360,
     ...

lovell avatar Sep 25 '19 18:09 lovell

This bit me as well.

@lovell I believe it would make a lot of sense to include this functionality by default as the other libraries do as it's the standard use case for most.

Thoughts?

jamesdixon avatar Jan 06 '20 21:01 jamesdixon

So, sharp depends on this module and this module requires sharp to work? That's a bit bizarre, imho.

WebReflection avatar Oct 18 '20 12:10 WebReflection

@WebReflection

  • exif-reader does not depend on sharp. If you need to extract EXIF data as a Buffer from an image then you can use sharp, but other solutions may be available.
  • sharp uses exif-reader to verify it was able to extract valid EXIF data as a Buffer as part of its unit tests and therefore includes it in devDependencies.

lovell avatar Oct 18 '20 20:10 lovell

@lovell thanks for clarifying that, I ended up using both sharp and exiftool a part, as it seems to be the standard. I might have a second look at this module though, since it works fine via sharp metadata.

WebReflection avatar Oct 19 '20 10:10 WebReflection