Articles · Images and color · 中文

Why do wide-gamut (Display P3) photos from a phone lose their color in web tools — and how do you keep it?

By mosjin · 2026-10-01 · Based on real development work and on-device testing

It happens all the time: a red flower or a green leaf shot on an iPhone goes into a web tool for a quick crop or rotate, and comes out noticeably less vivid. It is not your imagination, and it is not caused by compression quality. To understand it, start with where color actually lives inside a file. There are two different reasons colors go dull; after that, here is how we keep the original colors in the browser, and the test data to prove it.

First: what “wide gamut” and a color profile actually mean

The range of colors a screen or a photo can represent is called its gamut. The web and most images default to sRGB, a very old and very universal standard. Recent iPhones shoot in Display P3 by default; its range is larger than sRGB, so it can hold more saturated reds, greens and oranges. That is what “wide gamut” means.

The key point: each pixel in an image stores only three numbers, such as (255, 0, 0). Those numbers have no color meaning on their own — they are interpreted through a “color profile” (an ICC profile) embedded in the file. The same (255, 0, 0) reads as an ordinary red under sRGB, but as a deeper, richer red under Display P3. iPhones embed a Display P3 ICC profile in their photos, and only software and browsers with color management read it and show the colors correctly.

Once you see that, the “duller colors” problem explains itself: either the numbers were changed, or the instructions for interpreting them were lost.

The two reasons colors go dull

Reason 1: the image is converted to sRGB before processing

When a browser decodes an image, it performs color management: it converts the colors into its internal working space so the display looks right. Many web image tools use Canvas (the web's drawing surface) to rotate, crop and resize, and the usual way of writing them ends up with pixels that have already been converted to sRGB. sRGB cannot hold the most saturated part of P3, so those colors get “clamped” to the sRGB boundary.

In that case, the preview you see on screen is a “correct sRGB version”, and what you export is a standard sRGB image. Ordinary colors barely change, but highly saturated areas — petals, neon lights, bright clothing — go flat and dull. And it is irreversible: the extra color information in the original is gone.

Reason 2: the numbers survive, but the profile is dropped

The opposite case also happens: the tool manages to get the original pixel values, processes them, and writes a new file — but forgets to carry the original ICC profile along, or the encoder inserts an sRGB profile of its own. Numbers that should be read as P3 are then read as sRGB by viewing software. P3's (255, 0, 0) is displayed as sRGB's (255, 0, 0), and the whole image looks washed out, as if under a layer of grey.

The two causes look similar in the result, but the fixes are completely different: the first calls for avoiding conversion, the second for writing the ICC back unchanged. Many tools solve only one of them.

Browsers do not behave the same way

You might ask: can the browser just hand me the original numbers? Some can. In desktop Chromium, we measured that a Canvas in the display-p3 color space, together with createImageBitmap's colorSpaceConversion: 'none' option, returns values identical to the file's original decoded values, one by one, and the export also embeds a P3 ICC profile.

But you cannot count on every environment doing this. In September 2026 we tested on a Redmi Note 12 Turbo (Android 15): the native decoding in Chrome, the Xiaomi browser and WeChat's built-in browser all preserved P3, while the Quark browser compressed P3 into sRGB first. And desktop WebKit on Linux squeezes P3 into sRGB, yet native decoding on a real iPhone (iOS 26.6) preserves P3 — because decoding and color management go through each platform's own graphics libraries, so the same engine behaves differently on different systems. Conclusions only count when they come from real devices.

Lesson: for anything involving color and decoding, test at least Chromium and WebKit separately, and test the “read in” and “export” directions separately. Testing one browser in one direction leads to wrong conclusions very easily.

Our approach: let the browser do the preview, re-read the original numbers at export

Since native decoding cannot be relied on, the safest approach is to bypass it — but only at the step that changes colors. The hybrid path we ended up with:

  1. Preview and editing use the browser's color-managed image. That way the colors on screen are correct, and the editor never displays P3 numbers as if they were sRGB.
  2. At export, decode the original file again with a WebAssembly (WASM) decoder to get the raw numbers. We use the mozjpeg decoder from the open-source jSquash project, about 63 KB compressed, loaded only when a wide-gamut photo shows up. PNG and WebP have matching decoders.
  3. Put the raw numbers into a plain Canvas and rotate, crop and resize there. Within a single color space, these operations only move and interpolate numbers; they perform no color conversion. Preview and export share the same editing function, so both sides produce identical results.
  4. Encode with Canvas to JPEG, PNG or WebP, strip the encoder's own color chunk, then write the original ICC back unchanged. We measured that Chrome's Canvas JPEG encoding attaches an sRGB ICC profile of its own; it has to be removed first, or it will conflict with the P3 profile written back.

Writing the ICC back differs per format: in JPEG it goes into APP2 segments, with larger profiles split across several segments; PNG needs an iCCP chunk with a recomputed checksum; WebP has to be converted from the simple format to the extended format (VP8X) before it can hold an ICCP chunk. And judge the output format by the actual file bytes, not the requested format — ask iOS to encode WebP, for instance, and what you get back may be PNG.

Why not do everything in WASM? We measured that too: decoding, resizing and encoding a 12-megapixel photo entirely in WASM takes about 2.3 seconds, while “WASM only decodes, Canvas does the rest” takes 288 milliseconds on desktop Chromium and 436 milliseconds on WebKit — 5 to 8 times faster. On real phones, the Redmi processed 12- to 24-megapixel photos in 0.3 to 1.4 seconds across browsers, with no color deviation.

Phone memory is the other hurdle

This path decodes the image one extra time at export, so two large images cannot both stay resident: at a 40-megapixel cap, two uncompressed bitmaps alone take about 320 MB, which many phones cannot handle. Our approach is to decode only at export time, inside a one-shot background thread (a Web Worker) that is destroyed immediately afterwards, releasing the memory WASM held. On a low-end Android phone with 4 GB of memory, steady memory use after repeated exports dropped from about 531 MB to about 429 MB.

One more point: if the decoding component fails to load, the user should be told clearly to retry — not silently handed an sRGB export. Otherwise they believe the colors were preserved when they were not.

How we verify the colors really survived

Comparing by eye is unreliable, so we used two hard criteria: first, read the exported file back with an independent decoder and require its ICC to match the original byte for byte; second, compare the export pixel by pixel, across the whole image, against a reference made by applying the same geometric transform to the original numbers. On the Redmi phone, real iPhone P3 photos of 12 and 24 megapixels were rotated and exported to PNG and sliced into a nine-grid with zero differences across the whole image; JPEG and WebP exports had average errors of about 0.31 and 0.97 respectively, against 7.36 for a control group converted to sRGB first.

Lesson: when verifying a geometric transform like rotation, always compare the whole image, never spot-check a few points. Early on we tried one image library's rotation, spot-checked 4 points, and 3 looked right; the 4th had actually turned white, and we nearly dismissed it as a fluke. The whole-image comparison showed that about a quarter of the pixels had turned white.

Another easy trap is deciding whether an image is wide-gamut at all. Searching the profile's name for “sRGB” is unreliable: the ICC v4 profile written by Xiaomi's camera encodes its name in UTF-16, so a plain text search cannot find “sRGB” in it, and ordinary photos get misjudged as wide-gamut; conversely, the Display P3 profile generated by Chrome's graphics library (Skia) contains the string “sRGB” in its name. The reliable method is to read the red, green and blue primary coordinates from the profile and compare them with the sRGB standard values.

What about AI processing, such as upscaling?

AI upscaling, background removal and similar jobs usually run on a server, and the models generally understand pixels as sRGB. In our upscale feature, we upload the original numbers without the color profile, then write the original ICC back onto the result. On a P3 test image upscaled 2×, the average color difference (ΔE) against the original dropped from 13.6 to 4.9, with vivid reds, greens and orange-yellows falling from 27–37 down to 2–9; greys, whites and blacks came out the same either way. If writing the profile back fails, the result is still saved, with a note that the colors may be slightly duller.

Advice for everyday users

  • After processing, compare against the original side by side in the most vivid areas (red flowers, green leaves, neon). Dulling is usually visible at a glance.
  • Check the exported file with a tool that can show its color profile, and confirm it is still Display P3. The command-line tool exiftool, for example, can show the ICC description inside a file.
  • If a tool's description says “automatically converts to sRGB”, that is the first case above: fine for posting to chat apps and web pages, but do not use it for the final export if you want to keep the most vivid colors.
  • When several photos are combined into one image, the result can only carry one color profile; converting everything to sRGB is a reasonable compromise — as long as it is a proper conversion, not a dropped profile.

The approach in this article is what Jinlab's image tool pixforge uses: basic features such as rotate, crop, resize, format conversion and nine-grid slicing all preserve the original photo's wide-gamut colors and color profile. Related: How to convert CMYK images to RGB accurately in the browser.