A Python utility for extracting base64-encoded JPEG images from HTML files, saving them as JPEG files, and updating the HTML to reference these images by their new file paths.
These instructions will guide you through setting up and running base64-image-extractor
on your local machine.
- Python 3.x
- pip
- virtualenv
-
Clone the Repository
Start by cloning the repository to your local machine:
git clone https://github.com/miguelsm/base64-image-extractor.git cd base64-image-extractor
-
Set Up a Virtual Environment
Create a virtual environment to manage the project's dependencies separately from your global Python environment:
python3 -m virtualenv venv
Activate the virtual environment:
-
On Windows:
.\venv\Scripts\activate
-
On macOS and Linux:
source venv/bin/activate
-
-
Install Dependencies
Install the project dependencies from the
requirements.txt
file:pip install -r requirements.txt
To run base64-image-extractor
, ensure your virtual environment is activated, then execute the script with the path to your HTML file as an argument. The script will extract base64-encoded JPEG images, save them as files, and update the HTML file to reference these images by their new paths.
python base64_image_extractor.py path/to/your/file.html
The modified HTML will be printed to standard output. If you want to save the modified HTML to a new file, you can redirect the output like so:
python base64_image_extractor.py path/to/your/file.html > path/to/your/modified_file.html
Once you are done, you can deactivate the virtual environment:
deactivate
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or improvements.
This project is licensed under the MIT License - see the LICENSE file for details.