---
title: "Keep colours right when you strip metadata · Agent Wranglers"
url: https://agentwranglers.se/playbook/files-and-media/images/colour-profiles
id: MED-8
level: Recommended
updated: 2026-10-22
tokens: 883
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Keep colours right when you strip metadata

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Images](https://agentwranglers.se/playbook/files-and-media/images.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: MED-8
- Level: Recommended
- Chapter: [Images](https://agentwranglers.se/playbook/files-and-media/images.md)
- Rule: Before you drop an image's metadata, convert its pixels to sRGB or keep its colour profile. Never drop the profile alone.
- Check: Upload a Display P3 test photo with a known red patch. The served file has no EXIF tags. Either it carries the P3 profile, or its patch matches the sRGB value within 2 units per channel.
- How: Phones save photos in wide colour spaces such as Display P3, with an embedded ICC profile that says how to read the numbers. Strip the profile and keep the pixels, and browsers read them as sRGB, so colours look flat or shifted. Converting to sRGB suits nearly every web image and keeps files small. Keep the profile, or convert to P3 and attach it, only for products where colour must match, such as print or fashion. Some libraries convert by default, such as sharp, while others drop the profile and leave the pixels, such as a plain Pillow save. Do it in the same step as [Rebuild every uploaded image](https://agentwranglers.se/playbook/api-design/files-and-uploads/process-images.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
import sharp from 'sharp';

export async function rebuildForWeb(input) {
  return sharp(input, { limitInputPixels: 40_000_000 })
    .rotate()
    .toColourspace('srgb')
    .webp({ quality: 80 })
    .toBuffer();
}
```

### Python example

```python
import io
from PIL import Image, ImageCms, ImageOps

SRGB = ImageCms.createProfile("sRGB")

def rebuild_for_web(data: bytes) -> bytes:
    image = ImageOps.exif_transpose(Image.open(io.BytesIO(data)))
    icc = image.info.get("icc_profile")
    if icc:
        source = ImageCms.ImageCmsProfile(io.BytesIO(icc))
        image = ImageCms.profileToProfile(image, source, SRGB, outputMode="RGB")
    out = io.BytesIO()
    image.convert("RGB").save(out, "WEBP", quality=80)
    return out.getvalue()
```

## Sources

- [sharp output options (keepIccProfile, withIccProfile)](https://sharp.pixelplumbing.com/api-output/)
- [W3C PNG Third Edition (colour spaces and iCCP)](https://www.w3.org/TR/png-3/)

## Related rules

- API-61 [Rebuild every uploaded image](https://agentwranglers.se/playbook/api-design/files-and-uploads/process-images.md) in API design

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/files-and-media/images/colour-profiles">Agent Wranglers files and media playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Make image sizes from a fixed list](https://agentwranglers.se/playbook/files-and-media/images/fixed-image-sizes.md)
- Next: [Accept the photo formats phones save](https://agentwranglers.se/playbook/files-and-media/images/phone-photo-formats.md)
- [Images](https://agentwranglers.se/playbook/files-and-media/images.md)
