A small library to convert images and other files e.g. pdf from a source to a target folder in a custom format, size and name. For one source file there can be several new images by providing an array of options.
npm install batch-convert --save
var bc = require('batch-convert')
var options = [
{
'height': 400,
'postfix': '_small'
},
{
'height': 1200,
'postfix': '_big'
}
];
bc.convert("input", "output", options)
This will copy and convert all images in the folder input to the folder output by creating a small and a big version. The small version will get the postfix '_small' with a height of 400px and the big version with the postfix '_big' and 1200px height. The width will be changed depending on the ratio. By default the output format is jpg with a quality of 100.
{
'height': [in pixel] // Image height
'width': [in pixel] // Image width
'postfix': [allowed fs characters] // Postfix for the file name e.g. image.jpg + '_small' = image_small.jpg
'quality': [0-100], default = 100 // The quality of the image if a compression is used
'format': [jpg, png, gif, ..., default = 'jpg' // The format of the image
}
This library uses GraphicsMagick for conversion. Check http://www.graphicsmagick.org/formats.html to see which import and export formats are supported.
npm test
- 0.1.0 - Initial release
- 0.1.1 - Typos, default value for output
- 0.1.2 - Default value for input, jsdoc
- 0.1.3 - Update doc, fix typos