Skip to content

matthewberryman/text2png

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM npm version

text2png: text-to-png generator for Node.js

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

text2png

Quick start

$ npm install text2png
var fs = require('fs');
var text2png = require('text2png');
fs.writeFileSync('out.png', text2png('Hello!', {textColor: 'blue'}));

text2png depends on node-canvas.

See node-canvas wiki on installing node-canvas.

Option

text2png(text, option)

param default
text (required)
option.font '30px sans-serif'
option.textColor 'black'
option.bgColor null
option.lineSpacing 0
option.xpadding 0
option.ypadding 0
option.output 'buffer'

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

'canvas' returns node-canvas object.

Example

text2png('Example\nText', {
  font: '80px Futura',
  textColor: 'teal',
  bgColor: 'linen',
  lineSpacing: 10,
  xpadding: 20,
  ypadding: 20
});

ExampleText

Enjoy!

About

text-to-png generator for Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%