Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

blend

mapbox62deprecated1.2.0

This module has moved: please install @mapbox/blend instead

High speed image blending and quantization

readme

node-blend

This module can re-encode one or more images of the same size. It supports stiching multiple images together into a single image, alpha-compositing, color quantization, and various compression options to produce highly optimized output.

Build Status Build status

Usage

var blend = require('blend');
var image1; // Contains a compressed PNG image as a buffer.
var image2;
blend([ image1, image2 ], function(err, result) {
    // result contains the blended result image compressed as PNG.
});

blend([ image1, image2 ], {
    format: 'jpeg',
    quality: 90
}, function(err, result) {
    // result contains the blended result image compressed as JPEG.
});

Options

  • format: jpeg, png, or webp
  • quality: integer indicating the quality of the final image. Meaning and range differs per format. For JPEG and webp the range is from 0-100. It defaults to 80. The lower the number the lower image quality and smaller the final image size. For PNG range is from 2-256. It means the # of colors to reduce the image to using. The lower the number the lower image quality and smaller the final image size.
  • width: integer, default 0: final width of blended image. If options provided with no width value it will default to 0
  • height: integer, default 0: final width of blended image. If options provided with no height value it will default to 0
  • reencode: boolean, default false
  • matte: when alpha is used this is the color to initialize the buffer to (reencode will be set to true automatically when a matte is supplied)
  • compression: level of compression to use when format is png. The higher value indicates higher compression and implies slower encodeing speeds. The lower value indicates faster encoding but larger final images. Default is 6. If the encoder is libpng then the valid range is between 1 and 9. If the encoder is miniz then the valid range is between 1 and 10. The reason for this difference is that miniz has a special "UBER" compression mode that tries to be extremely small at the potential cost of being extremely slow.
  • palette: pass a blend.Palette object to be used to reduced PNG images to a fixed array of colors
  • mode: octree or hextree - the PNG quantization method to use, from Mapnik: https://github.com/mapnik/mapnik/wiki/OutputFormats. Octree only support a few alpha levels, but is faster while Hextree supports many alpha levels.
  • encoder: libpng or miniz - the PNG encoder to use. libpng is standard while miniz is experimental but faster.

Installation

npm install blend@latest

Development

To run tests for this module, run npm install --dev to install the testing framework, then npm test. Tests require Imagemagick for its compare utility.

changelog

Changlog

1.2.0

  • Updated to mapnik 3.5.0

1.0.1

  • Loosen mapnik semver to 3.x.

1.0.0

0.11.0

  • Drop C++ addon in favor of using upstream node-mapnik blend API.

0.10.1

  • Bump release to dodge npm fail.

0.10.0

  • Support for pre-built binaries using node-pre-gyp.

0.9.1

  • Fixed potential crash on zero length image.

0.9.0

  • Node v0.10.x support (removed waf support)
  • Minor hsl fixes ported from Mapnik 2.3.x: faster fmod and improved rounding/static casts

0.8.3

  • Support for OS X 10.9

0.8.2

  • Maintain build support for all node v0.8.x versions as waf support erodes

0.8.1

  • Fix for OS X build and libjpeg turbo

0.8.0

  • Add support for webp.

0.7.1

  • Fix potential memory corruption when writing reduced color png images.

0.7.0

  • Modified tinting functionality - now all pixels are converted from rgb to hsl before the tint string is applied and then the pixels are converted back to rgb.
  • Fixed unsigned integer overflow (#27)

0.6.0

  • Added HSL tinting support - a tint string can be passed as a property of an image and all rgb pixels will be set as a function of hsl2rgb conversion. See README for details on usage. (#26)
  • Added --debug configure option to enable debug builds with assertions

0.5.1

  • Fixed possible assert/crash when encoding an image with true white when using dense_hash_map

0.5.0

  • Switch to using sparsehash/dense_hash_map for performance caching in quantize functions (#24)
  • Added support for MZ_UBER_COMPRESSION when using encoder:miniz.

0.4.1

  • Added mode and encoder option to control hextree/octree and libpng/miniz (See README.md for details)

0.4.0

  • Hextree, fixed palettes, miniz additions

0.3.0

  • Node v0.8.x support