Image2Negative

Here's a neat piece of PHP code that'll convert an image into its negative..

Image


CODE:
function img2neg($pic) {

   header("Content-type: image/jpeg");

   $source=imagecreatefromjpeg($pic);   // Source
   $width=imagesx($source);   $height=imagesy($source);
   $im = imagecreatetruecolor($width, $height);   // Our negative img in the making

   for($y=0; $y < $height; $y++) {
      for($x=0; $x < $width; $x++) {

         $colors=imagecolorsforindex($source, imagecolorat($source, $x,$y));   // Extract the pixel color
         // this is what makes the colors negative
         $r=255-$colors['red'];
         $g=255-$colors['green'];
         $b=255-$colors['blue'];
         $test=imagecolorallocate($im, $r,$g,$b);
         imagesetpixel($im,$x, $y, $test);
      }
   }

   imagejpeg($im);
   imagedestroy($im);
}


Download the zip (with the donkey kong pic ;) )
Posted by Shan   www
on April 30, 2006, 5:25 pm
Why are these images not coming?

btw, its a good utility we were looking for.


( Reply to this comment )
Posted by JOHN   www
on February 13, 2007, 1:56 pm
that looks god

( Reply to this comment )
Posted by so   www
on June 13, 2007, 10:04 am
HA HU VA

( Reply to this comment )
Posted by so   www
on June 13, 2007, 10:05 am
Posted by girls nude on webcams   www
on June 28, 2007, 2:59 pm
doesn't seem to work..do you need anything installed on your server to get this working?

( Reply to this comment )
Posted by Faydalı siteler   www
on January 25, 2008, 5:00 pm
Thank you for this post

( Reply to this comment )
Posted by Muhabbet odası   www
on April 23, 2008, 2:12 pm
Thank you

( Reply to this comment )
Posted by mirc   www
on October 9, 2008, 9:54 pm
good sharing, thank you.

( Reply to this comment )
Posted by film izle   www
on November 2, 2008, 7:13 pm
teoman - dus

( Reply to this comment )