Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-17-2003, 11:12 PM   PM User | #1
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
How would I make an image pre-processor?

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?
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

Last edited by brothercake; 03-17-2003 at 11:14 PM..
brothercake is offline   Reply With Quote
Old 03-17-2003, 11:43 PM   PM User | #2
Ökii
Regular Coder

 
Join Date: Jun 2002
Location: UK
Posts: 577
Thanks: 0
Thanked 0 Times in 0 Posts
Ökii is an unknown quantity at this point
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.
__________________
Ökii - formerly pootergeist
teckis - take your time and it'll save you time.
Ökii is offline   Reply With Quote
Old 03-17-2003, 11:46 PM   PM User | #3
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,220
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
The GD library has lots of image manipulation functions:

http://www.php.net/manual/en/function.imagecolorat.php
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 03-17-2003, 11:52 PM   PM User | #4
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
Thanks guys; I'll check it out
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
brothercake is offline   Reply With Quote
Old 03-18-2003, 09:37 AM   PM User | #5
Ökii
Regular Coder

 
Join Date: Jun 2002
Location: UK
Posts: 577
Thanks: 0
Thanked 0 Times in 0 Posts
Ökii is an unknown quantity at this point
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
PHP Code:
// $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.
__________________
Ökii - formerly pootergeist
teckis - take your time and it'll save you time.
Ökii is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:58 PM.


Advertisement
Log in to turn off these ads.