home ~ socials ~ projects ~ rss

Convert an Image to base64 on the Command Line

October 2021

Use the base64 command with the > filename operator to convert an image to base64 and save the string in a file:

base64 IMAGE_FILE.jpg > OUTPUT.txt

You can also export it into an environmental variable for use in other scripts

export IMAGE_STRING=$(base64 IMAGE_FILE.jpg)
echo $IMAGE_STRING
end of line
Share link:
https://www.alanwsmith.com/en/20/eo/xz/7c/?convert-an-image-to-base64-on-the-command-line