Skip to content

embed image files in markdown as base64

License

Notifications You must be signed in to change notification settings

tanvirp/embed-images

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

embed-images

NPM version js-standard-style

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

license

MIT

About

embed image files in markdown as base64

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%