Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dayitv89/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.
https://github.com/dayitv89/nodejs-image-parser

Last synced: 9 days ago
JSON representation

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.

Awesome Lists containing this project

README

        

# nodejs-image-parser

![https://www.npmjs.com/package/nodejs-image-parser](https://img.shields.io/badge/npm-v1.0.2-red.svg?style=flat)

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

```javascript
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

```javascript
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

```javascript
const ImageParser = require('./ImageParser');

ImageParser.getFiles('./img_src').then(files => console.log(files)); // [email protected], [email protected]
```

#### Change Image : Promise based

```javascript
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

```javascript
const ImageParser = require('./ImageParser');
const options = { destDir: './img_dest/', compressionSize: '50' };
ImageParser.compressImages(options).then(() => console.log('done'));
```

####

Voila & Thanks, Author: **Gaurav D. Sharma**