- Download / checkout this repository.
- Copy b64 into your bin (usr/bin)
which b64
from any dir should returnusr/bin/b64
b64 will base64 encode all of the png files in the current directory, write them to a valid JSON array and create a file with the passed name to save them in. Simply cd to the directory you want to encode and run b64 myfile.json
. The result will be a file named myfile.json with the following format:
[
"data:image/png;base64, ...",
"data:image/png;base64, ...",
"data:image/png;base64, ..."
]
- Works on Mac only and requires openssl (openssl is usually installed by default).
- Does not support spaces in file names.
- Encoding large images / lots of images might take a while. Depending on what time it is or how you roll, grab some coffee or a beer.
- To keep your images in sequential order, name them with leading zeros (i.e. for hundreds of images:
001.png, 002.png ... 100.png
instead of1.png, 2.png ... 100.png
).