Last Updated: February 25, 2016
·
689
· ameijernl

Base64 encode images (Mac terminal)

No installs required, just change the filename and you're all set!

$ openssl enc -base64 -in YOUR_FILE.png | tr -d '\n'

Even better:
First compress / minify your images (using a tool like ImageOptim).

Uncompressed .png file (200x70 pixels) outputs as 4764 characters
The same file, compressed: outputs as 1749 characters! Which is only 36% of the original size!