base64 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
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.