...

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



brothercake
03-18-2003, 12:12 AM
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?

Íkii
03-18-2003, 12:43 AM
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.

Spookster
03-18-2003, 12:46 AM
The GD library has lots of image manipulation functions:

http://www.php.net/manual/en/function.imagecolorat.php

brothercake
03-18-2003, 12:52 AM
Thanks guys; I'll check it out :thumbsup:

Íkii
03-18-2003, 10: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:
http://www.teckis.com/compiled_files/img_create.php

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