rsz

Resize images as files or Buffers

rsz

Resize image files or Buffers

Depends on node-canvas which has special build instructions as it requires Cairo to be installed on your system.

There is one method but multiple ways to use it:

rsz(src, width, height, function (err, buf) { /* */ })

Where src is a String specifying the path to the image or a Buffer containing the image data, and buf is a Buffer containing the resized image data.

rsz(src, width, height, dst, function (err) { /* */ })

Where src is a String specifying the path to the image or a Buffer containing the image data, and dst is a String specifying the path to write the output file to.

rsz(src, { width: w, height: h }, function (err, buf) { /* */ })

Where w and h are the width and height respectively, src is a String specifying the path to the image or a Buffer containing the image data, and buf is a Buffer containing the resized image data.

rsz(src, { width: w, height: h }, dst, function (err) { /* */ })

Where w and h are the width and height respectively, src is a String specifying the path to the image or a Buffer containing the image data, and dst is a String specifying the path to write the output file to.

var rsz = require('rsz')
  , fs  = require('fs')
 
rsz('/path/to/nyancat.gif', 200, 350, function (errbuf) {
  fs.writeFileSync('/path/to/nyancat_200_350.gif', buf)
})
 
// or 
 
rsz('/path/to/nyancat.gif', 200, 350, '/path/to/nyancat_200_350.gif', function (err) {
})
 
// or 
 
rsz('/path/to/nyancat.gif', { width: 200, height: 350 }, function (errbuf) {
  fs.writeFileSync('/path/to/nyancat_200_350.gif', buf)
})
 
// or 
 
rsz('/path/to/nyancat.gif', { width: 200, height: 350 }, '/path/to/nyancat_200_350.gif', function (err) {
})

rsz is Copyright (c) 2013 Rod Vagg @rvagg and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.