Ebmed base64 encoded images from Linux

image_editor_compbase64 is an encoding format that represents binary data in ASCII string format. HTML emails embed inline images and other mime types in base64 format. Web pages also load much faster if images are embedded in the pages in base64 format rather than linking them. In this article we will explore a way to do this on Linux.

Most Linux distributions come with the base64 utility. On Ubuntu, it is included in the packages coreutils.

To dump the base64 data of an image, run:

$ base64 -w 0 image.png > image.base64

To embed the image, open the output file in a text editor and copy the complete data. Then paste it replacing _imgdata_ in the following format:

<img src="data:image/png;base64,_imgdata_" />

Note that this would work for any image file format. You just need to change the image mimetype above.

Unfortunately, this doesn’t work on WP sites, as the data: URI is stripped as untrusted.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

search previous next tag category expand menu location phone mail time cart zoom edit close