code: def rotate_scale(im, angle, scale, borderValue=0, interp=cv2.INTER_CUBIC):
      
      im = np.asarray(im, dtype=np.float32)
      rows, cols = im.shape
      M = cv2.getRotationMatrix2D(
          (cols / 2, rows / 2), -angle * 180 / np.pi, 1 / scale)
      im = cv2.warpAffine(im, M, (cols, rows),
                          borderMode=cv2.BORDER_CONSTANT,
                          flags=interp,
                          borderValue=borderValue)  # REPLICATE
      return im
docs: Rotates and scales the image
  
      Parameters
      ----------
      im: 2d array
          The image
      angle: number
          The angle, in radians, to rotate
      scale: positive number
          The scale factor
      borderValue: number, default 0
          The value for the pixels outside the border (default 0)
  
      Returns
      -------
      im: 2d array
          the rotated and scaled image
  
      Notes
      -----
      The output image has the same size as the input.
      Therefore the image may be cropped in the process.