Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPied.com:
Image fun (with PHP and GD)
Sep 14, 2005 @ 11:03:13

On PHPied.com today they've having a little Image Fun with a few examples of image manipulation with PHP and the GD libraries.

Here are some examples of image manipulation using the GD library, more specifically these are pixel operations. Pixel operation meaning doing something to a pixel in an image with regards to this pixel only, not taking into account the neighbours.

An example pixel operation is making a negative image. You take every pixel in an image and substitute it with its opposite color pixel.

They give you all the code to create the "pixel class" and include an "add noise" function that can increase the noise by whatever factor you give it. There's other functions to control other attributes of the image as well, including: brightness, color swapping, removing/boosting colors, making the image negative, greyscaling it, making a black and while image of it, clipping, adjusting contrast, adding "salt and pepper", gamma correction, and a randomize function (for calling a random one of any of the above functions).

This is a ton of stuff to take in, but it's a great chunk of code to have around, especially if you see your project using any kind of image manipulation in the future...

tagged:

Link:


Trending Topics: