1.2.0 • Published 5 years ago

sjotorp-image v1.2.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

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);
    });
}