Home  /  Guides  /  What one invert button does to a batch

What One Invert Button Does to a Whole Batch

Updated 2026-11-11 · measured on 12 mixed files, 20,934,926 bytes

The short answer

One invert button is not one subtraction repeated twelve times. It is twelve subtractions followed by twelve saves, and the save is where the damage happens.

We ran a single color inversion over twelve mixed files. Ten were written, two failed to open. The three PNGs and the GIF came back with zero changed pixels. The five JPEGs came back with between 28.562% and 47.815% of their pixels changed, and the WebP with 58.071%. A six-frame animation kept one frame and lost 83.611% of its bytes. A 16-bit grayscale PNG stopped with Invalid mode for data type. The batch shrank by 438,897 bytes, 2.096% of the input. A thumbnail grid shows twelve negatives and hides every one of those differences.

This page is about the files, not about which button to press. To invert one picture right now, our single-file invert guide covers the arithmetic and the format consequences, and the flip / mirror / invert explainer separates the three operations that get used interchangeably.

1. The batch, and how the numbers were taken

Twelve files, 20,934,926 bytes on disk: five JPEG photographs (two of them byte-identical copies), three PNGs, one lossy WebP, one six-frame GIF, one 16-bit grayscale PNG, and one deliberately truncated JPEG. Every file got the same operation: each color channel replaced by 255 minus its value, alpha left alone, palette entries inverted for the paletted file, and 65535 minus the value for the 16-bit one. Each output was saved back in its own format, then reopened from disk.

Pixel drift below is measured against the exact 255 - v of the decoded input. That reference is already lossy for JPEG and WebP, so the percentages are the cost of saving again, not a claim about the original scene. The run used Pillow 13.0.0, numpy 2.5.4 and Python 3.13.14 on local files. Every number here came out of that script and its output files.

What the twelve files were: two identical 3000×4000 portrait JPEGs, one 4000×3000 landscape JPEG, one 3000×4000 grayscale JPEG, one 2000×1500 JPEG carrying an orientation tag, one 3000×3000 PNG, one 1200×800 transparent RGBA PNG, one 128×128 PNG icon, one 1600×900 WebP, one 400×300 six-frame GIF, one 800×600 16-bit grayscale PNG, and one 1,200-byte truncated JPEG that cannot be decoded.

2. The per-file ledger

Nothing about the queue was uniform after the first save. Here is every file, in the order it went in.

FileFormat / modePixelsBytes in → outPixels changedTime
animation.gifGIF / P, 6 frames120,0005,339 → 8750 (0.000%)20.18 ms
broken.jpgJPEG / RGB12,000,0001,200 → nonecould not be decoded
duplicate_photo.jpgJPEG / RGB12,000,0002,443,475 → 2,343,6975,232,791 (43.607%)364.71 ms
exif_orient6.jpgJPEG / RGB3,000,000703,335 → 655,3991,434,448 (47.815%)87.85 ms
gray_16bit.pngPNG / I;16480,00012,042 → noneInvalid mode for data type
gray_8bit.jpgJPEG / L12,000,0002,068,147 → 1,999,3603,427,399 (28.562%)114.68 ms
logo_alpha.pngPNG / RGBA960,0008,367 → 8,3740 (0.000%)59.25 ms
photo_landscape.jpgJPEG / RGB12,000,0002,403,704 → 2,306,0625,246,231 (43.719%)221.08 ms
photo_portrait.jpgJPEG / RGB12,000,0002,443,475 → 2,343,6975,232,791 (43.607%)223.54 ms
photo_square.pngPNG / RGB9,000,00010,636,840 → 10,638,1010 (0.000%)1,499.99 ms
screenshot.webpWEBP / RGB1,440,000186,788 → 178,152836,229 (58.071%)392.20 ms
small_icon.pngPNG / RGB16,38422,214 → 22,3120 (0.000%)7.73 ms

The three PNGs added bytes: the square gained 1,261, the icon 98, the transparent logo 7. Every lossy file lost them: each portrait JPEG dropped 99,778, the landscape 97,642, the grayscale 68,787, the tagged one 47,936, the WebP 8,636. The GIF is its own case, in section 4. Net for the ten written files: 20,921,684 bytes in, 20,496,029 out, a drop of 425,655 bytes or 2.035%. Count the two failed files on the input side and the whole queue reads 20,934,926 in and 438,897 fewer out, 2.096%.

3. Four files kept every pixel; six did not

The split is clean. Three PNGs (9,976,384 pixels between them) and the GIF (120,000 pixels) returned exactly the arithmetic result: 0 changed pixels, maximum difference 0, mean absolute difference 0.000000. The five JPEGs and the WebP did not. Their differences are small in magnitude but cover a lot of ground: the largest single-channel deviation was 42 on the WebP, and mean absolute differences ran from 0.492147 on the grayscale JPEG to 1.314369 on the WebP.

Pixels changed by one invert + save WebP screenshot58.071% JPEG tagged47.815% JPEG landscape43.719% JPEG portrait & copy43.607% JPEG grayscale28.562% 3 PNGs + GIF0.000% 0% 30% 60% Bar length = changed pixels / decoded pixels, measured after reopening each saved file.
Same subtraction, seven different outcomes. Lossless formats return the exact negative; lossy ones pay for a second encode.

A page near the top of the results says an inversion is applied to all images simultaneously and that no file or quantity limit applies. That describes the control, not the queue. The queue here produced ten outputs from twelve inputs in 2,991.21 ms, and the two that did not come back were not the two you would guess from looking at a progress bar.

4. The animation that came back as a still

The GIF went in at 400×300 with six frames and 5,339 bytes. Inverting a paletted image means inverting its palette entries, not its pixel indexes, so the color work is exact: the surviving frame has 0 changed pixels out of 120,000 and a maximum difference of 0. But the file came out at 875 bytes with one frame. That is 4,464 bytes gone, 83.611% of the input, and five frames with them.

A default single-frame save does this quietly. The negative looks right in a thumbnail, the download is smaller, and nothing reports a missing frame. Keeping the animation is a separate decision the batch has to make explicit for every animated file in the queue. One tool page in the results states that all frames are inverted and the animation timing is preserved; our six-frame file did not survive the default path.

Your call: Whether your folder contains animations is something only you can check before the run. I built one six-frame file on purpose and measured the default save. I do not know what is in your folder, and I did not test the tool you are about to use.

5. Two files that stopped the line, and did not stop the batch

The 16-bit grayscale PNG reached the arithmetic and failed at the rebuild: Invalid mode for data type after 13.21 ms. A 16-bit sample needs 65535 minus its value, and the resulting array has to be turned back into an image of the right mode; that step is where this file died. The truncated JPEG failed earlier and cheaper: image file is truncated (2 bytes not processed) after 0.77 ms, before any inversion was attempted.

Both were skipped. The remaining ten files were written. That is a choice in how the loop is written, not a property of inversion: a loop that aborts on the first error would have delivered one file here, because the bad JPEG sat second in the queue. Ten outputs from twelve inputs looks like a normal partial success from either implementation, which is why the delivered count has to be compared against the input list, not against a feeling.

6. The alpha trap

The transparent logo is 960,000 pixels, of which 607,580 are fully transparent (63.29%) and 352,420 are opaque. Invert only the RGB channels and copy alpha unchanged, and the result has 0 changed pixels, 8,374 bytes, and the same see-through shape. Apply 255 - v to all four channels and every one of the 960,000 alpha values flips: the 607,580 transparent pixels become opaque and the 352,420 opaque ones become transparent. The negative looks like a solid rectangle with a hole in it.

In a batch this is worse than in a single file. The same button lands on RGB, RGBA, L and P modes in one pass, so a handful of logos come out with their cutouts inverted while the photographs look fine. Nothing in the output filenames marks the difference.

960,000 pixels in the RGBA logo original alpha 607,580 transparent (63.29%) 352,420 opaque RGB only (correct) unchanged — 0 pixels drift all 4 channels (naive) all 960,000 alpha values flipped
Light blocks are transparent, dark blocks opaque. Only the third row changes the cutout.

7. Determinism, checked two ways

Two byte-identical portrait JPEGs went in. Both came out at 2,343,697 bytes with 5,232,791 changed pixels each, and their SHA-256 prefixes match at 16845361c0b7ad88. The GIF was inverted and saved twice; both runs produced 875 bytes, byte-identical. The subtraction itself is deterministic. What varies between files is the encoder they are handed to afterwards.

8. Invert twice and you get the input back — in memory

Since 255 - (255 - v) = v, inversion is its own inverse. We ran the double inversion on all twelve inputs in memory: the ten readable files returned 0 changed pixels across 62,536,384 pixels, with maximum difference 0. The two broken files never reached the comparison.

Scope: that is arithmetic on decoded arrays, with no disk write in between. It is not a claim that saving twice restores your original bytes. Each save re-encodes lossy formats, which is exactly the drift in section 3. A film negative needs more than a color inversion to become a photograph again; the single-file guide covers that separately.

9. What the run cost

The twelve-file pass took 2,991.21 ms end to end, averaging 299.12 ms per written file. The slowest was the 9,000,000-pixel PNG at 1,499.99 ms; the 16,384-pixel icon took 7.73 ms. Splitting the work: 1,325.14 ms in the subtraction (44.3%) and 1,666.08 ms in saving (55.7%). The save is both the larger half of the clock and the only half that changes pixels. These are local script timings, not a browser benchmark, and they scale with pixel count rather than with file count.

2,991.21 ms for the whole batch subtract 1,325.14 ms (44.3%) save 1,666.08 ms (55.7%) Only the right-hand block changes pixels. Local run, 12 files, Pillow 13.0.0.
Less than half the time is spent doing the inversion.

10. What was measured, and what was not

Measured: one inversion of twelve local files, each output reopened from disk and compared against the exact negative of its decoded input. Bytes, pixel differences, frame counts, alpha behavior, hashes, error strings and timings all come from that run.

Not measured: any online tool, any browser implementation, HEIC, AVIF, TIFF, RAW or color profiles, per-file settings inside one queue, partial or selective inversions, or a queue larger than twelve. Where this page says a tool "can" do something, it describes file behavior reproduced locally, not a claim about a specific product. We also did not measure what happens when the batch is asked to keep all frames of an animation; section 4 reports only what the default save did.

11. A six-step pass before you queue anything

  1. List the queue: filename, format, mode, dimensions, frame count, and whether an alpha channel is present. The last two columns produce the silent failures.
  2. Pull animations, 16-bit files and anything with alpha out of the uniform pass. They do not share a save path with a JPEG.
  3. Decide whether lossy files are allowed a second encode. If not, convert to a lossless format first and invert that.
  4. Make the tool report the output count, and compare it to the input list. Ten out of twelve is not the same result as twelve.
  5. Put a known file at the head and a byte-identical copy at the tail. Their output hashes should match.
  6. Open one transparent file, one animation and one JPEG after the run. The thumbnail grid will not tell you what happened to any of them.
Your call: Whether a second encode is acceptable for your photos is your judgement, not a number I can measure for you. I measured the cost of one re-encode at fixed settings. I did not measure your tolerance for it.

Related guides

Questions people ask

Can I invert the colors of a whole batch of images at once?

Yes, but it is not one operation. It is one subtraction per file followed by one save per file, and the save decides what you get back. In a twelve-file run, ten files were written and two failed to open. The three PNGs and the GIF came back with zero changed pixels, the five JPEGs with 28.562% to 47.815% changed, and the WebP with 58.071%.

Does a batch invert keep every frame of an animated GIF?

Not automatically. A six-frame 400×300 animation went into our batch at 5,339 bytes and came out at 875 bytes with one frame, a loss of 83.611% of the bytes. The palette entries were inverted correctly, so the surviving frame had zero changed pixels, but a default single-frame save discarded the other five. Keeping an animation needs an explicit all-frames save.

Why did my transparent logo turn into a solid block after a batch invert?

The alpha channel was inverted along with the color channels. In our 960,000-pixel RGBA logo, 607,580 pixels were fully transparent (63.29%). Subtracting every channel from 255 flips all 960,000 alpha values: the 607,580 transparent pixels become opaque and the 352,420 opaque ones become transparent. Inverting only the RGB channels and copying alpha unchanged changed zero pixels and left the file at 8,374 bytes instead of 8,367.

Why does a 16-bit grayscale PNG fail in a batch invert?

Because 16-bit samples need 65535 minus the value, not 255 minus the value, and the file has to be rebuilt as a 16-bit image afterwards. Our 800×600 I;16 file stopped at that rebuild with the error Invalid mode for data type after 13.21 milliseconds. A truncated JPEG in the same queue failed separately with image file is truncated (2 bytes not processed) after 0.77 milliseconds. Both were skipped and the remaining ten files were written.

Does inverting a batch twice give me the original files back?

In memory, yes: subtracting from 255 twice returns the input exactly, and our ten readable files came back with zero changed pixels across 62,536,384 pixels. That is arithmetic, not a round trip through disk. Saving after each pass re-encodes lossy formats again, which is where the drift reported on this page comes from.

Your call: Which of these five failures matters to your folder is for you to say. I measured all of them on files I built; I have not seen your queue.
Invert a picture in your browser — no upload