# tf.compat.v1.image.resize

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/image_ops_impl.py#L1524-L1607) |

Resize `images` to `size` using the specified `method`.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.image.resize_images`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/image/resize)

<br />

    tf.compat.v1.image.resize(
        images,
        size,
        method=ResizeMethodV1.BILINEAR,
        align_corners=False,
        preserve_aspect_ratio=False,
        name=None
    )

Resized images will be distorted if their original aspect ratio is not
the same as `size`. To avoid distortions see
[`tf.image.resize_with_pad`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/image/resize_with_pad) or [`tf.image.resize_with_crop_or_pad`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/image/resize_with_crop_or_pad).

The `method` can be one of:

- **[`tf.image.ResizeMethod.BILINEAR`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/image/ResizeMethod#BILINEAR)** : [Bilinear interpolation.](https://en.wikipedia.org/wiki/Bilinear_interpolation)
- **[`tf.image.ResizeMethod.NEAREST_NEIGHBOR`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/image/ResizeMethod#NEAREST_NEIGHBOR)** : [Nearest neighbor interpolation.](https://en.wikipedia.org/wiki/Nearest-neighbor_interpolation)
- **[`tf.image.ResizeMethod.BICUBIC`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/image/ResizeMethod#BICUBIC)** : [Bicubic interpolation.](https://en.wikipedia.org/wiki/Bicubic_interpolation)
- **[`tf.image.ResizeMethod.AREA`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/image/ResizeMethod#AREA)**: Area interpolation.

The return value has the same type as `images` if `method` is
[`tf.image.ResizeMethod.NEAREST_NEIGHBOR`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/image/ResizeMethod#NEAREST_NEIGHBOR). It will also have the same type
as `images` if the size of `images` can be statically determined to be the
same as `size`, because `images` is returned in this case. Otherwise, the
return value has type `float32`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `images` | 4-D Tensor of shape `[batch, height, width, channels]` or 3-D Tensor of shape `[height, width, channels]`. |
| `size` | A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The new size for the images. |
| `method` | ResizeMethod. Defaults to [`tf.image.ResizeMethod.BILINEAR`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/image/ResizeMethod#BILINEAR). |
| `align_corners` | bool. If True, the centers of the 4 corner pixels of the input and output tensors are aligned, preserving the values at the corner pixels. Defaults to `False`. |
| `preserve_aspect_ratio` | Whether to preserve the aspect ratio. If this is set, then `images` will be resized to a size that fits in `size` while preserving the aspect ratio of the original image. Scales up the image if `size` is bigger than the current size of the `image`. Defaults to False. |
| `name` | A name for this operation (optional). |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | if the shape of `images` is incompatible with the shape arguments to this function |
| `ValueError` | if `size` has invalid shape or type. |
| `ValueError` | if an unsupported resize method is specified. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| 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]`. ||

<br />