Skip to content

Instantly share code, notes, and snippets.

@JacopoDaeli
Last active November 29, 2016 05:25
Show Gist options
  • Save JacopoDaeli/9ad595589f20ae81ec594f39810239ae to your computer and use it in GitHub Desktop.
Save JacopoDaeli/9ad595589f20ae81ec594f39810239ae to your computer and use it in GitHub Desktop.
Create thumbs from image
import cv2
def image_to_thumbs(img):
"""Create thumbs from image"""
height, width, channels = img.shape
thumbs = {"original": img}
sizes = [640, 320, 160]
for size in sizes:
if (width >= size):
r = (size + 0.0) / width
max_size = (size, int(height * r))
thumbs[str(size)] = cv2.resize(img, max_size, interpolation=cv2.INTER_AREA)
return thumbs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment