UNPKG
string2png
Version:
latest (1.0.1)
1.0.1
1.0.0
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
Convert strings in various formats to tiny images
github.com/koopero/string2png
koopero/string2png
string2png
/
src
/
datauri.js
8 lines
(6 loc)
•
206 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
'use strict'
module
.
exports
=
function
datauri
(
data, options
) {
if
( !
Buffer
.
isBuffer
( data ) ) data =
require
(
'./png'
)( data, options )
return
'data:image/png;base64,'
+data.
toString
(
'base64'
) }