https://github.com/peterjakubowski/image-editing-utilities
Python-based image editing utilities
https://github.com/peterjakubowski/image-editing-utilities
helper-functions image-editing image-processing python
Last synced: 8 months ago
JSON representation
Python-based image editing utilities
- Host: GitHub
- URL: https://github.com/peterjakubowski/image-editing-utilities
- Owner: peterjakubowski
- License: apache-2.0
- Created: 2024-12-11T19:54:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-05T03:23:26.000Z (over 1 year ago)
- Last Synced: 2025-02-05T04:22:57.392Z (over 1 year ago)
- Topics: helper-functions, image-editing, image-processing, python
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```commandline
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
```commandline
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)
```