Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

image-headers

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-headers

Parse image headers from a stream without loading the entire image.

  • 0.3.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

ImageHeaders

This is a simple class that can be used with a stream to read all the metadata from an image file without storing the entire file in memory.

Typically, most libraries in Node take in the stream, save it somewhere (either a Buffer or to disk), then hand the image file off to an external library.

We have a image uploader service that basically proxies through the stream directly to S3 - we don't want to hit our disk at all. This was the only way we could hit that goal and still get our metadata.

Usage

npm install image-headers

See the test file for how we are using it. Here's the key snippet:

image_headers = new ImageHeaders()

  new DataReader(file_name)
    .on "error", (error) ->
      console.log ("error: " + error)
      return callback(error)
    .on "byte", (b) ->
      # console.log ("byte: " + b)
      image_headers.add_bytes(b) unless image_headers.finished
    .on "end", () ->
      # console.log ("EOF");
      image_headers.finish (err, image_headers) ->
        return callback(err, image_headers)
    .read()

That's in CoffeeScript.

The finish call is important - it's what processes the EXIF tags (and in the future anything similar that can benefit from an external library). This keeps our code simpler from having us stream and parse EXIF on the fly. No library does this well, as far as I can find.

TODO

  • performance and general cleanup. This was a weekend hack (really a 24 hour one) and it shows.
  • clean up internals and exposed data structures. Right now, it's all properties on the object.
  • add support for additional metadata, including GPS and Camera model, as top level features

License

See the LICENSE file for details, but short version: MIT License.

Keywords

FAQs

Package last updated on 16 Jun 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc