tf.image.resize_with_pad

View source on GitHub

Resizes and pads an image to a target width and height.

tf.image.resize_with_pad(
    image, target_height, target_width, method=ResizeMethod.BILINEAR,
    antialias=False
)

Resizes an image to a target width and height by keeping the aspect ratio the same without distortion. If the target dimensions don't match the image dimensions, the image is resized and then padded with zeroes to match requested dimensions.

Args:

Raises:

Returns:

Resized and padded image. If images was 4-D, a 4-D float Tensor of shape [batch, new_height, new_width, channels]. If images was 3-D, a 3-D float Tensor of shape [new_height, new_width, channels].