// 05.Oct.2009

Dynamic Grayscale Conversion with PHP and GD

A powerful grayscale function for use with the GD graphics library — one that is both easy to use, and customizable. Most grayscale functions typically average the red, green, and blue values of each of an image's pixels, then set each RGB value to that average. This grayscale function can do that, too, and it works fine — but it is also able to take account of the relative amount that each color contributes to a pixel's intensity. As a result, pixels that are disproportionately weighted toward one color contribute more to the total intensity than if they tended to neutral — something altogether lost if simply averaging. As a further option, the results of both processes can be blended to produce a weighted average, and arguably the best final image.

Last Revision: October 5th, 2009 at 06:42

Comments are closed.