mattburns / exiftool.js

A pure javascript implementation of exiftool
MIT License
64 stars 13 forks source link

node.js Buffer support, optimize size, reading string fixes #12

Closed dfries closed 9 years ago

dfries commented 9 years ago

Create and expose getExifFromNodeBuffer for when the image is already in a Node.js Buffer, such as a streamed image that isn't even in a file.

Great utility, I coded up a node.js jpeg comment extractor (I've done that before), for a webcam stream, but then figured out it was Exif not a comment, so I looked around and found this. In my case I'm streaming the images over http in one multipart request and so I didn't have a file. Here's a trivial change to modify this module to read an image out of the Node.js Buffer.

I fixed an issue of creating a Buffer of size 100000, reading the file, then creating a BinaryFile of size 1000000 (10x the size). Now it won't create a buffer bigger than 100000, or the buffer length. In my case the images are small, some in the 10KB size, so I didn't want the overhead of creating an image bigger than required.

Don't drop the last character of Image Description, or ascii in general, do so by reading the full buffer, then discarding starting at any NULL, found in perl libimage-exiftool.

Don't throw away printable characters (I was loosing data), just what isn't.

Thanks for the great work on the module.