code: def resize_img(self, img, keep_ratio=True):
      h, w, _ = img.shape
      if keep_ratio:
          t_h = (
              self.target_size
              if h >= w
              else int(h * self.target_size / w)
          )
          t_w = (
              self.target_size
              if h <= w
              else int(w * self.target_size / h)
          )
      else:
          t_h = t_w = self.target_size
      img = cv2.resize(img, (t_w, t_h))
      return img, (t_h, t_w)
  
imports: import numpy
  from PIL import Image, ImageDraw
  import cv2
  from shapely.geometry import Polygon
  import math
  from ppocr.utils.poly_nms import poly_intersection
label_desc: Use image node_id 2 for calling the SquareResizePad obj's underlying member method code with example usage: obj.resize_img(img, keep_ratio) and returns: img,  t_h,  t_w