0.0.9 • Published 3 years ago

toolpic-render v0.0.9

Weekly downloads
1
License
ISC
Repository
-
Last release
3 years ago

Toolpic Render

This is a rendering API for Live Templates of toolpic project.

Install

$ npm install toolpic-render

Usage

Rendering ahppens within instances that share some general settings. To create them:

// Import fs
import fs from 'fs'
// Import module
import ToolpicRender from 'toolpic-render'

// Create instance
const app = new ToolpicRender({
  initFunctionName: 'render', // Optional, default value is 'render'
  // Specify wether we do not want to use the default headers by default (JPEG, PNG, SVG & PDF) (which generally does not make sense in the most cases)
  noDefaultHandlers: false // Optional, default value is false
});

// 1st: URL of live instance
// 2nd: Data object
// 3rd: Options
const rs = app.render('http://localhost:8888/live/strike/', {
  radius: 42
}, {
  width: 400, // Required, width of result
  height: 400, // Required, height of result
  // Delay to wait for images to be load
  delay: 101, // Optional, default = 100
  // Can be used to specify compression of JPEG images
  quality: 50, // Optional, default = 95
  //mime: 'application/pdf',
  // mime type of result
  mime: 'image/png', // Required!
});


// Create example write stream
const myWriteStream = fs.createWriteStream('test.png');
// Pipe the read stream to any write stream
rs.pipe(myWriteStream);

// Listen for finish event in write stream
myWriteStream.on('finish', () => {
  console.log("Successfully rendered image!");
  // Kill instance if we do not use it for additional rendering any more
  app.kill();
});
0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.3

3 years ago

0.0.1

3 years ago

0.0.2

3 years ago

0.2.5

4 years ago

0.2.3

4 years ago

0.2.1

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago