Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mascrypt0/npm-image-generator
NPM Image Generator
https://github.com/mascrypt0/npm-image-generator
Last synced: about 2 months ago
JSON representation
NPM Image Generator
- Host: GitHub
- URL: https://github.com/mascrypt0/npm-image-generator
- Owner: mascrypt0
- Created: 2024-03-04T17:36:24.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-04T18:15:33.000Z (10 months ago)
- Last Synced: 2024-10-28T15:30:44.670Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# npm-image-generator
This is a node module for generating random images.
- Works platform independent
- Needs no building thanks to jpeg-js
- Generates random colored, noisy imagesI needed this for creating dummy datasets including images in combination with faker.js and / or choice.js
Uses the jpeg-js library: https://github.com/eugeneware/jpeg-js
## Installation
```bash
npm i npm-image-generator
```## Example Usage
```js
var fs = require('fs');
var imgGen = require('npm-image-generator');// Generate one image
imgGen.generateImage(800, 600, 80, function(err, image) {
fs.writeFileSync('dummy.jpg', image.data);
});// Generate multiple images
for(var i=1;i<=10;i++){
imgGen.generateImage(800, 600, 80, function(err, image) {
console.log("Generating image #" +i);
fs.writeFileSync('dummy-' + i + '.jpg', image.data);
});
}
```