Skip to content

pandoc base64 img2file

Benct Philip Jonsson edited this page Jul 10, 2015 · 3 revisions

This is the documentation for pandoc-base64-img2file.pl.

SYNOPSIS

pandoc -F pandoc-base64-img2file.pl \
      [-M image_dir=decoded_images] \
      -f html some.html -t FORMAT -o FILE

DESCRIPTION

Pandoc filter which intercepts image elements with data URIs with Base64 encoded image data, decodes the data and writes the image to a file with a hopefully correct extension in a directory designated by the user as a metadata value, then replaces the URL in the output document with the path to that file.

image_dir defaults to ./decoded_images

Filenames are on the pattern "decodedImage0000.EXT", where "0000" is incremented for each data URI encountered and "EXT" actually is whatever comes after "image/" in the MIME type of the data URI.

IMPORTANT

You must make sure that there is no whitespace in the data URIs in the source, and thus that each is all on one line, or pandoc will become confused.

Images files are overwritten with each run. Switch image directory or rename the old directory if that is a problem.

PREREQUISITES

Data::Rmap
Data::Util
JSON::MaybeXS
List::AllUtils~0.09
MIME::Base64::Perl
Path::Tiny~0.011
Clone this wiki locally