Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A nodejs C++ module that given a buffer with RGB or RGBA values creates a JPEG image in memory.
Branch: master
Pull request Compare This branch is 76 commits behind pkrumins:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


This is a node.js module, writen in C++, that uses libjpeg to produce a JPEG
image from a buffer of RGBA or RGB values. Since JPEG has no notion of A (alpha),
the module always uses just RGB values.

It was written by Peteris Krumins (
His blog is at  --  good coders code, great reuse.


The module exports `Jpeg` object that takes 5 arguments in its constructor:

    var png = new Jpeg(buffer, width, height, quality, buffer_type);

The first argument, `buffer`, is a nodee.js `Buffer` filled with RGBA or RGB
The second argument is integer width of the image.
The third argument is integer height of the image.
The fourth argument is the quality of output image.
The fifth argument is buffer type, either 'rgb' or 'rgba'.

See `examples/` directory for examples.

To get it compiled, you need to have libjpeg and node installed. Then just run

    node-waf configure build

to build the Jpeg module. It will produce a `jpeg.node` file as the module.


Have fun!

Peteris Krumins

Something went wrong with that request. Please try again.