View Full Version : How would I make an image pre-processor?

03-17-2003, 11:12 PM
Say I've got a GIF image - I want to extract its pixel data, do a transformation on each color value, and then generate a new image with these values.

The middle bit is easy; but the first and last bit I have no idea about - I guess I need some kind of library or extension to do this?

03-17-2003, 11:43 PM
could and do do it for jpeg, bmp and png (and possibly even swf at a push) though without the rights to the LZW compression algorythm, reading/writing gifs would be darn tricky.

Take a gander at GD / Gimp (and script-fu) or ImageMagick for image manipulations.
I'll be ready to answer any GD related questions.

03-17-2003, 11:46 PM
The GD library has lots of image manipulation functions:


03-17-2003, 11:52 PM
Thanks guys; I'll check it out :thumbsup:

03-18-2003, 09:37 AM
There is a rather useful GD2+ manipulation class that extends the basic functionality of GD spreading through various sites (resourceindex.com, phpclasses.org, phpfreaks.com and phpbuilder.com.
) - main page:

The drop-shadow effect could do with some work - when I get the time and motivation :)

if you wanted the rgb of a pixel, you could use

// $this->r = image height
for( $this->dy = 0; $this->dy <= $this->r; $this->dy++ )
// this->q = image width
for( $this->dx = 0; $this->dx <= $this->q; $this->dx++ )
$this->pxrgb = imagecolorat($this->t, $this->dx, $this->dy);
$this->rgb = ImageColorsforIndex( $this->t, $this->pxrgb );
// leaves $this->rgb['red'] = the red value etc - 'green' - 'blue'
$this->setcol = ImageColorAllocate( $this->t, $this->newcol, $this->newcol, $this->newcol );
imagesetpixel( $this->t, $this->dx, $this->dy, $this->setcol );

might give you a hint of functions to use for a procedural approach anyway.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum