# What is “fill” algorithm used for image resizing and cropping?

I was going through this documentation directed by Codelab-Developer-Google. In order to resize an image, the notebook is using the "fill" algorithm. See the below code

def resize_and_crop_image(image, label):
# Resize and crop using "fill" algorithm:
# always make sure the resulting image
# is cut out from the source image so that
# it fills the TARGET_SIZE entirely with no
# black bars and a preserved aspect ratio.
w = tf.shape(image)[0]
h = tf.shape(image)[1]
tw = TARGET_SIZE[1]
th = TARGET_SIZE[0]
resize_crit = (w * th) / (h * tw)
image = tf.cond(resize_crit < 1,
lambda: tf.image.resize(image, [w*tw/w, h*tw/w]), # if true
lambda: tf.image.resize(image, [w*th/h, h*th/h])  # if false
)
nw = tf.shape(image)[0]
nh = tf.shape(image)[1]
image = tf.image.crop_to_bounding_box(image, (nw - tw) // 2, (nh - th) // 2, tw, th)
return image, label


I have gone through google search results and didn't find any such algorithm for image resizing and cropping. Please help me understand

1. What is this algorithm doing?
2. What is the role of the equation used in crop_to_bounding_box function?