A threshold tuned on lossless PNGs is tuned on a different image than the one most people will feed it. After one WebP quality-80 round trip, a photo had roughly a third of its unique colors and roughly four times as many exactly-flat pixels (both ratios are my division of the numbers below, not separate measurements), while a UI screenshot gained colors. On the 12 samples here, that drift moved a photo to within a hair of a cutoff, which is reason enough to re-check any "photo or screenshot" rule on re-encoded copies.
All numbers come from one Apple-silicon Mac and a single pass over 12 samples, using Python with Pillow 11.3, NumPy and OpenCV. They describe these samples, not images in general. The photos come from Wikimedia Commons: Bonnie Moreland's "Lake Mountain Landscape", William Stitt's "Face portrait" and "Avions à l'aéroport de Madrid - 2015", all CC0, resized or cropped. The web-page screenshot is by Stefan Kühn (CC0). The remaining screenshots are self-made with invented data.
Why a classifier sits in front of a JPG encoder
Converting WebP to JPG raises a question the encoder cannot answer by itself: which quality number. Photos tolerate a lower one, text and flat UI wants a higher one. One way a converter can handle that is to pick a default from what the image looks like. ImgIng, the converter I use at https://imging.ai/ , shows two things on its page: after an image is dropped in, it displays a detected content type, and the JPG default is 80 for photos, 78 for smooth images, 84 for textured ones and 88 for graphics or text. What it uses to decide was not checked here.
A cheap way to build such a first-pass sorter is a few pixel statistics. The one used here is the share of pixels whose luminance equals the right and lower neighbours (call it flat), the share within a difference of 2 (near-flat), the hard-edge share, and unique colors per pixel.
Measured: one round trip moves the features
Same image, before and after saving as WebP at quality 80 and decoding again. The snippet is a trimmed rewrite of the feature script that keeps only the two features that moved (it is not the original command from the run log). Its output below was re-run and matches the 12-sample table.
import io, numpy as np from PIL import Image # decode and re-encode def stats(im): a = np.array(im.convert("RGB")); y = np.array(im.convert("L")).astype(np.int16) g = np.maximum(np.abs(np.diff(y, axis=1))[:-1], np.abs(np.diff(y, axis=0))[:, :-1]) # larger of the right/down luma steps return len(np.unique(a.reshape(-1, 3), axis=0)), (g == 0).mean() for f in ("photo.png", "shot.png"): im = Image.open(f).convert("RGB"); buf = io.BytesIO(); im.save(buf, "WEBP", quality=80) c0, f0 = stats(im); c1, f1 = stats(Image.open(buf)) print(f"{f}: colors {c0} -> {c1}, flat {f0:.1%} -> {f1:.1%}") photo.png: colors 121313 -> 39042, flat 11.2% -> 44.4% shot.png: colors 1015 -> 9565, flat 91.2% -> 82.8% The photo is the lake landscape, the screenshot is a self-made admin table. Both move toward the middle: the photo gets smoother and poorer in colors, the screenshot gains colors. The photo's colors per pixel went from 0.0711 to 0.0229, and the cutoff in the combined rule is 0.02. A second self-made screenshot with heavy gradients saw its flat share go from 27.0% to 77.4%, which looks like WebP squeezing the gradient into small flat blocks (a reading of the numbers, not checked block by block).
Here is what did not change. Across the 12 samples, the combined rule (near-flat above 80% with hard edges above 15%, or colors per pixel under 0.02, or flat above 60%) was wrong on exactly one image both before and after the round trip: the web-page screenshot with a photo embedded, which has 325,881 colors and gets called a photo. Edge density alone was the worst single feature, five wrong on either version, including the airport photo, whose railings and aircraft give it a 6.3% edge density against 4.6% for the admin table.
Inferred: where the drift would bite
The measured part stops at one encoder setting. What follows is inference, not something this run tested.
A photo that already sits close to 0.02 colors per pixel, say a flat-lit product shot, could cross the line after a stronger WebP setting than 80. Whether the 12 samples would behave that way at quality 60 was not measured. The threshold set was also chosen by looking at these same 12 images, with no held-out set, so the right reading is "a starting point that runs", not an accuracy figure.
Measured: what a wrong label costs
Using Pillow's libjpeg-turbo at 4:2:0, with SSIM computed on luminance by a self-written NumPy and OpenCV routine against the lossless original, there is no human rating behind it. Giving a photo the 88 meant for graphics made files 36.3% to 39.2% larger for only 0.0072 to 0.0090 more SSIM. Giving a screenshot the 80 meant for photos made files about a fifth smaller and 0.0010 to 0.0067 SSIM lower, which shows up as a faint ring of speckles around text when you zoom in. Between 78, 80, 84 and 88 there was no obvious knee; the price climbs clearly only above 88.
The page gave a real case of the same direction. The airport photo, with a big sky in the top half, was shown as "Screenshot/UI detected", so its JPG default was 88 and the output came out at 317,542 bytes, 2.00 times the source WebP. The other two photos got 80 and landed at 1.41 and 1.43 times. This reads as an example of a wrong label turning into a larger file. How the page reaches its labels is not something this run looked at.
Re-check your own cutoffs on re-encoded copies
Take the set you tuned on, save each file once through the lossy format your users actually have, decode, and recompute the same features. Whatever moves toward a cutoff is the part to watch, and the colors-per-pixel line is the first place to look.
