Method

VipsImageunpremultiply

Declaration [src]

int
vips_unpremultiply (
  VipsImage* in,
  VipsImage** out,
  ...
)

Description [src]

Unpremultiplies any alpha channel.

Band alpha_band (by default the final band) contains the alpha and all other bands are transformed as:

alpha = (int) clip(0, in[in.bands - 1], max_alpha);
norm = (double) alpha / max_alpha
if (alpha == 0)
    out = [0, ..., 0, alpha]
else
    out = [in[0] / norm, ..., in[in.bands - 1] / norm, alpha]

So for an N-band image, the first N - 1 bands are divided by the clipped and normalised final band, the final band is clipped. If there is only a single band, the image is passed through unaltered.

The result is VipsBandFormat unless the input format is VipsBandFormat, in which case the output is double as well.

max_alpha has the default value 255, or 65535 for images tagged as VipsInterpretation or VipsInterpretation, and 1.0 for images tagged as [enum@Vips.Interpretation.scRGB.

Non-complex images only.

::: tip “Optional arguments” * max_alpha: gdouble, maximum value for alpha * alpha_band: gint, band containing alpha data

::: seealso vips_premultiply(), vips_flatten().

Parameters

out VipsImage
 

Output image.

 The argument will be set by the function.
 The instance takes ownership of the data, and is responsible for freeing it.
... none
 

NULL-terminated list of optional named arguments.

Return value

Returns: int
 

0 on success, -1 on error.