jstransformer-datauri
v1.0.4
Published
DataURI support for JSTransformers.
Downloads
13
Readme
JSTransformer DataUri
Converts file into DataURI representation;
jstransformer-datauri
DataURI support for JSTransformers.
Installation
npm install jstransformer-datauri
CLI
$ datauri /home/vganzin/1black.jpeg
data:image/jpeg;base64,/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAj/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AJWAB//Z
API
var datauri = require('jstransformer')(require('jstransformer-datauri'))
datauri.render('./Octocat.png').body.slice(0, 100)
//=> data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAKZCAYAAABAwk9hAAB/FUlEQVR4AezBMQEAAAjAIJvM/imt4Q
Optional resize
var datauri = require('jstransformer')(require('jstransformer-datauri'))
datauri.render('./Octocat.png:10x10').body
//=> data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAABCAYAAADn9T9+AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAMklEQVQI12NQU5DjUDUw5dIzMAxf2ttwYOfMjr97Znf9WdBZc0pBQd6cjZWbUUNVlRMAH8sNpOmtCWUAAAAASUVORK5CYII=
License
MIT