Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?
    Last edited by brothercake; 03-17-2003 at 11:14 PM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •