---
metadata:
  - name: generator
    content: Diplodoc Platform v5.44.0
alternate:
  - https://yandex.com/dev/disk/doc/en/reference/preview.md
  - https://yandex.com/dev/disk/doc/ru/reference/preview.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/disk/doc/en/llms.txt

# Getting image previews

You can request a preview (a smaller version of a picture) for _images that have been uploaded to Yandex Disk.

To get an image preview, send a GET request specifying the `preview` parameter, and set the desired size as the value of the `size` parameter. There are several ways to set the preview size:

- T-shirt size, such as `size=M`.

    Yandex Disk returns a preview in the size you selected.

    Supported values:

    - “XXXS” — 50 pixels on each side (square).
    - “XXS” — 75 pixels on each side (square).
    - “XS” — 100 pixels on each side (square).
    - “S” — 150 pixels wide, preserves original aspect ratio.
    - “M” — 300 pixels wide, preserves original aspect ratio.
    - “L” — 500 pixels wide, preserves original aspect ratio.
    - “XL” — 800 pixels wide, preserves original aspect ratio.
    - “XXL” — 1024 pixels wide, preserves original aspect ratio.
    - “XXXL” — 1280 pixels wide, preserves original aspect ratio.

- A number, such as `size=128`.

    Yandex Disk returns a preview with this width. If the specified width is more than 100 pixels, the preview preserves the aspect ratio of the original image.

    Otherwise, the preview is additionally modified: the largest possible square section is taken from the center of the image to scale to the specified width.

- Exact dimensions, such as `size=128x256`.

    Yandex Disk returns a preview with the specified dimensions. The largest possible section with the specified width/height ratio is taken from the center of the original image (in the example, the ratio is 128/256 or 1/2). Then this section of the image is scaled to the specified dimensions. See the example with exact dimensions below.

- Exact width or height, such as `size=128x` or `size=x256`.

    Yandex Disk returns a preview with the specified width or height that preserves the aspect ratio of the original image.

## Server response

There are two possible server responses:

- HTTP 404 — The image was not found on Yandex Disk.
- HTTP 200 — The image was found, and the preview was created and returned in the response body.

## Example requests {#examples}

The examples use an [image sized 1280×720 pixels](https://download.cdn.yandex.net/tech/ru/disk/files/orig-1280x720.jpg) that has been uploaded to the `/fotki/` directory on the user's Disk.

The headings correspond to the value of the `size` parameter for each example.

## XS
>
> Requests an XS-size preview (square with 100 pixels per side).
>
> ```yaml
> GET **/fotki/t.jpg?preview&size=XS** HTTP/1.1
> User-Agent: my_application/0.0.1
> Host: webdav.yandex.ru
> Authorization: OAuth 0c4182a7c2cf4521964a72ff57a34a07
> ```
>
> The server responds with a preview file sized 100×100 pixels:
>
> ![XS](../_images/preview_demo/preview_XS.jpg)

## XL
>
> Requests an XL-size preview (width of 800 pixels and the original aspect ratio).
>
> ```yaml
> GET **/fotki/t.jpg?preview&size=XL** HTTP/1.1
> User-Agent: my_application/0.0.1
> Host: webdav.yandex.ru
> Authorization: OAuth 0c4182a7c2cf4521964a72ff57a34a07
> ```
>
> The server responds with a preview file sized 800×533 pixels:
>
> ![XL](../_images/preview_demo/preview_XL.jpg)

## 90
>
> Requests a preview 90 pixels wide.
>
> ```yaml
> GET **/fotki/t.jpg?preview&size=90** HTTP/1.1
> User-Agent: my_application/0.0.1
> Host: webdav.yandex.ru
> Authorization: OAuth 0c4182a7c2cf4521964a72ff57a34a07
> ```
>
> The server responds with a preview file sized 90×90 pixels:
>
> ![90](../_images/preview_demo/preview_90.jpg)

## 100
>
> Requests a preview 100 pixels wide.
>
> ```yaml
> GET **/fotki/t.jpg?preview&size=100** HTTP/1.1
> User-Agent: my_application/0.0.1
> Host: webdav.yandex.ru
> Authorization: OAuth 0c4182a7c2cf4521964a72ff57a34a07
> ```
>
> The server responds with a preview file sized 100×100 pixels:
>
> ![100](../_images/preview_demo/preview_100.jpg)

## 101
>
> Requests a preview 101 pixels wide.
>
> ```yaml
> GET **/fotki/t.jpg?preview&size=101** HTTP/1.1
> User-Agent: my_application/0.0.1
> Host: webdav.yandex.ru
> Authorization: OAuth 0c4182a7c2cf4521964a72ff57a34a07
> ```
>
> The server responds with a preview file sized 101×67 pixels:
>
> ![101](../_images/preview_demo/preview_101.jpg)

## 90x
>
> Requests a preview with a width of 90 pixels that preserves the original aspect ratio.
>
> ```yaml
> GET **/fotki/t.jpg?preview&size=90x** HTTP/1.1
> User-Agent: my_application/0.0.1
> Host: webdav.yandex.ru
> Authorization: OAuth 0c4182a7c2cf4521964a72ff57a34a07
> ```
>
> The server responds with a preview file sized 90×60 pixels:
>
> ![90x](../_images/preview_demo/preview_90x.jpg)

## 700x1000
>
> Requests a preview with the exact dimensions of 700×1000 pixels.
>
> ```yaml
> GET **/fotki/t.jpg?preview&size=700x1000** HTTP/1.1
> User-Agent: my_application/0.0.1
> Host: webdav.yandex.ru
> Authorization: OAuth 0c4182a7c2cf4521964a72ff57a34a07
> ```
>
> The largest possible section is taken from the center of the picture with a width-to-height ratio of 7:10 (700 to 1000). In this case, the size of the fragment is 504×720.
>
> Then this fragment is scaled to the specified dimensions. The server responds with a preview file sized 700×1000 pixels:
>
> ![700x1000](../_images/preview_demo/preview_700x1000.jpg)
