Skip to content

Instantly share code, notes, and snippets.

View IdeaKing's full-sized avatar
💭
Thinking

Thomas Chia IdeaKing

💭
Thinking
View GitHub Profile
@IdeaKing
IdeaKing / resize_with_pad_cv2.py
Last active December 3, 2025 07:02
Resize image with padding using CV2
import cv2
from typing import Tuple
def resize_with_pad(image: np.array,
new_shape: Tuple[int, int],
padding_color: Tuple[int] = (255, 255, 255)) -> np.array:
"""Maintains aspect ratio and resizes with padding.
Params:
image: Image to be resized.