# Smart Resize

>  Smart image resize to arbitrary dimensions, powered by Nano Banana Pro with vision-LLM-guided prompting for composition-aware recomposition. Crop, cropping, resize ads.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/smart-resize`
- **Model ID**: `fal-ai/smart-resize`
- **Category**: image-to-image
- **Kind**: inference
**Tags**: realism, typography, visual, ads, 



## Pricing

Your request will cost $0.15 per output image (charged double for 4K outputs), plus a $0.05 minimum vision analysis fee per request. For $1.00, you can run this model 5 times at standard resolution. 

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`image_url`** (`string`, _required_):
  The URL of the source image to resize.
  - Examples: "https://storage.googleapis.com/falserverless/example_inputs/nano-banana-edit-input.png"

- **`target_sizes`** (`list<string>`, _required_):
  The list of target dimensions to generate, each written as ``<width>x<height>`` (e.g. ``"1920x1080"``). One output image is produced per target size (multiplied by ``num_images_per_size``). The endpoint internally picks the smallest nano-banana-pro preset that fully covers each target so the final image is a pixel-perfect match with no upscaling.
  - Array of string
  - Examples: ["1024x1024","1920x1080","768x1344"]

- **`prompt`** (`string`, _optional_):
  Optional extra instruction that is forwarded to nano-banana-pro alongside the auto-generated resize prompt. Leave empty to let the model preserve the original image content as closely as possible. Default value: `""`
  - Default: `""`
  - Examples: ""

- **`num_images_per_size`** (`integer`, _optional_):
  The number of nano-banana-pro variants to produce for each target size. The response images list will contain ``len(target_sizes) * num_images_per_size`` images in total. Default value: `1`
  - Default: `1`
  - Range: `1` to `4`

- **`resolution`** (`ResolutionEnum`, _optional_):
  Hint for the minimum resolution tier to use internally. The smart-resize algorithm may pick a higher tier automatically when the requested target size is too large for this tier. This field does not affect the final output dimensions — those come from ``target_sizes``. Default value: `"1K"`
  - Default: `"1K"`
  - Options: `"1K"`, `"2K"`, `"4K"`

- **`output_format`** (`OutputFormatEnum`, _optional_):
  The output image format. Default value: `"png"`
  - Default: `"png"`
  - Options: `"jpeg"`, `"png"`, `"webp"`

- **`safety_tolerance`** (`SafetyToleranceEnum`, _optional_):
  The safety tolerance level applied to the inner nano-banana-pro /edit calls. Higher numbers loosen safety filtering. Default value: `"4"`
  - Default: `"4"`
  - Options: `"1"`, `"2"`, `"3"`, `"4"`, `"5"`, `"6"`

- **`seed`** (`integer`, _optional_):
  Optional random seed forwarded to the inner nano-banana-pro /edit calls for reproducibility. The same seed is used for every target size when set.

- **`sync_mode`** (`boolean`, _optional_):
  When True, the response contains data URIs in place of CDN URLs so the client can decode the images without an extra HTTP request. Adds latency for large outputs.
  - Default: `false`



**Required Parameters Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/example_inputs/nano-banana-edit-input.png",
  "target_sizes": [
    "1024x1024",
    "1920x1080",
    "768x1344"
  ]
}
```

**Full Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/example_inputs/nano-banana-edit-input.png",
  "target_sizes": [
    "1024x1024",
    "1920x1080",
    "768x1344"
  ],
  "prompt": "",
  "num_images_per_size": 1,
  "resolution": "1K",
  "output_format": "png",
  "safety_tolerance": "4"
}
```


### Output Schema

The API returns the following output format:

- **`images`** (`list<ImageFile>`, _required_):
  All generated images, flattened across every target size. Order matches the order of ``results`` below: the first ``num_images_per_size`` entries correspond to ``target_sizes[0]`` and so on.
  - Array of ImageFile
  - Examples: [{"file_name":"nano-banana-pro-edit-output.png","content_type":"image/png","url":"https://storage.googleapis.com/falserverless/example_outputs/nano-banana-pro-edit-output.png"}]

- **`description`** (`string`, _required_):
  The description of the generated images.

- **`results`** (`list<SmartResizeResult>`, _required_):
  Per-target-size breakdown with the requested width/height and the nano-banana-pro (aspect_ratio, resolution) preset that was used internally.
  - Array of SmartResizeResult



**Example Response**:

```json
{
  "images": [
    {
      "file_name": "nano-banana-pro-edit-output.png",
      "content_type": "image/png",
      "url": "https://storage.googleapis.com/falserverless/example_outputs/nano-banana-pro-edit-output.png"
    }
  ],
  "description": "",
  "results": [
    {
      "images": [
        {
          "url": "",
          "content_type": "image/png",
          "file_name": "z9RV14K95DvU.png",
          "file_size": 4404019
        }
      ],
      "description": "",
      "aspect_ratio": "",
      "resolution": ""
    }
  ]
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/smart-resize \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "image_url": "https://storage.googleapis.com/falserverless/example_inputs/nano-banana-edit-input.png",
     "target_sizes": [
       "1024x1024",
       "1920x1080",
       "768x1344"
     ]
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/smart-resize",
    arguments={
        "image_url": "https://storage.googleapis.com/falserverless/example_inputs/nano-banana-edit-input.png",
        "target_sizes": ["1024x1024", "1920x1080", "768x1344"]
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/smart-resize", {
  input: {
    image_url: "https://storage.googleapis.com/falserverless/example_inputs/nano-banana-edit-input.png",
    target_sizes: ["1024x1024", "1920x1080", "768x1344"]
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/fal-ai/smart-resize)
- [API Documentation](https://fal.ai/models/fal-ai/smart-resize/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/smart-resize)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
