you should use the return value of the command imagecolorat to get the alpha transparency with the code below because it's much faster and will have a major impact if you process every pixel of an image:

If you would like to change the intensity or lightness level of a specific color, you will need to convert the color format from RGB to HSL. following function convert RGB array(red,green,blue) to HSL array(hue, saturation, lightness)<?php/** * Convert RGB colors array into HSL array * * @param array $ RGB colors set * @return array HSL set */function rgb2hsl($rgb){

Here's a better grayscale, sepia, and general tinting function. This function is better because:

1) Works with true color images (the other sepia code didn't).2) Provides a more gooder grayscale conversion (yes, I said "more gooder"). The other grayscale code used imagetruecolortopalette, which just doesn't work well for grayscale conversion.3) The other sepia code was really colorful, a little too much for my taste. This function allows you to optionally set the tinting of the grayscale to anything you wish.4) Single function for grayscale, sepia, and any other tinting you can dream up.

Here's some examples:

imagegrayscaletint ($img); // Grayscale, no tintingimagegrayscaletint ($img,304,242,209); // What I use for sepiaimagegrayscaletint ($img,0,0,255); // A berry blue image

The RGB values for tinting are normally from 0 to 255. But, you can use values larger than 255 to lighten and "burn" the image. The sepia example above does this a little, the below example provides a better example of lightening the image and burning the light areas out a little: