Resize Image Keep Ratio Python. In this post i will summarize ways to resize an image to square shape with padding and keep its aspect ratio. In the following example we will scale the image only along x axis or horizontal axis.
Pip install python resize image usage. Python resize image takes as first argument a pil image and then size argument which can be a single integer or tuple of two integers. To resize an image opencv provides cv2 resize function.
The image module provides a class with the same name which is used to represent a pil image.
In this post i will summarize ways to resize an image to square shape with padding and keep its aspect ratio. Resize an image and keep aspect ratio posted by twig at 8 36 am monday january 14 2013 a handy little snippet that saves you a lot of work is the ability to quickly generate thumbnails from a source image. Cv2 resize image horizontally. Using cv2 imwrite we are writing the output of cv2 resize to a local image file.