This project has been archived by its maintainers, and is no longer receiving any updates.
Pillow Image-Format Converter
Description
pil_image_converter is a Python package and CLI tool for converting images between different formats using the Pillow library. It supports conversions between JPG, PNG, BMP, and WebP formats.
Contributions always welcome!
Features
- Convert images between JPG, PNG, BMP, and WebP formats
- Batch conversion of multiple images
- Simple command-line interface
- Skips conversion if the input and output formats are the same
Usage
Dependencies
- Pillow >= 11.0.0
Setup
To set up the development environment:
- Clone the repository
- Install PDM if you haven't already:
pip install pdm - Install dependencies:
pdm install - Convert images:
python main.py ./input_image.jpg ./output_image.png png
Using main.py directly as a CLI tool (Recommended)
If you've cloned the repository or downloaded the source code, you can use the main.py file directly:
- Navigate to the directory containing
main.py - Run the following command:
python main.py <input_path> <output_path> <output_format>
Example:
python main.py ./input_image.jpg ./output_image.png png
For batch conversion:
python main.py ./input_directory ./output_directory png
Note: You should use quotations for paths containing spaces.
-> Ex.: python main.py "./input directory" "./output directory" jpg
Using the pil_image_converter package
You can use the pil_image_converter package directly from the command line:
python -m pil_image_converter <input_path> <output_path> <output_format>
<input_path>: Path to the input image file or directory<output_path>: Path to save the converted image(s)<output_format>: Desired output format (jpg, png, bmp, or webp)
Example:
python -m pil_image_converter ./input_image.jpg ./output_image.png png
For batch conversion, provide a directory as the input path:
python -m pil_image_converter ./input_directory ./output_directory png
Using pil_image_converter in your own projects
-
First, ensure you're working within a virtual environment with PDM:
pdm install -
In your Python script, import the necessary functions:
from pil_image_converter import collect_images, ImageConverter
To convert a single image, use the ImageConverter class directly:
converter = ImageConverter('path/to/input/image.jpg', 'path/to/output/image.png', 'png')
converter.convert()
For batch conversion, you can pass in directories as arguments instead of individual image paths. Then, use the collect_images function and loop through the results:
from pil_image_converter import collect_images, ImageConverter
input_directory = 'path/to/input/directory'
output_directory = 'path/to/output/directory'
output_format = 'png'
image_files = collect_images(input_directory)
for input_path in image_files:
filename = os.path.basename(input_path)
name, _ = os.path.splitext(filename)
output_path = os.path.join(output_directory, f"{name}.{output_format}")
convert_image(input_path, output_path, output_format)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Version
3.0.0
Metadata
Release files for pil_image_converter 3.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pil_image_converter-3.0.3.tar.gz | 7.1 kB | Without provenance | Details for pil_image_converter-3.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pil_image_converter-3.0.3-py3-none-any.whl | Python 3 | none | any | Details for pil_image_converter-3.0.3-py3-none-any.whl |
Total release size: 13.9 kB
Release files / pil_image_converter-3.0.3.tar.gz
| Download URL | pil_image_converter-3.0.3.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
027a1f9794dd723d46b125963828e01fb1b755a2f37ca93a2c673f802ea31662
|
|
BLAKE2b-256 checksum How to use checksums |
b5bb9bf8f3304a85f0bdb1112b8557e6e48a7abe21837d2adede0cbde585db10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.22.3 CPython/3.10.11 Windows/10
|
Release files / pil_image_converter-3.0.3-py3-none-any.whl
| Download URL | pil_image_converter-3.0.3-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff84f7e4f5115c921a0bd838e456e37a4e12f688b4672de1ec6d836ed94a3e68
|
|
BLAKE2b-256 checksum How to use checksums |
2de8ed2ee1d327fcf2d715a091a07c23487852650480e9f06608ce6597cb968f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.22.3 CPython/3.10.11 Windows/10
|
Security for pil_image_converter 3.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.