Open stefanocudini opened 5 years ago
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 :
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,
...
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?
So, sharp depends on this module and this module requires sharp to work? That's a bit bizarre, imho.
@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 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.
trying to read a buffer created using: var exifreader = Npm.require('exif-reader');
var buf = Buffer.from(fileObj.blob, 'binary'); var meta = exifreader(buf);