Socket
Socket
Sign inDemoInstall

nodejs-image-parser

Package Overview
Dependencies
377
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    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.


Version published
Weekly downloads
3
Maintainers
1
Install size
25.2 MB
Created
Weekly downloads
 

Readme

Source

nodejs-image-parser

https://www.npmjs.com/package/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/', 'arrowNext@3x.png', 1)); // ./img_dest/arrow_next.png
console.log(ImageParser.parseFileName('./img_dest/', 'arrowNext@3x.png', 2)); // ./img_dest/arrow_next@2x.png
console.log(ImageParser.parseFileName('./img_dest/', 'arrowNext@3x.png', 3)); // ./img_dest/arrow_next@3x.png
Get file name : Promise based
const ImageParser = require('./ImageParser');

ImageParser.getFiles('./img_src').then(files => console.log(files)); // arrowNext@3x.png, search@3x.png
Change Image : Promise based
const ImageParser = require('./ImageParser');
const options = { srcDir: './img_src/', destDir: './img_dest/', file: 'arrowNext@3x.png' 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

FAQs

Last updated on 11 Dec 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc