Some PIL utility functions I frequently use.
Project description
cjm-pil-utils
Install
pip install cjm_pil_utils
How to use
get_img_files
from cjm_pil_utils.core import get_img_files
from pathlib import Path
img_dir = Path('../images/')
img_paths = get_img_files(img_dir)
img_paths
[PosixPath('../images/cat.jpg'), PosixPath('../images/depth-cat.png')]
resize_img
from cjm_pil_utils.core import resize_img
from PIL import Image # For working with images
img_path = img_paths[0]
src_img = Image.open(img_path).convert('RGB')
print(f"Image Size: {src_img.size}")
resized_img = resize_img(src_img, target_sz=384, divisor=32)
print(f"New Image Size: {resized_img.size}")
Image Size: (768, 512)
New Image Size: (576, 384)
stack_imgs
from cjm_pil_utils.core import stack_imgs
stacked_imgs = stack_imgs([resized_img, resized_img])
print(f"Stacked Image Size: {stacked_imgs.size}")
Stacked Image Size: (576, 768)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cjm-pil-utils-0.0.2.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for cjm_pil_utils-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4980372ad60da93fee69d5d8c2821882d0c059b226308f2fb2c9bf8c11f96e21 |
|
MD5 | 509caf52ce737e8a9dc4c11eaa4fd068 |
|
BLAKE2b-256 | 68924e2a4c092b8ce9fa14e95445ffe97bf083a4b536296bb21d3fecbebeda6c |