> 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/fit.md).

# Fit

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

## Description

**Fit** - resizes, crops, and optimises source image. This operation does not respect original aspect ratio. If you need to preserve aspect ratio then use [resize operation](/api/resize.md).

## Parameters

**size** (**required**) - new size (in pixels) of the image in the format `WIDTHxHEIGHT`. You have to specify **both** dimensions width and height.

**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=200x100` - scaling by the smaller side which is height, cropping sides, center positioning
* `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=200x100                                                                                                                                                                                                              |                                                                                                                                                                ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/fit?size=200x100\&auth=MTA0ODU5NDA0NQ__)                                                                                                                                                               |
| size=200x100\&dppx=2                                                                                                                                                                                                      |                                                                                                                                                            ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/fit?size=200x100\&dppx=2\&auth=MTA0ODU5NDA0NQ__)                                                                                                                                                           |
| size=200x200\&trim-border                                                                                                                                                                                                 |                                                                                                                                                         ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/fit?size=200x200\&trim-border\&auth=MTA0ODU5NDA0NQ__)                                                                                                                                                         |
| size=600x600, background prompt: An urban concrete plaza with minimalist architecture at sunset. Warm golden hour light casting long, soft shadows. Shallow depth of field, clean lines, elegant bokeh in the background. | ![](https://pixboost.com/api/2/img/https://pixboost.com/img/demos/tshirt.jpg/fit?size=600x600\&background=knhZyK4t9qsJA1GkjhnMzAKI%2BsXSnQtPxI0FOzUhMTsMzDdw2agZ%2B0yfr8qmEWfVyAzh%2FPA918l4kgru4geEA90Om2ImRrYyfJ7e0Iho9%2BNlQnlqlI5DRk6IVNKorvZ421xVSLxdZi%2B1dZYDcw5y%2Bk7jAWLg9Js9rRh1FdbU617C2FXsSWSUFgwVJntnq1dgGYXx6VctvDLwTfLhaNgc0WhB8%2FAmIETVpSJCKXwp3Fzo9WxnRB42me57Z6UNC%2B8DojE9us4YDGWqhVmyV1Q4cVz%2FGr8%3D\&auth=MTA0ODU5NDA0NQ__) |

**You can see URL of the examples by "right-click -> Copy Image address"**
