Hi, I tried to console.log(metadata.exif.toString()) and it returns semi-scrambled text like below:
ExifMnv(; ~�� ��i��%nHHRay ShanRay Shan�0230�����P�0100��P2015:08:21 23:11:23ASCIIMETAR MMMX 220347Z 07003KT 8SM OVC080 16/12 A3036 NOSIG RMK 8/07/ HZY SCR980100N�W���dc ad
$�G
Hello, the functional tests use the exif-reader module for this purpose - see https://github.com/lovell/sharp/blob/master/test/unit/metadata.js#L46-L49
Ahh, I should always check the tests first. Thanks!
Hi @lovell ,
Even with the exif-reader module I get the following exif properties as buffers:
But when I try to stringify them like exifdata.MakerNote.toString( 'utf8' ) I get this:
Apple iOS\u0000\u0000\u0001MM\u0000\u000b\u0000\u0001\u0000\t\u0000\u0000\u0000\u0001
Any advice?
@ickata These properties are all Buffers rather than strings - you'll need something to decode the raw proprietary data they contain.
Thanks for the clarification, @lovell . And also many thanks for this great module!
@ickata If you're going to read the exif data of images from untrusted sources, I recommend using the https://npmjs.org/package/exif-reader-paras20xx fork, which has been hardened with a bunch of range checks (https://github.com/devongovett/exif-reader/pull/5). The original module doesn't validate the offsets in the exif blob and will loop for a long time or run out of memory with certain kinds of corrupted or malicious exif data.
exif-reader now validates the offsets in the exif blob
I recently became a maintainer of the https://github.com/devongovett/exif-reader repo so was able to merge @papandreou's fixes and publish them in a new version of the original https://www.npmjs.com/package/exif-reader module.
Most helpful comment
I recently became a maintainer of the https://github.com/devongovett/exif-reader repo so was able to merge @papandreou's fixes and publish them in a new version of the original https://www.npmjs.com/package/exif-reader module.