# text2png2

> Convert text to png for node.js

Latest version **0.0.1** (published 2022-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install text2png2
pnpm add text2png2
yarn add text2png2
bun add text2png2
```

Provides the command `text2png`.

## 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.1 |
| Published | 2022-06-21 |
| First published | 2022-06-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | elijah999mgenezis |
| Maintainers | elijahmstarline |
| Keywords | text, png |

## Links

- npm: https://www.npmjs.com/package/text2png2
- Repository: https://github.com/elijah999mgenezis/text2png2
- Homepage: https://github.com/elijah999mgenezis/text2png2#readme
- Issues: https://github.com/elijah999mgenezis/text2png2/issues
- npm.io page: https://npm.io/package/text2png2

## Dependencies (2)

- [canvas](https://npm.io/package/canvas.md) ^2.9.1
- [commander](https://npm.io/package/commander.md) ^8.3.0

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 0.0.1 (latest) — 2022-06-21

## README

[![NPM](https://nodei.co/npm/text2png.png)](https://nodei.co/npm/text2png2/)
[![npm version](https://badge.fury.io/js/text2png.svg)](https://badge.fury.io/js/text2png2)
[![Build Status](https://travis-ci.org/tkrkt/text2png.svg?branch=master)](https://travis-ci.org/tkrkt/text2png2)

# text2png2: text-to-png generator for Node.js
# updated: this package is update of text2png with new node version 18

```js
text2png('Create png image\nfrom multi-line text!');
```

![text2png](./img/text2png.png)

## Quick start

text2png depends on [node-canvas](https://github.com/Automattic/node-canvas).
See [node-canvas wiki](https://github.com/Automattic/node-canvas/wiki) on installing node-canvas.

```
$ npm install text2png2
```

```js
var fs = require('fs');
var text2png = require('text2png');
fs.writeFileSync('out.png', text2png('Hello!', {color: 'blue'}));
```

## Option

``text2png(text, option)``

|param|default|
|---|---|
|text|(required)|
|option.font|'30px sans-serif'|
|option.textAlign|'left'|
|option.color (or option.textColor)|'black'|
|option.backgroundColor (or option.bgColor)|'transparent'|
|option.lineSpacing|0|
|option.strokeWidth|0|
|option.strokeColor|'white'|
|option.padding|0|
|option.padding(Left\|Top\|Right\|Bottom)|0|
|option.borderWidth|0|
|option.border(Left\|Top\|Right\|Bottom)Width|0|
|option.borderColor|'black'|
|option.localFontPath||
|option.localFontName||
|option.output|'buffer'|

``option.color = '#000' | 'rgb(0, 0, 0)' | 'black' | ...``

``option.output = 'buffer' | 'stream' | 'dataURL' | 'canvas'``

``option.strokeWidth = 1 | 2 | ... `` A padding may have to be set to avoid cutoff of stroke

``'canvas'`` returns [node-canvas](https://github.com/Automattic/node-canvas) object.

If you want to use any custom fonts without installing, use `localFontPath` and `localFontName` property.

```js
text2png('with custom fonts', {
  font: '50px Lobster',
  localFontPath: 'fonts/Lobstar-Regular.ttf',
  localFontName: 'Lobster'
});
```

## Command line interface

```
$ npm install -g text2png2
$ text2png --help
$ text2png -t "Hello!" -o "output.png"
```

## Example

```js
text2png('Example\nText', {
  font: '80px Futura',
  color: 'teal',
  backgroundColor: 'linen',
  lineSpacing: 10,
  padding: 20
});
```

![ExampleText](./img/exampleText.png)

Enjoy!

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