code: def compute_ratio_and_resize(img, width, height, model_height):
      """
      Calculate ratio and resize correctly for both horizontal text
      and vertical case
      """
      ratio = width / height
      if ratio < 1.0:
          ratio = calculate_ratio(width, height)
          img = cv2.resize(
              img,
              (model_height, int(model_height * ratio)),
              interpolation=Image.Resampling.LANCZOS,
          )
      else:
          img = cv2.resize(
              img,
              (int(model_height * ratio), model_height),
              interpolation=Image.Resampling.LANCZOS,
          )
      return img, ratio
  
imports: from __future__ import print_function
  import torch
  import pickle
  import numpy
  import math
  import cv2
  from PIL import Image, JpegImagePlugin
  from scipy import ndimage
  import hashlib
  import sys, os
  from zipfile import ZipFile
  from .imgproc import loadImage
label_desc: Use image node_id 12 for calling a global function with example usage: compute_ratio_and_resize(img, width, height, model_height) and returns: img,  ratio