def resizeImg(imgPath,img_size):
img = imread(imgPath)
h, w, _ = img.shape
scale = 1
if w >= h:
new_w = img_size
if w >= new_w:
scale = float(new_w) / w
new_h = int(h * scale)
else:
new_h = img_size
if h >= new_h:
scale = float(new_h) / h
new_w = int(w * scale)
new_img = imresize(img, (new_h, new_w), interp='bilinear')
imsave(imgPath,new_img)
#Download img
#Later we can do multi thread apply workers to do faster work
评论列表
文章目录