ImageArtificer is a powerful Python utility for loading, processing, and enhancing images. Just like a skilled artisan, it helps you transform raw images into polished visuals while maintaining clarity and composition.
With ImageArtificer, you can:
- Load Images: Import images from local storage, URLs, Google Cloud Storage, or Google Search.
- Scale & Pad: Resize images while maintaining aspect ratio, with optional padding using dominant or complementary colors.
- Analyze Colors: Extract dominant and complementary colors to enhance your images.
- Apply Overlays: Add transparent overlays and tint them with specified colors.
- Save Images: Export images in JPEG, PNG, or WEBP, with proper handling of transparency.
This class depends on several libraries, including PIL, ColorThief, icrawler, and google-cloud-storage.
Install ImageArtificer directly from GitHub:
pip install git+https://github.com/south-bend-code-works/image-artificer.git- Python 3.6 or higher
- Required Python libraries:
PillowMatplotlibcolorthieficrawlergoogle-cloud-storagepillow-heif
Install dependencies using:
pip install -r requirements.txtfrom image_artificer import ImageArtificer
# Load an image from local disk
img_art = ImageArtificer.from_local_disk("example.png")
# Resize with padding
resized_img = img_art.resize_and_pad_image(size=(800, 800), padding_color="dominant")
# Apply an overlay
resized_img.apply_overlay("overlay.png", color="#FF5733")
# Save as PNG
resized_img.save_to_local("output_image.png", format="PNG")img_art = ImageArtificer.from_url("https://example.com/sample.jpg")
img_art.save_to_local("downloaded.png", format="PNG")from google.cloud import storage
gcs_client = storage.Client()
img_art.save_to_gcs(gcs_client, "my-bucket", "folder/output.webp", format="WEBP")| Operation | JPEG | PNG | WEBP |
|---|---|---|---|
| Load | ✅ | ✅ | ✅ |
| Resize | ✅ | ✅ | ✅ |
| Transparency | ❌ | ✅ | ✅ |
| Save | ✅ | ✅ | ✅ |
- JPEG: No transparency (converts RGBA to RGB).
- PNG & WEBP: Transparency is fully supported.
This project is licensed under the MIT License. See the LICENSE file for details.
We welcome contributions! Feel free to:
- Open an issue for bugs or feature requests.
- Submit a pull request for improvements.
🚀 Happy coding with ImageArtificer!