Last active
February 1, 2018 19:38
-
-
Save unabridgedxcrpt/990f4d8f90520c83051eea9a26b083a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stored for reference. Base64 encoding of images. | |
https://stackoverflow.com/questions/16918602/how-to-base64-encode-image-in-linux-bash-shell/16918665 | |
Mac OS terminal modification: base64 -i <in-file> | |
Usage: base64 [-hvD] [-b num] [-i in_file] [-o out_file] | |
-h, --help display this message | |
-D, --decode decodes input | |
-b, --break break encoded string into num character lines | |
-i, --input input file (default: "-" for stdin) | |
-o, --output output file (default: "-" for stdout) | |
Single line result on Linux: | |
base64 -w 0 DSC_0251.JPG | |
For HTML: | |
echo "data:image/jpeg;base64,$(base64 -w 0 DSC_0251.JPG)" | |
As file: | |
base64 -w 0 DSC_0251.JPG > DSC_0251.JPG.base64 | |
In variable: | |
IMAGE_BASE64="$(base64 -w 0 DSC_0251.JPG)" | |
In variable for HTML: | |
IMAGE_BASE64="data:image/jpeg;base64,$(base64 -w 0 DSC_0251.JPG)" | |
See: http://www.greywyvern.com/code/php/binary2base64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment