> For the complete documentation index, see [llms.txt](https://help.pixboost.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.pixboost.com/api/resize.md).

# Resize

API endpoint - `/api/2/img/[IMAGE-URL]/resize?size=[NEW-SIZE]`

## Description

**Resize** - resizes image with preserving aspect ratio and optimizes it using lossy compression. If you need the exact size then use fit operation.

## Parameters

**size** (**required**) - new size (in pixels) of the image in the format `WIDTH and xHEIGHT`. You can specify only one dimension and the second will be calculated according to the image's aspect ratio.

**dppx** (optional) - Number of dots per pixel defines the ratio between device and CSS pixels. The query parameter is a hint that enables extra optimisations for high density screens. The format is a float number in the same format as window\.devicePixelRatio.

**trim-border**(optional) - Will remove the edges of the image with the same color, if the option specified.

## Examples

* `size=200` - resize to 200 px wide preserving aspect ratio
* `size=x80` - resize to 80 px high preserving aspect ratio
* `dppx=2` - sending a hint to the API that screen has DPI=2

| Parameters                                                                                                                                                                                                                |                                                                                                                                                                                                                           Image                                                                                                                                                                                                                           |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| Original                                                                                                                                                                                                                  |                                                                                                                                                                          ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/asis?auth=MTA0ODU5NDA0NQ__)                                                                                                                                                                         |
| size=200                                                                                                                                                                                                                  |                                                                                                                                                                    ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/resize?size=200\&auth=MTA0ODU5NDA0NQ__)                                                                                                                                                                   |
| size=x80                                                                                                                                                                                                                  |                                                                                                                                                                    ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/resize?size=x80\&auth=MTA0ODU5NDA0NQ__)                                                                                                                                                                   |
| size=200\&dppx=2                                                                                                                                                                                                          |                                                                                                                                                                ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/resize?size=200\&dppx=2\&auth=MTA0ODU5NDA0NQ__)                                                                                                                                                               |
| size=200\&trim-border                                                                                                                                                                                                     |                                                                                                                                                             ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/resize?size=200\&trim-border\&auth=MTA0ODU5NDA0NQ__)                                                                                                                                                             |
| size=600, background prompt: An industrial loft interior with exposed brick and polished concrete. Soft morning light diffusing through large windows, creating subtle rim lighting. Out-of-focus modern design elements. | ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/resize?size=600\&background=uk4l2l4eC8wQEWVQ8AX5%2FdMfxn%2FvS3B10RY4iZq01zeu1vzE29%2FgSYt6yFCgj2C3QMn3DLqbRpvDRspjyY2AC%2Bn%2FMgy%2BVBbbCN5GBsQe1wfVJJZ9t%2F56nG%2BsggTu36oRmkCSWHyzfzm7Aum8w7vf8rMr61qaUFtfoaQvRMPuuaowlQK7nCaPc%2BpB3uLaLHZfpvExuQdPktUfToqInWxWFDH2s%2FrIpq87XqCv9RYXlrMR4bkHWHwHzuKQ7wUQKnw%2BMQRAAs61dl572mq3wejmH3DYki1X%2BuHw\&auth=MTA0ODU5NDA0NQ__) |

**You can inspect URLs and sizes of the examples by "right-click -> Copy Image address"**
