embed-images
v1.0.1
Published
embed markdown image files as base64
Downloads
8
Maintainers
Readme
embed-images
embed image files in markdown as base64
Takes a markdown file with images referenced by file and embeds the image content as base64
. Useful if you want to render standalone markdown files without serving or hosting individual image files. Currently only handles png
files.
install
Add to your project with
npm install embed-images --save
Or install as a command line tool with
npm install embed-images -g
example
If you have a file example.md
with
# this is a markdown file with an image
![png](example.png)
And call
embed-images example.md
You'll get
# this is a markdown file with an image
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" />
use as a module
Just provide filenames for input and output and an optional callback.
require('embed-images')(input, output, cb)
If you don't specify an output the result will be logged to stdout.
use as a cli
Just specify an input and pipe to stdout
embed-images input.md > output.md
Or specify an output file
embed-images input.md -o output.md