I got obsessed with this topic after spending an afternoon trying to remove a watermark from one of my own images. Not someone else’s, mine. I’d exported a batch of photos through an old piece of software that had stamped its logo in the corner, and I wanted it gone. What started as a twenty-minute annoyance turned into me reading about alpha blending for three hours. I regret nothing.
Here’s what I learned, and why the math behind watermarks is actually a lot more interesting than I expected.

What Alpha Even Is
Every pixel in a digital image stores color information, usually as red, green, and blue values. But there’s a fourth channel that doesn’t get as much attention: alpha. Alpha represents opacity, how transparent or opaque that pixel is. A fully opaque pixel has an alpha value of 255 (in 8-bit color). A fully transparent pixel has an alpha value of 0. Everything in between is a blend.
That range from 0 to 255 is where watermarks live.
When you place a watermark over an image, you’re not simply drawing on top of it the way you’d write on paper. You’re combining two separate layers using a formula that decides how much of each layer to show. The formula cares about the alpha value of the top layer, which is your watermark, to figure out exactly how much of the underlying image should bleed through.
The Formula That Makes It Work
The standard alpha compositing equation is older than most people realize. Porter and Duff published it in 1984, and it’s been the foundation of digital compositing ever since. The basic “over” operation, which is what almost every watermark uses, looks like this:
Output = (Alpha × Foreground) + ((1 – Alpha) × Background)
Let me make that concrete. Say your watermark pixel has an alpha of 0.5, a foreground color value of 200 (out of 255), and the background image pixel at that same position has a value of 100. The output pixel value would be:
(0.5 × 200) + ((1 – 0.5) × 100) = 100 + 50 = 150
That resulting pixel is a blend, sitting exactly halfway between the watermark color and the background. At alpha 0.5, you’re splitting the contribution evenly. Crank alpha up to 0.9 and the watermark dominates. Drop it to 0.1 and you barely see it.
What surprised me when I first worked through this is how purely linear it is. There’s no curve, no perceptual correction, no magic. It’s weighted averaging. The alpha value is literally just a weight.
Why Watermarks Are Usually Partially Transparent
This seems obvious once you think about it, but it’s worth understanding why 100% opacity watermarks are actually pretty bad at their job, even though they’re harder to remove.
A fully opaque watermark obliterates the content underneath. If you’re protecting a photograph and your watermark covers 30% of the frame at full opacity, you’ve just destroyed 30% of the image’s value. Nobody’s buying that. So commercial watermarks tend to sit somewhere between 30% and 70% opacity, visible enough to deter casual theft but transparent enough to still show what the image actually looks like.
The tradeoff is real though. Lower opacity means easier removal. That’s the core tension that every watermarking system has to deal with, and alpha blending is right at the center of it.
Premultiplied vs. Straight Alpha: The Part That Trips People Up
I spent an embarrassing amount of time confused about this before it clicked.
There are two ways to store alpha information in an image file. Straight alpha (sometimes called unassociated alpha) stores the color channels and alpha channel independently. The RGB values represent the full, unmodified color of the pixel regardless of its transparency. Premultiplied alpha (associated alpha) bakes the alpha into the color channels already. Each RGB value has already been multiplied by the alpha before being stored.
So for a pixel with color (200, 100, 50) and alpha 0.5, straight alpha stores it as (200, 100, 50, 0.5). Premultiplied alpha stores it as (100, 50, 25, 0.5) because each color channel has already been multiplied by 0.5.
Why does this matter for watermarks? Because if you apply the alpha compositing formula to premultiplied data as if it were straight alpha, you get wrong results. Double-multiplication artifacts. Colors that look wrong, usually too dark or washed out in ways that are hard to pin down. I ran into exactly this when I was trying to composite a PNG watermark with a premultiplied alpha channel over a JPEG background in a script I was writing. The logo looked fine around the edges but had a weird dark fringe that I couldn’t explain for about an hour. That’s what incorrect alpha handling looks like.
Most image processing libraries handle this automatically if you use them correctly. But if you’re doing manual pixel operations, you need to know which format you’re working with.
How This Connects to Watermark Removal
Understanding the math immediately tells you why watermark removal is a solvable problem in some cases and an impossible one in others.
If the watermark is applied at a known, consistent alpha value across the entire image, removal is essentially algebra. You know the output pixel value. You know the foreground watermark color (you can sample it from a solid area of the watermark). You know the alpha. Rearrange the equation and you can solve for the background:
Background = (Output – (Alpha × Foreground)) / (1 – Alpha)
That works perfectly when the watermark is a flat color at consistent opacity. In practice, most professional watermarks aren’t that simple. They have varying opacity across the design, often with feathered edges, gradient transparency, and colored elements that make the math harder. The more complex the alpha channel of the watermark, the harder this kind of algebraic reversal becomes.
And when alpha hits 1.0, the math breaks. Division by zero. You genuinely can’t recover information from a fully opaque watermark using this approach. The original pixel data is gone. That’s why text watermarks with hard edges at full opacity are the most destructive to image value but the most resistant to mathematical removal.
Tiled and Diagonal Watermarks: Harder Than They Look
You’ve seen these, the repeating diagonal text patterns that cover an entire image rather than sitting in one corner. Getty Images uses something like this. Shutterstock too.
The alpha math is the same, but the removal problem gets harder for a different reason: there’s no clean area of the original image to reference. When a watermark sits only in the corner, the rest of the image is untouched and gives you information about the original content. When a tiled watermark covers everything, you have no clean reference. Every pixel you’re looking at is blended. You can try to solve the system of equations across the whole image simultaneously, but that gets computationally expensive fast and relies on assumptions about the underlying image that may or may not be valid.
Modern AI-based inpainting approaches attack this differently, by predicting what the underlying content should look like rather than mathematically inverting the blend. That’s a whole separate topic, but the reason those tools have gotten good is that the mathematical approach has real limits that they’re trying to route around.
The Gamma Problem
Here’s the part that I think gets skipped in most explanations, and it actually affects what your watermark looks like.
Digital images aren’t stored in a linear light space. They’re typically gamma-corrected, meaning the values stored in the file are put through a curve before display to account for how our eyes perceive brightness. The sRGB color space uses a gamma of approximately 2.2, meaning stored values are raised to the power of 2.2 to get actual linear light values.
When you do alpha blending in gamma-encoded space (which is what most simple implementations do), you get a result that’s mathematically correct relative to the stored values but perceptually wrong relative to actual light. Blending in linear light gives you physically accurate mixing. Blending in gamma space gives you results that tend to look slightly too dark at the midpoints.
Honestly, for most watermark applications this doesn’t matter much. The error is subtle and most viewers will never notice. But if you’re doing precision compositing work, or you’re wondering why your carefully calculated 50% blend looks a little off, gamma is probably why. I went down this rabbit hole for a project where I was matching a logo to background tones and couldn’t figure out why my math wasn’t giving me what I expected visually. Gamma correction was the answer.
What This Means If You’re Building Something
If you’re implementing watermarking yourself, a few things follow directly from all of this.
Alpha consistency matters. If your watermark opacity varies across the design and you haven’t documented what alpha values correspond to which parts, you’ve made your own system harder to manage. Pick intentional opacity levels and stick to them.
Know your color space. Are you working in sRGB or linear light? Are your alpha values premultiplied or straight? These aren’t aesthetic choices, they’re technical ones that affect correctness. Most image editors default to straight alpha in the UI and handle conversion internally, but the moment you start processing images programmatically, you need to know what you’re actually dealing with.
The “invisible” watermark problem is real. If you go too low on opacity to avoid disrupting the image, you’re not really protecting anything. I’ve seen watermarks at 15% opacity that completely disappear when the image is displayed on a slightly bright monitor. Save yourself the trouble and test your watermark on different displays and backgrounds before deploying it.
The math here isn’t complicated. A weighted average, a fourth channel, two conventions for storing that channel. But getting it wrong produces results that are annoying in ways that are hard to diagnose if you don’t know what to look for. That afternoon I spent trying to fix my watermark problem turned out to be pretty useful in the end, even if it didn’t feel like it at the time.
What’s the difference between alpha blending and alpha compositing?
They’re closely related. Alpha blending refers to the mathematical operation of mixing two values using an alpha weight. Alpha compositing is the broader process of combining image layers, which uses alpha blending as its core operation. In practice people use the terms interchangeably and nobody will look at you funny either way.
Can you remove any watermark if you know the alpha value?
In theory, yeah, if the alpha is consistent and the watermark color is known. In practice, most watermarks have variable opacity, colored gradients, or sit over areas where you can’t cleanly sample the watermark color. The math breaks down fast once you leave the simple case.
Does JPEG compression affect alpha channels?
JPEG doesn’t support alpha at all. If you save a transparent PNG as a JPEG, the alpha channel gets flattened against a background color, usually white, and it’s gone. For watermarks, this matters because a semi-transparent PNG watermark baked into a JPEG export has its alpha permanently merged into the pixel data. There’s no separate alpha channel to work with afterward.
What opacity level should I use for a watermark?
Somewhere between 40% and 60% is what most people land on for visible but non-destructive. Below 30% and it’s easy to miss. Above 70% and you start significantly degrading the image. That said, it depends on the watermark design, the background complexity, and how much protection you actually need versus how much you want the image to sell itself.
Is the Porter-Duff formula the only way to do alpha compositing?
No, Porter and Duff actually defined twelve compositing operations in their original paper. “Over” is just the most common one, and the one used for layering a watermark on top of content. Others handle things like masking, cutting out, or combining layers in different ways. Most image editing software exposes some of these as blending modes.