npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hyperdrive-jpeg-index

v1.1.0

Published

index jpeg metadata and thumbnails for a hyperdrive archive

Downloads

4

Readme

hyperdrive-jpeg-index

index jpeg metadata and thumbnails for a hyperdrive archive

example

This example will store time and orientation values from EXIF headers and width and height values from SOF headers.

var hyperdrive = require('hyperdrive')
var fs = require('fs')
var path = require('path')
var sub = require('subleveldown')
var to = require('to2')
var jpeg = require('hyperdrive-jpeg-index')

var level = require('level')
var db = level('/tmp/photos.db')

var namedArchives = require('hyperdrive-named-archives')
var named = namedArchives({
  drive: hyperdrive(sub(db, 'drive')),
  db: sub(db, 'archives')
})
var archive = named.createArchive('photos')
var photos = jpeg({
  archive: archive,
  db: sub(db, 'jpeg'),
  properties: {
    time: ['EXIF','exif','DateTimeOriginal',isoString],
    orientation: ['EXIF','image','Orientation'],
    width: ['SOF','width'],
    height: ['SOF','height']
  }
})
function isoString (date) { return date.toISOString() }

if (process.argv[2] === 'add') {
  var file = process.argv[3]
  fs.createReadStream(file)
    .pipe(archive.createFileWriteStream(path.basename(file)))
} else if (process.argv[2] === 'list') {
  photos.list().pipe(to.obj(function (img, enc, next) {
    console.log(img)
  }))
}

output:

$ node photos.js add cactus.jpg
$ node photos.js list
{ name: 'cactus.jpg',
  properties: 
   { time: '2015-06-19T16:40:52.000Z',
     orientation: 1,
     width: 600,
     height: 800 } }

api

var jpeg = require('hyperdrive-jpeg-index')

var photos = jpeg(opts)

Create a photos instance from:

  • opts.archive - a hyperdrive archive
  • opts.db - a leveldb instance to save index data
  • opts.properties - map of property keys to marker key paths
  • opts.map(entry, stream, next) - intercept the entry and binary jpeg stream

Each marker key path given in opts.properties is an array that describes the nested location into a marker object to produce a value. Key path items can be a string or a function (node) {} that take an object as input and should return the next node value to use in the traversal.

With opts.map you can calculate secondary indexes or set additional properties. Call next(err, props) with any additional properties to set on the record. You can use opts.map to do things like generate resized versions of the image to store elsewhere.

var stream = photos.list()

Return a readable objectMode stream of records. Each record has:

  • row.name - file name from hyperdrive
  • row.properties - the values generated from the marker key paths

photos.get(name, cb)

Fetch the property values generated for a file name.

install

npm install hyperdrive-jpeg-index

license

BSD