# List the image formats this server can read and write

> Probed from the engine at boot rather than declared. A format whose encoder is not in this build is reported as unwritable, so a client never offers a conversion that would be refused.

Source: https://tools.vukem.dev/docs/api/tools.image-convert.formats/

## Authentication

No key is needed. This route is public.

## Responses

### 200 OK

Content type `application/json`. Schema: [`MediaCapabilities`](/docs/api/schemas#mediacapabilities).

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `flips` | array of `string` | - | Horizontal or vertical |
| `formats` | array of [`ImageFormat`](/docs/api/schemas#imageformat) | - | Every image format, with whether this server can read it, write it, or both |
| `readable` | array of `string` | - | The media types this server accepts as input |
| `resize_modes` | array of `string` | - | Fit, fill or exact |
| `rotations` | array of `integer` | - | The quarter turns a client may ask for |
| `writable` | array of `string` | - | The formats this server can write, by name |

### Any other status

Content type `application/problem+json`. Error (RFC 9457 problem details). Schema: [`Problem`](/docs/api/schemas#problem).

The error follows RFC 9457. See [Errors](/docs/api/overview#errors).

```bash
curl -X GET "http://localhost:3000/api/v1/tools/image-convert/formats"
```

```python
import requests

response = requests.get(
    "http://localhost:3000/api/v1/tools/image-convert/formats",
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

```javascript
const response = await fetch("http://localhost:3000/api/v1/tools/image-convert/formats", {
  method: "GET",
});
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
console.log(await response.json());
```

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "http://localhost:3000/api/v1/tools/image-convert/formats"
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		panic(err)
	}

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, err := io.ReadAll(res.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(res.Status, string(out))
}
```

```php
<?php

$ch = curl_init("http://localhost:3000/api/v1/tools/image-convert/formats");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new RuntimeException(curl_error($ch));
}
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), " ", $response, PHP_EOL;
```

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Example {
    public static void main(String[] args) throws Exception {
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("http://localhost:3000/api/v1/tools/image-convert/formats"))
            .GET()
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}
```

```csharp
using System;
using System.Net.Http;

using var client = new HttpClient();
using var request = new HttpRequestMessage(
    HttpMethod.Get, "http://localhost:3000/api/v1/tools/image-convert/formats");

using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
```

```ruby
require "net/http"
require "uri"

uri = URI("http://localhost:3000/api/v1/tools/image-convert/formats")
request = Net::HTTP::Get.new(uri)

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end
puts "#{response.code} #{response.body}"
```

**Response examples**

```json
{
  "flips": [
    "horizontal",
    "vertical"
  ],
  "formats": [
    {
      "animated": true,
      "extension": ".webp",
      "label": "WebP",
      "mime": "image/webp",
      "name": "webp",
      "read": true,
      "write": true
    },
    {
      "animated": false,
      "extension": ".avif",
      "label": "AVIF",
      "mime": "image/avif",
      "name": "avif",
      "read": true,
      "write": false
    },
    {
      "animated": false,
      "extension": ".bmp",
      "label": "BMP",
      "mime": "image/bmp",
      "name": "bmp",
      "read": true,
      "write": false
    }
  ],
  "readable": [
    "image/jpeg",
    "image/png",
    "image/webp",
    "image/gif",
    "image/tiff"
  ],
  "resize_modes": [
    "fit",
    "fill",
    "exact"
  ],
  "rotations": [
    0,
    90,
    180,
    270
  ],
  "writable": [
    "jpeg",
    "png",
    "webp",
    "jxl",
    "gif",
    "tiff"
  ]
}
```

The examples are built from the schemas, so every value is a placeholder of its type. The tables above hold the fields that carry the real values.
