Skip to content

peterjakubowski/Image-Editing-Utilities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image-Editing-Utilities

Python helper functions for image editing tasks.

rescale_width_height

Function for rescaling the width and height of an image to keep aspect ratio.

Pillow Image Usage

from PIL import Image
from image_utils.image_utils import rescale_width_height

# Open an image with PIL
img = Image.open(img_path)

# Retrieve the image's original dimensions
w, h = img.size

# Rescale the image's dimensions where size is the longest edge
scaled_wh = rescale_width_height(width=w, height=h, size=1000)

# Resize the image with new dimensions
resized_img = img.resize(scaled_wh, Image.Resampling.BICUBIC)

OpenCV Usage

import cv2
from image_utils.image_utils import rescale_width_height

# Open an image with OpenCV
img = cv2.imread(img_path)

# Retrieve the image's original dimensions
h, w, _ = img.shape

# Rescale the image's dimensions where size is the longest edge
scaled_wh = rescale_width_height(width=w, height=h, size=1000)

# Resize the image with new dimensions
resized_img = cv2.resize(img, scaled_wh, cv2.INTER_AREA)

About

Python-based image editing utilities

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages