nodejs-image-parser
v1.0.2
Published
Nodejs image parser (convert images as @3x image into desired RGB, compress them, fix the names to snake_case and finally put as 1x,2x, 3x form). Good for react native/ iOS projects.
Downloads
1
Readme
nodejs-image-parser
Nodejs image parser (convert images as @3x image into desired RGB, compress them, fix the names to snake_case and finally put as 1x,2x, 3x form). Good for react native/ iOS projects.
Source Image:
Output: ,,
Source Image:
Output: ,,
Sample code
const ImageParser = require('./ImageParser');
const options = { srcDir: './img_src/', destDir: './img_dest/', color: { red: 0, green: 255, blue: 255 } };
ImageParser(options)
.then(() => {
console.log('all done');
})
.catch(err => {
console.log(err);
});
Other options for Separate task
Parse File Names : Sync return
const ImageParser = require('./ImageParser');
console.log(ImageParser.parseFileName('./img_dest/', '[email protected]', 1)); // ./img_dest/arrow_next.png
console.log(ImageParser.parseFileName('./img_dest/', '[email protected]', 2)); // ./img_dest/[email protected]
console.log(ImageParser.parseFileName('./img_dest/', '[email protected]', 3)); // ./img_dest/[email protected]
Get file name : Promise based
const ImageParser = require('./ImageParser');
ImageParser.getFiles('./img_src').then(files => console.log(files)); // [email protected], [email protected]
Change Image : Promise based
const ImageParser = require('./ImageParser');
const options = { srcDir: './img_src/', destDir: './img_dest/', file: '[email protected]' color: { red: 0, green: 255, blue: 255 } };
ImageParser.changeImage(options).then(() => console.log('done'));
Compress Images : Promise based
const ImageParser = require('./ImageParser');
const options = { destDir: './img_dest/', compressionSize: '50' };
ImageParser.compressImages(options).then(() => console.log('done'));
Voila & Thanks, Author: Gaurav D. Sharma