sjotorp-image

1.2.0 • Public • Published

sjotorp_image

This is a node module for generating random images.

  • Works platform independent
  • Needs no building thanks to jpeg-js
  • Generates random colored images

I 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

npm install sjotorp_image

Example Usage

var fs = require('fs');
var imgGen = require('sjotorp_image');
 
// Generate one image
imgGen.generateImage(800, 600, undefined, function(err, image) {
    fs.writeFileSync('dummy.jpg', image.data);
});
 
// Generate multiple images
// Will generate same color on the images every time we run since we use the
// fileName as a seed
for(var i=1;i<=10;i++){
  var fileName = 'dummy-' + i + '.jpg';
  var color = imgGen.generateColor(fileName);
    imgGen.generateImage(800, 600, color, function(err, image) {
        console.log("Generating image #" +i);
        fs.writeFileSync(fileName, image.data);
    });
}

Package Sidebar

Install

npm i sjotorp-image

Weekly Downloads

7

Version

1.2.0

License

ISC

Unpacked Size

15.8 kB

Total Files

8

Last publish

Collaborators

  • softbrixorg