# html-to-gif

> HTML to animated gif generator for NodeJS using PhantomJS and Gifencoder.

Latest version **0.0.4** (published 2017-07-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install html-to-gif
pnpm add html-to-gif
yarn add html-to-gif
bun add html-to-gif
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2017-07-25 |
| First published | 2017-07-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Chris Rodgers |
| Maintainers | cr2828 |

## Links

- npm: https://www.npmjs.com/package/html-to-gif
- npm.io page: https://npm.io/package/html-to-gif

## Dependencies (4)

- [phantomjs](https://npm.io/package/phantomjs.md) ^2.1.7
- [get-pixels](https://npm.io/package/get-pixels.md) ^3.3.0
- [gifencoder](https://npm.io/package/gifencoder.md) ^1.0.6
- [image-plucker](https://npm.io/package/image-plucker.md) ^0.1.1

## Recent versions

- 0.0.4 (latest) — 2017-07-25
- 0.0.3 — 2017-07-25
- 0.0.2 — 2017-07-24
- 0.0.1 — 2017-07-24

## README

## Install
npm install html-to-gif --save

## Description
HTML to animated gif generator for NodeJS using PhantomJS and Gifencoder.
Returns a stream of GIF data.

## Options
| Value             | Type   | Description                                                      |
|-------------------|--------|------------------------------------------------------------------|
| phantomExecutable | String | Location of phantomjs. Defaults to ./node_modules/.bin/phantomjs |
| dimensions        | Object | dimensions: {width: 800, height: 650}                            |
| url               | String | Target URL                                                       |
| duration          | Int    | Duration in ms                                                   |
| repeat            | Bool   | Animation repeats when finished - true / false                   |
| delay             | Int    | Time between each frame in ms                                    |
| quality           | Int    | Image quality 1-10                                               |

## Example 1
Saving the gif to a file
```
var htmlToGif = require('html-to-gif'),
	fs = require('fs');

var options = {
	dimensions:{
		width: 800,
		height: 650,
	},
	url: 'http://www.goodboydigital.com/pixijs/examples/12-2/',
	duration: 3000,
	repeat: true,
	delay:  30,
	quality: 3,
};

var filePath = __dirname + '/myanimated.gif';

htmlToGif(options, () => {
	console.log('finished');
}).pipe(fs.createWriteStream(filePath));
```

## Example 2
Taking the gif stream and serving it with ExpressJS
```
var htmlToGif = require('html-to-gif'),
    express = require('express'),
    app = express(),
    options = {
        dimensions:{
            width: 800,
            height: 650,
        },
        url: 'http://www.goodboydigital.com/pixijs/examples/12-2/',
        duration: 3000,
        repeat: true,
        delay:  30,
        quality: 3,
    };

app.get('/', function(req, res) {
    var gifStream = htmlToGif(options),
        animatedGif = '';

    // Capture the streaming output
    gifStream.on('data', function(data) {
        animatedGif += data.toString('binary');
    });

    // Once complete, write it out to the browser
    gifStream.on('end', function() {
        res.set('Content-Type', 'image/gif');
        res.end(animatedGif, 'binary');
    });
});

app.listen(3000);
console.log('http://localhost:3000')
```

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