Author: Valentin Schmidt
This script allows to use images (PNGs or JPGs) with alpha channels. The alpha channel can be supplied either
via a separate PNG image (called a mask) or, for PNGs, an internal alpha channel can be used directly.
For the latter, the GD 2.x extension is required.
The mask must be a gray scale image (not palette-based nor true color). A black pixel means that the corresponding
pixel in the main image is fully transparent; a white pixel means it's opaque. Values in between mean different
degrees of transparency.
Using a mask has several advantages:
- GD is not required
- Better quality (full 8-bit alpha channel, whereas GD internally only supports 7-bit alpha channels)
- Much faster (extraction of embedded alpha channel has to be done pixel-wise)
A new version of Image() is provided:
Image(string file, float x, float y [, float w [, float h [, string type [, mixed link [, boolean isMask [, int maskImg]]]]]])
The parameters are the same as for the original method, with 2 additional (optional) ones:
isMask: if specified and
true, the image is used as a mask for another image. In this case,
the parameters x, y, w and h will be ignored and the mask image itself is not visible on
maskImg: number of image resource (as returned by previously called Image() with isMask
parameter set to
true) that will be used as a mask for this image.
This version supports PNGs with internal alpha channel. Alternatively, you can also use this method:
ImagePngWithAlpha(string file, float x, float y [, float w [, float h [, mixed link]]])
The parameters are the same as for the original method, but without the
Note: alpha channel requires at least Acrobat Reader 5.