devongovett / exif-reader

A small EXIF image metadata reader
MIT License
145 stars 22 forks source link

Doesn't work with all EXIF images #1

Closed gchudnov closed 9 years ago

gchudnov commented 9 years ago

e.g the following top image contains EXIF metadata http://www.w3.org/MarkUp/Test/xhtml-print/20050519/tests/A_2_1-BF-01.htm but triggers an exception.

'Invalid EXIF data: buffer should start with "Exif".'
devongovett commented 9 years ago

exif-reader does not read JPEG images directly, only raw EXIF data. You need to first extract the EXIF chunk from the JPEG and then pass it to exif-reader. Support for this is built into jpg-stream.

jon49 commented 8 years ago

A simple workaround without pulling in yet another lib.

const img = readFileSync('flower.jpg')
const imageMetadata = exif(img.slice(img.toString('ascii', 0, 100).indexOf('Exif')))

I don't know if that is a bad way to go about it though... :-/