rsz v0.2.3
rsz
Resize image files or Buffer
s
Depends on node-canvas which has special build instructions as it requires Cairo to be installed on your system.
API
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.
Example
var rsz = require('rsz')
, fs = require('fs')
rsz('/path/to/nyancat.gif', 200, 350, function (err, buf) {
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 (err, buf) {
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) {
})
Licence
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.