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

couchmagick-stream

v1.6.0

Published

Pipe CouchDB documents through ImageMagicks convert.

Downloads

12

Readme

couchmagick-stream

Pipe CouchDB documents through ImageMagicks convert.

Usage

var stream = require('couchmagick-stream');
var es = require('event-stream');
var request = require('request').defaults({ json: true });

var couch = 'http://localhost:5984/mydb';
var config = {
  versions: {
    thumbnail: {
      args: [
        "-resize", "x100"
      ]
    }
  }
};

es.pipeline(
  request.get(couch + '/_all_docs', { qs: { include_docs: true } }),
  JSONStream.parse('rows.*'),
  stream(couch, { thumbs: config }),
  es.map(function map(data, done) {
    done(null, data.response);
  }),
  es.stringify(),
  process.stdout
);

See examples/posts.js for an advanced usage example.

filter

There are two kinds of filters which you can define: one operates on doc level and one on version level.

Document Filter

This filter is called with one argument: document.

Version Filter

This filter is called with two arguments, document and attachment name.

content_type

Content-Type of the resulting attachment. Default is image/jpeg.

id

The document id where the version is stored. Defaults to {id}/{version}.

Can have the following placeholders:

  • id - the original doc id
  • parts - array of the id splitted at /
  • version - name of the version

name

The attachment name of the version. Default is {basename}-{version}{extname}.

Can have placeholders:

  • id - the original doc id
  • parts - array of the id splitted at /
  • version - name of the version
  • name - original attachment name, eg this/is/my-image.jpg
  • extname - file extenstion of the original attachment name, eg .jpg
  • basename - basename without extension, eg my-image
  • dirname - directory name, eg this/is
  • version - name of the version

args

Array of argument strings for ImageMagicks convert.

The default is ['-', 'jpg:-'], which means that ImageMagick converts the image to jpg. You can see that we use convert with pipes for in- and output.

See ImageMagick Convert Command-line Tool for a comprehensive list of options.

Options

couchmagick-stream accepts an optional options object as third parameter:

  • concurrency - Number of simultanous processes. Default is 1.
  • convert_process_timeout - Timeout for convert process. Default is 1 minute.

Examples

You can run an example (examples/thumbnails.js):

node examples/thumbnails.js http://localhost:5984/mydb

Contributing

Lint your code with npm run jshint

(c) 2013 Johannes J. Schmidt, null2 GmbH