Last active
November 29, 2016 05:25
-
-
Save JacopoDaeli/9ad595589f20ae81ec594f39810239ae to your computer and use it in GitHub Desktop.
Create thumbs from image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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