> ## Documentation Index
> Fetch the complete documentation index at: https://docs.domshot.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Formats

> Choose the right image format for your needs

## Image Formats

DomShot supports three image formats. Choose based on your use case: lossless quality (PNG), smaller file size (JPEG/WebP), or modern web optimization (WebP).

## Format comparison

| Format   | Compression | Quality Parameter | Transparency | Best For                    |
| -------- | ----------- | ----------------- | ------------ | --------------------------- |
| **PNG**  | Lossless    | No                | Yes          | Text, UI, documentation     |
| **JPEG** | Lossy       | Yes (1-100)       | No           | Photographs, complex images |
| **WebP** | Lossy       | Yes (1-100)       | Yes          | Web applications, storage   |

## PNG

Lossless compression with perfect quality. Best for screenshots containing text, UI elements, or when you need transparency.

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&format=png" \
    --output screenshot.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    format: 'png'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'format' => 'png'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("format", "png")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

**Characteristics:**

* Largest file size
* No quality loss
* Supports transparency
* Universal compatibility

## JPEG

Lossy compression optimized for photographic content. Smaller files with adjustable quality.

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&format=jpeg&quality=80" \
    --output screenshot.jpg
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    format: 'jpeg',
    quality: '80'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.jpg', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'format' => 'jpeg',
    'quality' => '80'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.jpg', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("format", "jpeg")
      params.Set("quality", "80")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

**Characteristics:**

* Smaller file size than PNG
* Adjustable quality (1-100, default: 100)
* No transparency support
* Best for photos and complex graphics

## WebP

Modern format with excellent compression ratio. Ideal for web applications and storage optimization.

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&format=webp&quality=80" \
    --output screenshot.webp
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    format: 'webp',
    quality: '80'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('screenshot.webp', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'format' => 'webp',
    'quality' => '80'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('screenshot.webp', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("format", "webp")
      params.Set("quality", "80")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

**Characteristics:**

* Best compression ratio
* Adjustable quality (1-100, default: 100)
* Supports transparency
* Modern browser support

## Quality parameter

The `quality` parameter controls compression for JPEG and WebP formats:

| Value    | Description                               |
| -------- | ----------------------------------------- |
| `1-49`   | Low quality, smallest files               |
| `50-79`  | Good balance of quality and size          |
| `80-100` | High quality, larger files (default: 100) |

<Tip>
  Quality settings do not apply to PNG format since it uses lossless compression.
</Tip>

## Recommendations

Choose your format based on your primary need:

| Use case                 | Format | Reason                                 |
| ------------------------ | ------ | -------------------------------------- |
| Documentation, tutorials | PNG    | Sharp text, universal support          |
| Social media thumbnails  | JPEG   | Small file size, wide compatibility    |
| Web applications         | WebP   | Best compression, modern standard      |
| Archiving                | PNG    | Lossless quality for long-term storage |
| Email attachments        | JPEG   | Smaller files, faster loading          |

## Parameters

| Parameter | Type   | Default | Description                               |
| --------- | ------ | ------- | ----------------------------------------- |
| `format`  | string | `png`   | `png`, `jpeg`, or `webp`                  |
| `quality` | number | `100`   | Image quality from 1-100 (JPEG/WebP only) |

## See also

* [Viewport Presets](/guides/screenshots/viewports) - Device sizes and dimensions
* [Full Page Screenshots](/guides/screenshots/full-page) - Capture entire page length
