This is a Python script that converts PNG images to WebP format in bulk. The user selects a directory, and the script converts all PNG images in that directory. The converted images are saved in a converted subdirectory within the selected directory. After the conversion process, the converted subdirectory is automatically opened in the default file explorer.
- Python 3.x
- Pillow library
For all these code snippets use your terminal of choice. You can honestly copy and paste in the presented order and it should work.
-
Clone the repository:
git clone https://github.com/laztaxon/png-to-webp.git
-
Install Python:
- For Windows and macOS, download and install Python from the official website: https://www.python.org/downloads/
- For macOS, you can also use Homebrew:
brew install pythonor - For Linux, use your package manager, e.g.,
sudo apt install python3
-
Set up the virtual environment:
- For Windows, use:
python -m venv venv - For Unix or MacOS, use:
python3 -m venv venv
- For Windows, use:
-
Activate the virtual environment:
- For Windows, use:
venv\Scripts\activate - For Unix or MacOS, use:
source venv/bin/activate
- For Windows, use:
-
Install the required dependencies from the
requirements.txtfile:pip install -r requirements.txt
-
Running the script After installing the dependencies, you can run the main.py script:
python main.py
-
Deactivating the Virtual Environment
After you're done running the script, you can deactivate the virtual environment:
deactivate