In [72]:
import numpy as np
from PIL import Image
import cv2 as cv
import matplotlib.pyplot as plt
from resizeimage import resizeimage
%matplotlib inline

def reshapeToSquare(img, length):
    output = resizeimage.resize('contain', img, [length, length])
    return np.asarray(output)
    
with open('../sample_data/1.jpg', 'r') as f:
    with Image.open(f) as image:
        input = np.asarray(image)
#         output = reshapeToSquare(input, 280)
        print(input.shape)


(2525, 1766, 3)

In [84]:
dst = np.zeros([280, 280, 3])
# print(input)
dst = cv.resize(input, (280, 280), interpolation = cv.INTER_LANCZOS4);
# print(dst.shape)
# cv.imshow('image',dst)
plt.imshow(dst)
# plt.imshow(input)


Out[84]:
<matplotlib.image.AxesImage at 0x10f4a7e50>