# toolpic-render

> Toolpic rendering core module

Latest version **0.0.9** (published 2021-07-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install toolpic-render
pnpm add toolpic-render
yarn add toolpic-render
bun add toolpic-render
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2021-07-01 |
| First published | 2020-04-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 158.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Maurice Conrad |
| Maintainers | mauriceconrad |
| Keywords | toolpic, render |

## Links

- npm: https://www.npmjs.com/package/toolpic-render
- npm.io page: https://npm.io/package/toolpic-render

## Dependencies (1)

- [puppeteer](https://npm.io/package/puppeteer.md) ^10.0.0

## Recent versions

- 0.0.9 (latest) — 2021-07-01
- 0.0.8 — 2021-07-01
- 0.0.7 — 2021-07-01
- 0.0.6 — 2021-06-30
- 0.0.5 — 2021-06-29
- 0.0.3 — 2021-06-18
- 0.0.2 — 2021-04-26
- 0.0.1 — 2021-04-26
- 0.2.3 — 2020-05-01
- 0.2.2 — 2020-04-29
- 0.2.1 — 2020-04-29
- 0.2.0 — 2020-04-14
- 0.1.9 — 2020-04-14
- 0.1.8 — 2020-04-14
- 0.1.7 — 2020-04-12
- … 6 more at https://npm.io/package/toolpic-render/versions

## README

# Toolpic Render

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

## Install

```bash
$ npm install toolpic-render
```

### Usage

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

```javascript
// 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();
});
```

---
_Source: https://npm.io/package/toolpic-render · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
