# Image Resize

This function block changes the size of an incoming image. Use it to scale images up or down with selectable interpolation methods so downstream blocks receive images at the required dimensions.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

* `Image Any` This is the image you want to resize.
* `Width` Desired output width in pixels. Optional — leave empty to preserve the original width.
* `Height` Desired output height in pixels. Optional — leave empty to preserve the original height.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

* `Image Any` The resized image.

## 🕹️ Controls <a href="#controls" id="controls"></a>

* `Interpolation Method` Choose how pixels are sampled when resizing. Common choices you will see: `INTER_NEAREST`, `INTER_LINEAR`, `INTER_AREA`, `INTER_CUBIC`, `INTER_LANCZOS4`.
  * Use `INTER_AREA` for downscaling (good for reducing aliasing).
  * Use `INTER_LINEAR` for general-purpose resizing (balanced speed and quality).
  * Use `INTER_CUBIC` or `INTER_LANCZOS4` when upscaling and higher image quality is required (slower).

## ⚙️ How it runs <a href="#running-mechanism" id="running-mechanism"></a>

When this block runs it takes the provided `Image Any` and uses the chosen `Interpolation Method` to produce a new image at the requested `Width` and `Height`. If either dimension is left blank, that axis will keep the original image size. The resized image is sent to the output for the following blocks in the flow.

## 🎯 Key features <a href="#features" id="features"></a>

* Precise control of output size using explicit width and height.
* Multiple interpolation options so you can trade off speed and quality.
* Works with any image-producing block and prepares images for models or visualization.

## 📝 Usage tips <a href="#usage" id="usage"></a>

* If you need to preview results, connect the output to `Show Image`.
* Crop first then resize for best results when the region of interest is smaller than the full image. Use `Image ROI` or `Slice Image` before this block.
* To avoid stretching and preserve aspect ratio, crop or pad the image first. Use `Image Padding` to add borders instead of distorting the image.
* For models that expect smaller inputs (object detection, OCR), resize the image to the model’s preferred dimensions before feeding it to blocks like `Object Detection (D-FINE)`, `Object Detection - Custom`, `OCR`, or `OCR (EasyOCR)`.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Preparing for OCR: enlarge a cropped text region with this block before connecting to `OCR` or `OCR (EasyOCR)` to improve recognition accuracy.
* Preparing for detection: resize camera frames to a consistent size before `Object Detection (D-FINE)` or `Object Detection - Custom` so detection thresholds and box sizes behave predictably.
* Preserve details when upscaling: when you must enlarge small images, pick `INTER_CUBIC` or `INTER_LANCZOS4` for better visual quality.
* Keep aspect ratio safe: to avoid distorted objects, use `Image ROI` or `Image Padding` to make the crop square (or match the model input) then resize.
* Quick checks: attach `Show Image` right after this block to confirm the resized output visually.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* Blurry result after upscaling
  * Try a higher-quality interpolation such as `INTER_CUBIC` or `INTER_LANCZOS4`.
* Important object appears squashed or stretched
  * Ensure aspect ratio is preserved. Crop or pad the image before resizing.
* Unexpected size or orientation
  * Verify the numeric values provided to `Width` and `Height` and preview with `Show Image`.
  * If only one dimension should change, leave the other empty to keep the original size for that axis.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/image-transformations/operations/image-resize.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
