# Image Resize

Add `?w=` or `?h=` to any Sirv image URL and Sirv resizes it on the fly.

Using an AI coding agent?

Install the [`sirv-dynamic-imaging`](https://www.skills.sh/sirv/image-optimization-skill/sirv-dynamic-imaging) skill, and your agent can build these image URLs for you. Ask in plain words, such as “Serve our product photos as 800px WebP.” [See all 8 skills](/help/rest-api/sirv-skills-for-ai-agents/)

The new image is created the moment it’s requested and cached, and your original file stays unchanged, so you never prepare separate sizes yourself.

Use **scale.option** to choose how the image fits the width and height you set. Try it in the demo below and watch the pixel size and file size change.

Try it

Original

Loading…

With options

Loading…

Width

px%

Height

px%

Scale option

fitfillignorenoup

https://demo.sirv.com/nuphar.jpg**?w=400**

[](https://demo.sirv.com/nuphar.jpg?w=400)

## Which resize parameters can I use?

Add parameters to the end of the URL after a `?` and join them with `&`.

| Parameter | What it does | Example |
| --- | --- | --- |
| **w** or **scale.width** | Width in pixels or as a percentage of the original | `?w=250`, `?w=50%` |
| **h** or **scale.height** | Height in pixels or as a percentage of the original | `?h=100` |
| **scale.option=fit** | Default. Fits the image inside both **w** and **h**, keeping the aspect ratio | `?w=150&h=150` |
| **scale.option=fill** | Scales to the greater of **w** or **h**, so the image fills the area | `?w=350&h=120&scale.option=fill` |
| **scale.option=ignore** | Stretches to the exact **w** and **h**, ignoring the aspect ratio | `?w=100&h=200&scale.option=ignore` |
| **scale.option=noup** | Never scales the image larger than its original size | `?w=800&h=600&scale.option=noup` |

The examples below all use the same 400 × 252px JPEG, so you can compare the results. See every other parameter in [dynamic imaging](/help/dynamic-imaging/).

## Width

Width is changed by appending the **w** parameter to the URL (or **scale.width**). The JPEG image below was 400px width. It has been scaled to 250px width:

`https://demo.sirv.com/looks.jpg?w=250`

![250px width image](https://demo.sirv.com/looks.jpg?w=250)

## Height

Height is changed by appending the **h** parameter to the URL (or **scale.height**), for example this 100px height image:

`https://demo.sirv.com/looks.jpg?h=100`

![100px height image](https://demo.sirv.com/looks.jpg?h=100)

### Percentage sizes

Images can also be scaled as a percentage of their original size. This image has 50% of its original width:

`https://demo.sirv.com/looks.jpg?w=50%`

![Image scaled to 50% width](https://demo.sirv.com/looks.jpg?w=50%25)

Images can be stretched larger, beyond their original dimensions, though images become blurred when they are scaled up.

We recommend uploading your largest images (at least 2500px wide if possible), so they can be scaled down to size.

### Width and height together

If you specify both **w** and **h**, the new image fits inside the two dimensions and keeps the original aspect ratio.

In the example below, **w** and **h** are both set to 150px, so Sirv created an image 150px wide and 94px high (because the original image is wider than it is tall):

`https://demo.sirv.com/looks.jpg?h=150&w=150`

![Image scaled to 150px height/width](https://demo.sirv.com/looks.jpg?h=150&w=150)

## Scale options

**scale.option** controls how Sirv scales images when you set both dimensions. It defaults to **fit**, which scales the image to within whichever is the lesser of **w** or **h**.

### fill

Change it to **fill** to scale an image to whichever is the greater of **w** or **h** (to fill a particular area). The example below disregards the height of 120px and creates an image of 350px width:

`https://demo.sirv.com/looks.jpg?w=350&h=120&scale.option=fill`

![Image scaled to 350px width with fill](https://demo.sirv.com/looks.jpg?w=350&h=120&scale.option=fill)

Want the image cut to an exact box instead? Combine resizing with [cropping](/help/dynamic-imaging/transformations/crop/).

### ignore

To stretch the image, changing the aspect ratio, set the **scale.option** parameter to **ignore** (ignore aspect ratio). For example:

`https://demo.sirv.com/looks.jpg?w=100&h=200&scale.option=ignore`

![Image stretched to 100px width and 200px height](https://demo.sirv.com/looks.jpg?w=100&h=200&scale.option=ignore)

Avoid this for product and editorial images unless you want the distortion.

### noup

To prevent the image from being scaled larger than its original size, set the **scale.option** to **noup** (no upscaling of image).

The example below sets a size of 800px width and 600px height but the image served doesn’t go beyond its original 400px width and 252px height:

`https://demo.sirv.com/looks.jpg?w=800&h=600&scale.option=noup`

![Image with no upscaling](https://demo.sirv.com/looks.jpg?w=800&h=600&scale.option=noup)

This is useful when page templates ask for large image slots but some of your originals are smaller.

## What size should I serve on my web pages?

Pick the width from the space the image fills on the page, not from the original file. A product card that shows at 360px wide should not download a 2400px original.

Right-sized images load faster, use less data transfer and still look sharp.

| Page use | Typical displayed width | Sirv URL example |
| --- | --- | --- |
| Small thumbnail | 120–240px | `?w=200` |
| Product card | 300–500px | `?w=400` |
| Blog or help article image | 700–1100px | `?w=900` |
| Full-width desktop hero | 1400–2000px | `?w=1800&scale.option=noup` |

High-density (retina) screens need a 2x size. Use [retina images](/help/dynamic-imaging/format-quality/retina-support/) or let [responsive images](/help/sirv-media-viewer/core-features/responsive-images/) pick the size for you, instead of sending one oversized image to every device.

## How do I build a responsive srcset with Sirv?

Because every size is just a URL, you can build a srcset without creating any files. The browser picks the best width for the screen:

```html
<img src="https://demo.sirv.com/looks.jpg?w=400"
  srcset="https://demo.sirv.com/looks.jpg?w=200 200w,
          https://demo.sirv.com/looks.jpg?w=400 400w"
  sizes="(max-width: 400px) 50vw, 400px"
  width="400" height="252" alt="Model in a jacket" loading="lazy">
```

Add `scale.option=noup` to your largest size if the original might be smaller than you ask for.

## Can I set quality and format in the same URL?

Yes. Resize first and add quality in the same URL, for example `?w=900&q=82`. Sirv already serves the best format for each browser by default: AVIF where supported, otherwise WebP.

For more control, see [format and quality](/help/dynamic-imaging/format-quality/format/) and the [JPEG quality comparison](/help/guides/jpeg-quality-comparison/).

## When is resizing not enough?

Resizing keeps the whole image visible. Use [crop](/help/dynamic-imaging/transformations/crop/) when you need a fixed aspect ratio or want to focus on one part of the image, and [thumbnail](/help/dynamic-imaging/transformations/thumbnail/) for square thumbnails.
