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 🙏

© 2025 – Pkg Stats / Ryan Hefner

printlet

v0.5.0

Published

Generate static images from tiles and draw suff on top.

Readme

Printlet

Generate static map images from TileJSON configuration and draw stuff on top with GeoJSON.

Printlet supports an extended version of TileJSON for declaring custom map projections. The specification resides here.

Intended for use as a library Printlet also comes with a thin HTTP API as an example of implementation but also for practical use.

var printlet = require('printlet'),
    render = printlet(require('./tile.json'));

render({
  width: 800,
  height: 600,
  zoom: 12,
  lng: 11.95,
  lat: 57.7,
  format: 'png'
}, function (err, data) { data.stream.pipe(process.stdout); });

Getting started

Installing dependencies on OS X using Homebrew

$ brew install cairo --without-x

Note: This might cause some problems. Please report issues if Printlet wont build after this step.

Troubleshooting problems with libpng (on OS X 10.7.5):

# For freetype
export LIBPNG_CFLAGS=`/usr/local/opt/libpng/bin/libpng-config --cflags`
export LIBPNG_LDFLAGS=`/usr/local/opt/libpng/bin/libpng-config --ldflags`

# For cairo
brew link libpng --force
brew install --env=std cairo --without-x
brew link cairo --force
brew link pixman --force
brew link freetype --force

Installing dependencies on Ubuntu

$ sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++

Installing dependencies on Fedora

$ sudo yum --enablerepo=updates-testing install npm cairo-devel

Drop "--enablerepo=updates-testing" if you're on F19 or greater.

Installing Printlet using NPM

$ npm install -g printlet

Running the HTTP server

$ printlet

Now point your browser to http://localhost:41462/12/11.95/57.7/800x600.png and get a nice view of Göteborg using a default OSM TileJSON.

With custom TileJSON

Grab your favorite TileJSON and point Printlet to it. There is an example TileJSON with a custom projection to try out here.

$ printlet 41462 your/tile.json

Open browser to same URL as previous step to check it out.

Building Printlet for developers

$ git clone https://github.com/kartena/printlet.git
$ cd printlet
$ npm install

Examples of using Printlet as a lib

There is a minimalistic map image generator in the examples folder to get the basic gist of the Printlet lib.

Also there is a more advanced implementation using the GeoJSON drawing capabilities as a HTTP server.

Drawing GeoJSON features

At the moment styles for GeoJSON is defined in the properties attribute of a GeoJSON feature as a dictionary called style. The keys under style are the same as the HTML5 canvas API for styling shapes.

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [11.95, 57.7]
      },
      "properties": {
        "style": {
          "fillStyle": "rgba(200, 0, 0, 0.6)",
          "marker": {
            "radius": 15
          }
        }
      }
    }
  ]
}

Exceptions to the canvas properties is marker which is possible to define for geometry type Point and describes how points are drawn with images, text or a circle.

{
  "image": "http://example.org/image.png",
  "text": "Example text...",
  "radius": 5,
  "offset": {
    "x": 10,
    "y": -15,
    "fx": 0.5,
    "fy": 0.5
  }
}