jimp-canvas

0.1.1 • Public • Published

A (very) incomplete canvas 2d built on Jimp JS for node

I needed to run JsBarcCode in node, but didn't want to add the complexity of node-canvas and cairo into my build system.

Setup:

npm install --save jsbarcode jimp jimp-canvas

Usage as express route handler:

const JsBarcode = require('jsbarcode')
const Canvas = require('./jimp-canvas')
function routeHandler (req, res) {
  let canvas = new Canvas()
  JsBarcode(canvas, 'ABC123', {
    format: 'CODE128'
  })
  canvas.getBufferAsPng(function (err, buffer) {
    res.type('.png')
    res.send(buffer)
  })
}

Caveats:

Truly a junk yard implementation of the bare minimum canvas '2d' feature set needed for CODE128 in JsBarCode canvas renderer. The font sized is fixed incorrecrly at 16, the colors are fixed at black and white, etc.

Readme

Keywords

Package Sidebar

Install

npm i jimp-canvas

Weekly Downloads

6

Version

0.1.1

License

MIT

Last publish

Collaborators

  • sullivanpt