One grayscale button is not one reversible switch flipped twelve times. It is twelve permanent color drops followed by twelve saves, and the save decides how many channels the file actually has.
Eleven of twelve files were written; one truncated JPEG would not decode. The batch fell from 20,934,926 to 12,453,366 bytes, 40.514%. Nine outputs became single-channel, one became a one-frame palette image, and one WebP kept three channels while looking gray. A 16-bit PNG dropped from 65,536 levels to 256. A thumbnail grid hides all of it.
This page is about the files, not about which button to press. For the arithmetic behind a single-file color operation, the single-file invert guide and the flip / mirror / invert explainer are the closest relatives. Yesterday's batch invert measurement used the same twelve files and makes a useful control: inversion is reversible arithmetic, grayscale is not.
Twelve files, 63,016,384 pixels across the eleven that decoded: six JPEGs (one of them deliberately truncated), four PNGs, one six-frame GIF, and one lossy WebP. Each readable file got the same operation, convert('L'), which per the Pillow reference uses the ITU-R 601-2 luma transform L = R * 299/1000 + G * 587/1000 + B * 114/1000. Each output was saved back in its own format, then reopened from disk and measured.
Two measurement scopes matter, because mixing them is how misleading numbers get published. Distinct color count is the number of different RGB triples in the decoded input versus the number of different gray levels in the reopened output. Differing pixel count is the share of pixels that no longer match when the saved file is decoded back to RGB and compared channel by channel with the decoded input. The second figure includes the noise of re-saving a lossy format; section 5 separates the two effects. Timings cover only open, convert and save. The color census runs after the timer stops.
Nothing about this queue was uniform after the first save. Eleven were written, the twelfth never decoded, and 8,481,560 bytes disappeared in total. Here is every file, in the order it went in.
| File | Input mode | Bytes in → out | Change | Output mode | Colors in → gray levels |
|---|---|---|---|---|---|
| animation.gif | P, 6 frames | 5,339 → 875 | -83.611% | P, 1 frame | 2 → 2 |
| broken.jpg | RGB | 1,200 → none | could not be decoded | ||
| duplicate_photo.jpg | RGB | 2,443,475 → 1,998,819 | -18.198% | L | 597,567 → 256 |
| exif_orient6.jpg | RGB | 703,335 → 547,627 | -22.139% | L | 366,412 → 256 |
| gray_16bit.png | I;16 | 12,042 → 1,630 | -86.464% | L | 256 → 256 |
| gray_8bit.jpg | L | 2,068,147 → 1,999,236 | -3.332% | L | 256 → 256 |
| logo_alpha.png | RGBA | 8,367 → 5,373 | -35.783% | L | 3 → 3 |
| photo_landscape.jpg | RGB | 2,403,704 → 1,960,679 | -18.431% | L | 597,542 → 256 |
| photo_portrait.jpg | RGB | 2,443,475 → 1,998,819 | -18.198% | L | 597,567 → 256 |
| photo_square.png | RGB | 10,636,840 → 3,788,909 | -64.379% | L | 597,392 → 256 |
| screenshot.webp | RGB | 186,788 → 143,918 | -22.951% | RGB | 214,038 → 220 |
| small_icon.png | RGB | 22,214 → 7,481 | -66.323% | L | 8,957 → 250 |
The color count for the 16-bit PNG is taken from its RGB-decoded form, which is already 8-bit. Its raw 16-bit depth is measured separately in section 6. Percentages are computed against each file's own input bytes, not against the batch total.
Measured byte change per file. The two steepest drops are the 16-bit PNG and the animation, neither of them a large input.
Ask for a grayscale batch and the reasonable expectation is eleven single-channel gray files. We got nine L files, one P palette file, and one RGB file. That last one matters more than it sounds.
The 1600×900 WebP went in as RGB, was converted to L in memory, and came back out of the encoder as RGB with three channels. Those three channels are not even equal to each other: each holds 220 distinct values, but R equals G and G equals B both fail, a residue of lossy chroma handling. The file looks gray. It is not a single-channel grayscale file. Anything downstream that counts channels, or that assumes a gray image is one third the raw size of a color one, will be wrong about this file.
The GIF went in as a six-frame palette animation and came back as a one-frame palette image. The surviving frame is genuinely gray and lost zero pixels against its own decoded input. The other five frames simply are not in the file. The P output mode is not a sign that grayscale failed; it is a sign that the encoder kept the palette container while dropping the animation.
Nine files did become L. That is the mode most guides mean when they say grayscale. It is also the mode that a plain grayscale save does not guarantee, because the encoder gets a vote.
Output mode distribution from the run. The check is on the reopened file, not on the in-memory result.
For the four full-size color photographs, the decoded input held between 597,392 and 597,567 distinct RGB triples. Each output held 256 gray levels. The reduction is 99.957% for three of them and 99.930% for the orientation-tagged one, which started at 366,412 colors. The WebP screenshot went from 214,038 colors to 220 gray levels, 99.897%. The small icon went from 8,957 to 250, 97.209%.
Those percentages come from (colors in - gray levels out) / colors in, with both counts taken over the whole reopened file, not a sample. They are a measure of how many distinct values the file can express, not of how different the picture looks. Four other files recorded 0.000% on this measure because they were already gray or nearly so: the animation had two colors, the 8-bit grayscale JPEG and the 16-bit PNG each had 256 values in their RGB-decoded form, and the transparent logo had three. Grayscale cannot remove colors that are not there.
What it can do is stop you from ever getting them back. A gray level is a weighted sum, and a weighted sum is not invertible: many different RGB triples map to the same value. On the four large photos, the largest single-channel gap between the saved output and the decoded source was 207 or 208 out of 255; on the square PNG it was 210. No amount of post-processing reconstructs which triple produced a given level.
When each saved file is decoded back to RGB and compared with its decoded source, 38,211,962 of 63,016,384 pixels differ, 60.638% of the batch. That number is honest but coarse, because it mixes two causes. The run contains a control that separates them.
gray_8bit.jpg was already single-channel grayscale. It lost 0.000% of its distinct values. Yet 27.545% of its 12,000,000 pixels came back different, with a maximum channel gap of just 15 and a mean gap of 0.481107. Grayscale did nothing to that file; re-encoding it as JPEG quality 90 did all of it. Compare photo_portrait.jpg, which lost 99.957% of its distinct values and came back with 65.893% differing pixels, a maximum gap of 207 and a mean of 27.717502. Same encoder, same quality setting, one file already gray and one not.
So read the per-file differing-pixel figures as a combined budget: the color discarded by grayscale plus the noise added by saving again. The five readable JPEGs span 27.545% to 66.127%. The square PNG reaches 87.416%, the WebP 66.784%, the icon 68.445%. The two files with zero differing pixels are the surviving animation frame and the 16-bit PNG, and neither was preserved intact: the animation lost its other five frames, and the 16-bit PNG lost its depth. Both are covered next.
Bit depth. The 800×600 16-bit PNG did not fail here. Its raw samples span 0 to 65,535 with 65,536 distinct values. After convert('L') the values span 0 to 255 with 256 distinct values, a 99.609% reduction in available levels, and the file fell from 12,042 to 1,630 bytes, -86.464%. Zero pixels differ against its 8-bit-decoded self, which is exactly why a pixel-diff check would miss the loss entirely. In the batch invert run the same file stopped with an error instead. Grayscale quietly accepted it and threw away the depth.
Transparency. The 1200×800 logo has 960,000 pixels, of which 607,580 are fully transparent, 63.29%. Converting to L drops the alpha channel entirely: four channels in, one out. The transparent area does not turn uniformly black, as the usual flattened-to-JPEG story goes. It becomes the luminance of the RGB values that were hidden underneath, ranging from 0 to 240 with a mean of 63.518 and only two distinct gray values. The formerly invisible pixels are now visible gray. The file fell from 8,367 to 5,373 bytes, -35.783%, and 36.71% of its pixels differ from the decoded source.
Animation. Six frames in, one frame out, 5,339 to 875 bytes, -83.611%. A default single-frame save discards the rest. Keeping an animation needs an explicit all-frames save, and a palette container is not evidence that it happened.
Orientation metadata. The 2000×1500 phone-style JPEG carried one EXIF tag, orientation value 6. A plain grayscale save wrote zero EXIF tags. The tag is gone and the file no longer tells a viewer how to turn it. If the display path was relying on that tag, the photo now lies on its side. The rotate tool page covers the tag itself; here the point is that a color operation removed it as a side effect.
A gray-looking image can be stored as one luminance channel or as three equal RGB channels. Both decode to the same picture. We saved three of the batch both ways at identical settings and compared the bytes.
| File | One-channel L | Three-channel RGB | Extra bytes | Decoded pixels differing |
|---|---|---|---|---|
| photo_portrait.jpg | 1,998,819 | 2,051,933 | 53,114 (+2.657%) | 0 of 12,000,000 (0.000%) |
| photo_square.png | 3,788,909 | 6,302,132 | 2,513,223 (+66.331%) | 0 of 9,000,000 (0.000%) |
| screenshot.webp | 143,918 | 143,918 | 0 (+0.000%) | 0 of 1,440,000 (0.000%) |
The PNG is the expensive case: storing the same 9,000,000 gray pixels as three channels costs 2,513,223 extra bytes, 66.331% more. The JPEG costs 53,114 bytes, 2.657%. The WebP costs nothing, because its encoder was already writing three channels for both paths, which is the same reason it showed up as RGB in section 3. All three pairs decode to zero differing pixels out of 22,440,000 compared. Choosing the wrong container is invisible on screen and entirely visible on disk.
Blue is the one-channel save, orange the three-channel save. Zero decoded pixels differ in every pair.
The eleven successful files took 2,007.46 ms in total, averaging 182.5 ms, from 6.96 ms for the 128×128 icon to 823.90 ms for the 3000×3000 PNG, a 118.4-fold spread. Conversion accounted for 829.62 ms, 41.327%; saving for 1,177.84 ms, 58.673%. The save is the larger half, and it is the half that changed the channel modes, dropped the frames and removed the metadata. That split is close to the invert run on the same files, where saving took 55.7%.
The operation is deterministic. Converting and saving the GIF twice produced two 875-byte files that are byte-for-byte identical, with a SHA-256 prefix of 655e7a1d4b2b18c0. The two byte-identical portrait JPEGs produced two byte-identical outputs at 1,998,819 bytes each, SHA-256 prefix a7fc426a444e0510. A second in-memory grayscale pass changed zero pixels on all six files tested, across 28,560,000 pixels. That is idempotence, not reversibility: applying it twice changes nothing, and neither pass can restore a color.
One file failed: broken.jpg, a 1,200-byte truncated JPEG, stopped with image file is truncated (2 bytes not processed) after 17.29 ms. The other eleven were still written. A batch that aborts on the first bad file and one that skips it will produce different folders from the same input, so this is worth knowing before you hand over a queue.
The twelve files here were built to contain the awkward cases. Your folder may contain none of them, or all of them. The checks that actually change the outcome are: whether any file is an animation, 16-bit, or carries transparency; whether downstream code counts channels rather than looking at the picture; whether an orientation tag is what keeps phone photos upright; and whether a failed file should stop the run or be skipped. A preview grid will answer none of these.
Yes, but it is one conversion plus one save per file, and the save is where the formats diverge. In our twelve-file run, eleven were written and one truncated JPEG failed with image file is truncated (2 bytes not processed) after 17.29 ms. Nine outputs were single-channel L, one was a one-frame palette GIF, and one WebP was still three-channel RGB. The batch fell from 20,934,926 to 12,453,366 bytes, 40.514%.
It is written, but it stops being 16-bit. Our 800×600 file had 65,536 distinct sample values from 0 to 65,535; after the conversion it had 256 values from 0 to 255, a 99.609% reduction in available levels, and fell from 12,042 to 1,630 bytes, 86.464% smaller. Zero pixels differ against its 8-bit-decoded self, so a pixel-diff check will not catch it. In our batch invert run the same file failed outright instead.
The hidden RGB values underneath become visible gray. In our 960,000-pixel logo, 607,580 pixels were fully transparent, 63.29% of the image. After the alpha channel was dropped, those pixels held gray values from 0 to 240 with a mean of 63.518 and only two distinct levels. They did not all turn black. The file went from four channels to one and from 8,367 to 5,373 bytes, 35.783% smaller, with 36.71% of its pixels differing from the decoded source.
Because the encoder chooses the container, not the conversion. Our 1600×900 WebP was converted to L in memory and reopened as RGB with three channels, each holding 220 distinct values and none exactly equal to the others. Saving the same gray pixels through a one-channel path and a three-channel path produced the identical 143,918-byte file and zero differing decoded pixels out of 1,440,000. It looks gray and it is not a single-channel file.
No, not by default here. Our 2000×1500 JPEG carried exactly one EXIF tag, orientation value 6. The grayscale output carried zero EXIF tags. Nothing about the luminance math requires removing it; a plain save simply did not copy it. If a viewer was relying on that tag to turn the photo, the picture will now appear on its side. Passing the metadata through explicitly is a separate step.
No. A gray level is a weighted sum of three channels, and many different colors produce the same sum. Our four large color photographs went from 597,392 to 597,567 distinct RGB triples down to 256 gray levels each, a 99.957% reduction, with maximum single-channel gaps of 207 to 210 against the decoded source. A second grayscale pass changed zero pixels across 28,560,000 pixels tested, which shows the operation is idempotent, not reversible. Keep the originals.