Effortlessly convert any image of your choice to base64 and back using Python with the two scripts provided below.
Download the scripts using the GitHub interface, or clone the repository with this link – https://github.com/thewhitechild/image-base64-converter
After downloading or cloning the repository, navigate to the folder containing the scripts. Each file name clearly indicates its function.
Converting an image to base64
First, ensure that Python is installed. Then, run the script imagetobase64.py by executing the command below in your terminal.
py imagetobase64.py your-picture.jpg
After successful execution, you should see a success message and the location where the base64 text file was saved.
Converting a base64 text file to an image
Run the base64toimage.py script using the command below.
py base64toimage.py your-base64-file.txt
The default image format that the script will decode from base64 is ‘jpeg’. To specify a different format, simply add it to the command as shown below.
py base64toimage.py your-base64-file.txt png
Converting images to and from Base64 using Python is a straightforward process with the provided scripts. With just a few commands, you can easily manage image data in a concise format.