Closed gchudnov closed 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.
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... :-/
@jon49 are we sure Exif identifier will always come within 100 bytes ?
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.