Unclear exception when using resize_with_pad on images with original_image_ratio > target_side
Hi @EricPulido ,

I have tested the code. The error is arising from C++ backend hence description is not clear.It seems generated from this line of code from **ResizeBilinearOp**.

https://github.com/tensorflow/tensorflow/blob/2d7328762fa39668b1f802788f6143c4ffa1e1c4/tensorflow/core/kernels/image/resize_bilinear_op.cc#L58 

which in turn calling output validation from here.

https://github.com/tensorflow/tensorflow/blob/b487f0246c5804978f86f0a6bf2add1b911af23c/tensorflow/core/util/image_resizer_state.h#L123-L124

Here given `'input_size'` is ( 1,2000). When it scales the input size using `'target_size'` (768,768), the `'input_size'` dimension becomes `'0'` making the above check fails and generating the error. You can refer the [gist](https://colab.sandbox.google.com/gist/SuryanarayanaY/0310f3f305f0e66e3d7d3f34b0690dfc/62456.ipynb) for aforesaid calculations.



>When using tf.image.resize_with_pad, if the ratio of the dimensions of the original image is bigger than one of the transformations width or height, then it will fail with
output dimensions must be positive [Op:ResizeBilinear]

I am not actually getting this. Can you please elaborate ?

Thanks!

 This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62456">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62456">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

source

### TensorFlow version

v1.12.1-101328-g60ccf67fad1 2.16.0-dev20231018

### Custom code

Yes

### OS platform and distribution

macOS 13.6.2 

### Mobile device

_No response_

### Python version

3.11

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

When using `tf.image.resize_with_pad`, if the ratio of the dimensions of the original image is bigger than one of the transformations width or height, then it will fail with

```output dimensions must be positive [Op:ResizeBilinear]```

While it's true that the process itself as set up generates output dimensions that are zero, this behaviour seems unexpected since it's possible to individually resize and pad without issue. 

### Standalone code to reproduce the issue

```shell
import tensorflow as tf

image = tf.zeros(shape=(1, 2000, 3))
out = tf.image.resize_with_pad(
    image,
    target_height=768,
    target_width=768,
)
```
```


### Relevant log output

```shell
Traceback (most recent call last):
  File "...venv/lib/python3.11/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "...venv/lib/python3.11/site-packages/tensorflow/python/framework/ops.py", line 5883, in raise_from_not_ok_status
    raise core._status_to_exception(e) from None  # pylint: disable=protected-access
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __wrapped__ResizeBilinear_device_/job:localhost/replica:0/task:0/device:CPU:0}} output dimensions must be positive [Op:ResizeBilinear] name: 
python-BaseException
```
