Alongside RequestsUtils.py and ImageSearchSession.py, let's create another file called ResizeUtils.py with the following import statements:
import numpy # Hint to PyInstaller
import cv2
For display in a GUI, images usually have to be resized. One popular mode of resizing is called aspect fill. Here, we want to preserve the image's aspect ratio while changing its larger dimension (width for a landscape image or height for a portrait image) to a certain value. OpenCV does not directly provide this resizing mode, but it does provide a function, cv2.resize, which accepts an image, target dimensions, and optional arguments, including an interpolation method. We can write our own function, cvResizeAspectFill, which accepts an image, maximum size, and preferred interpolation methods for upsizing and downsizing. It determines the appropriate...