5.0.1 • Published 3 years ago
imagickal v5.0.1
node-imagickal
node wrapper for ImageMagick commands
Installation
npm install imagickal
Examples
var im = require('imagickal');
//get image dimensions
im.dimensions('image.jpg').then(function (dim) {
console.log(dim.width);
console.log(dim.height);
});
//get image dimensions and type
im.identify('image.jpg').then(function (data) {
console.log(data);
});
//Add true as second argument on identify to check if the image is corrupt.
im.identify('image.jpg', true).then(function (data) {
console.log(data);
});
//Don't like using promises, use regular node style callbacks for all functions that returns promises.
im.identify('image.jpg', function (err, data) {
console.log(data);
});
//Using streams instead of filepath
im.identify(fs.createReadStream('image.jpg'), function (err, data) {
console.log(data);
});
im.transform(fs.createReadStream('image.jpg'), fs.createWriteStream('out.jpg', {encoding: 'binary'}), {strip: true}).then(function () {
console.log('Done')
});
//transform image with action object,
//actions is applied in the same order as they are recevied
var actions = {
resize: { width: 100 },
crop: { width: 10, height: 10, x: 10, y: 10 },
quality: 90,
strip: true
};
im.transform('src.jpg', 'dst.jpg', actions).then(function () {
console.log('Done')
});
//transform image with command object
im.commands()
.resize({ width: 100 })
.crop({ width: 10, height: 10, x: 10, y: 10 })
.quality(90)
.strip()
.exec('src.jpg', 'dst.jpg').then(function () {
console.log('done');
});
//specify executable path
im.commands({ executable: 'MAGICK_MEMORY_LIMIT=256MB /tmp/convert' }).exec('src.jpg', 'dst.png');
//or set global for im.
im.setDefaults({ executable: 'MAGICK_MEMORY_LIMIT=256MB /tmp/convert' });
Available image actions / commands
- rotate Rotate image, properties { angle: 0, x: 0, y: 0 }
- crop - Crop image, properties { width: 2560, height: 1013, x: 0, y: 0 }
- extent - Directly adjust image size, properties { width: 2560, height: 1013 }
- resize - Resize image, properties { width: 470, height: 186, flag: '>' }, available flags <,>,!,^ for more info read about them in the imagemagick resize docs
- sharpen - Sharpen image, properties { mode: 'variable' }, available modes are: light, moderate, strong, extreme, off.
- strip - Strip image of all profiles and comments.
- quality - Compression quality, defaults to 85.
Run Tests
npm test
Enable debugging output
Set DEBUG environment variable to imagickal
DEBUG=imagickal node ./app.js
5.0.1
3 years ago
5.0.0
3 years ago
4.2.0
4 years ago
4.1.0
5 years ago
4.0.0
6 years ago
3.1.0
6 years ago
3.0.0
6 years ago
2.0.0
8 years ago
1.1.2
9 years ago
1.1.1
9 years ago
1.1.0
9 years ago
1.0.1
9 years ago
1.0.0
9 years ago
0.8.0
9 years ago
0.7.0
10 years ago
0.6.0
10 years ago
0.5.0
10 years ago
0.4.1
10 years ago
0.4.0
10 years ago
0.3.0
10 years ago
0.2.0
10 years ago
0.1.1
11 years ago
0.1.0
11 years ago