Grayscaling Image with GD causes image to turn jet black!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    Grayscaling Image with GD causes image to turn jet black!

    I borrowed this code from a source:



    for($a=0;$a<ima gecolorstotal ($image_id);$a+ +)
    {
    $color = imageColorsForI ndex($image_id, $i);
    $R=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
    ($color['blue']);
    $G=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
    ($color['blue']);
    $B=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
    ($color['blue']);
    imageColorSet($ image_id, $a, $R, $G, $B);
    }

    using an image (in this case I'm using a JPEG) that is a true color
    image I was unable to successfully use imagecopymergeg ray since that
    washed out my hues/saturation altogether making the image illegible
    (imagecopymerge gray + imagecreate); otherwise, the colors overrode
    imagecopymergeg ray (imagecopymerge gray + imagecreatetrue color).

    Using the code I borrowed I was able to change the image.. except that
    it turned jet black instead!

    Has anyone ever successfully grayscaled an image using GD library? If
    so, how did you do it?

    Thanx
    Phil
  • CountScubula

    #2
    Re: Grayscaling Image with GD causes image to turn jet black!

    Try running an average of the three colors:
    $avg = floor( ( $color['red']) + $color['green']) + $color['blue']) ) / 3 )
    $R= $avg; $B = $avg; $G = $avg;
    imageColorSet($ image_id, $a, $R, $G, $B);


    --
    Mike Bradley
    http://www.gzentools.com -- free online php tools
    "Phil Powell" <soazine@erols. com> wrote in message
    news:1cdca2a7.0 402030910.a9109 fc@posting.goog le.com...[color=blue]
    > I borrowed this code from a source:
    >
    >
    >
    > for($a=0;$a<ima gecolorstotal ($image_id);$a+ +)
    > {
    > $color = imageColorsForI ndex($image_id, $i);
    > $R=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
    > ($color['blue']);
    > $G=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
    > ($color['blue']);
    > $B=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
    > ($color['blue']);
    > imageColorSet($ image_id, $a, $R, $G, $B);
    > }
    >
    > using an image (in this case I'm using a JPEG) that is a true color
    > image I was unable to successfully use imagecopymergeg ray since that
    > washed out my hues/saturation altogether making the image illegible
    > (imagecopymerge gray + imagecreate); otherwise, the colors overrode
    > imagecopymergeg ray (imagecopymerge gray + imagecreatetrue color).
    >
    > Using the code I borrowed I was able to change the image.. except that
    > it turned jet black instead!
    >
    > Has anyone ever successfully grayscaled an image using GD library? If
    > so, how did you do it?
    >
    > Thanx
    > Phil[/color]


    Comment

    • Phil Powell

      #3
      Re: Grayscaling Image with GD causes image to turn jet black!

      I'm sorry but that too breaks. Perhaps a code review is in order, I
      realize that imageColorsTota l($this->image) produces 0, which I am
      afraid I don't understand:

      class ImageGrayscaleG enerator {

      /*---------------------------------------------------------------------------------------------------------------------------------------------------------
      This class exists due to the rather poor performance of the
      imagecopymergeg ray() command
      Borrowing code snippet from
      http://us3.php.net/manual/en/functio...ymergegray.php first
      line comment
      Will perform actual grayscaling of image one pixel at a time.
      -----------------------------------------------------------------------------------------------------------------------------------------------------------*/

      var $image, $image_width, $image_height;

      // REMEMBER TO USE REFERENCE POINTER ONTO $image OBJECT TO ENSURE
      "static" CHANGE TO OBJECT AND NOT TO INSTANCE

      function ImageGrayscaleG enerator(&$imag e) { // CONSTRUCTOR
      $this->image =& $image;
      }

      function makeGray() { // VOID METHOD
      print_r($this->image); print_r("<P>");
      print_r(@imageC olorsTotal($thi s->image) . "<P>");
      for ($i = 0; $i < @imagecolorstot al($this->image); $i++) {
      $colorArray = @imageColorsFor Index($this->image, $i);
      print_r($colorA rray); print_r("<P>");
      $avg = floor(($colorAr ray['red'] + $colorArray['green'] +
      $colorArray['blue']) / 3);
      @imageColorSet( $this->image, $i, $avg, $avg, $avg);
      }
      }
      }


      Thanx
      Phil

      "CountScubu la" <me@scantek.hot mail.com> wrote in message news:<_rSTb.197 24$up5.18401@ne wssvr27.news.pr odigy.com>...[color=blue]
      > Try running an average of the three colors:
      > $avg = floor( ( $color['red']) + $color['green']) + $color['blue']) ) / 3 )
      > $R= $avg; $B = $avg; $G = $avg;
      > imageColorSet($ image_id, $a, $R, $G, $B);
      >
      >
      > --
      > Mike Bradley
      > http://www.gzentools.com -- free online php tools
      > "Phil Powell" <soazine@erols. com> wrote in message
      > news:1cdca2a7.0 402030910.a9109 fc@posting.goog le.com...[color=green]
      > > I borrowed this code from a source:
      > >
      > >
      > >
      > > for($a=0;$a<ima gecolorstotal ($image_id);$a+ +)
      > > {
      > > $color = imageColorsForI ndex($image_id, $i);
      > > $R=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
      > > ($color['blue']);
      > > $G=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
      > > ($color['blue']);
      > > $B=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
      > > ($color['blue']);
      > > imageColorSet($ image_id, $a, $R, $G, $B);
      > > }
      > >
      > > using an image (in this case I'm using a JPEG) that is a true color
      > > image I was unable to successfully use imagecopymergeg ray since that
      > > washed out my hues/saturation altogether making the image illegible
      > > (imagecopymerge gray + imagecreate); otherwise, the colors overrode
      > > imagecopymergeg ray (imagecopymerge gray + imagecreatetrue color).
      > >
      > > Using the code I borrowed I was able to change the image.. except that
      > > it turned jet black instead!
      > >
      > > Has anyone ever successfully grayscaled an image using GD library? If
      > > so, how did you do it?
      > >
      > > Thanx
      > > Phil[/color][/color]

      Comment

      • CountScubula

        #4
        Re: Grayscaling Image with GD causes image to turn jet black!

        sorry, I didnt really look at the code, how is it breaking, error, not
        working?

        --
        Mike Bradley
        http://www.gzentools.com -- free online php tools
        "Phil Powell" <soazine@erols. com> wrote in message
        news:1cdca2a7.0 402040711.63478 c64@posting.goo gle.com...[color=blue]
        > I'm sorry but that too breaks. Perhaps a code review is in order, I
        > realize that imageColorsTota l($this->image) produces 0, which I am
        > afraid I don't understand:
        >
        > class ImageGrayscaleG enerator {
        >
        >[/color]
        /*--------------------------------------------------------------------------
        ----------------------------------------------------------------------------
        ---[color=blue]
        > This class exists due to the rather poor performance of the
        > imagecopymergeg ray() command
        > Borrowing code snippet from
        > http://us3.php.net/manual/en/functio...ymergegray.php first
        > line comment
        > Will perform actual grayscaling of image one pixel at a time.
        > --------------------------------------------------------------------------[/color]
        ----------------------------------------------------------------------------
        -----*/[color=blue]
        >
        > var $image, $image_width, $image_height;
        >
        > // REMEMBER TO USE REFERENCE POINTER ONTO $image OBJECT TO ENSURE
        > "static" CHANGE TO OBJECT AND NOT TO INSTANCE
        >
        > function ImageGrayscaleG enerator(&$imag e) { // CONSTRUCTOR
        > $this->image =& $image;
        > }
        >
        > function makeGray() { // VOID METHOD
        > print_r($this->image); print_r("<P>");
        > print_r(@imageC olorsTotal($thi s->image) . "<P>");
        > for ($i = 0; $i < @imagecolorstot al($this->image); $i++) {
        > $colorArray = @imageColorsFor Index($this->image, $i);
        > print_r($colorA rray); print_r("<P>");
        > $avg = floor(($colorAr ray['red'] + $colorArray['green'] +
        > $colorArray['blue']) / 3);
        > @imageColorSet( $this->image, $i, $avg, $avg, $avg);
        > }
        > }
        > }
        >
        >
        > Thanx
        > Phil
        >
        > "CountScubu la" <me@scantek.hot mail.com> wrote in message[/color]
        news:<_rSTb.197 24$up5.18401@ne wssvr27.news.pr odigy.com>...[color=blue][color=green]
        > > Try running an average of the three colors:
        > > $avg = floor( ( $color['red']) + $color['green']) + $color['blue']) ) /[/color][/color]
        3 )[color=blue][color=green]
        > > $R= $avg; $B = $avg; $G = $avg;
        > > imageColorSet($ image_id, $a, $R, $G, $B);
        > >
        > >
        > > --
        > > Mike Bradley
        > > http://www.gzentools.com -- free online php tools
        > > "Phil Powell" <soazine@erols. com> wrote in message
        > > news:1cdca2a7.0 402030910.a9109 fc@posting.goog le.com...[color=darkred]
        > > > I borrowed this code from a source:
        > > >
        > > >
        > > >
        > > > for($a=0;$a<ima gecolorstotal ($image_id);$a+ +)
        > > > {
        > > > $color = imageColorsForI ndex($image_id, $i);
        > > > $R=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
        > > > ($color['blue']);
        > > > $G=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
        > > > ($color['blue']);
        > > > $B=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
        > > > ($color['blue']);
        > > > imageColorSet($ image_id, $a, $R, $G, $B);
        > > > }
        > > >
        > > > using an image (in this case I'm using a JPEG) that is a true color
        > > > image I was unable to successfully use imagecopymergeg ray since that
        > > > washed out my hues/saturation altogether making the image illegible
        > > > (imagecopymerge gray + imagecreate); otherwise, the colors overrode
        > > > imagecopymergeg ray (imagecopymerge gray + imagecreatetrue color).
        > > >
        > > > Using the code I borrowed I was able to change the image.. except that
        > > > it turned jet black instead!
        > > >
        > > > Has anyone ever successfully grayscaled an image using GD library? If
        > > > so, how did you do it?
        > > >
        > > > Thanx
        > > > Phil[/color][/color][/color]


        Comment

        • Phil Powell

          #5
          Re: Grayscaling Image with GD causes image to turn jet black!

          "CountScubu la" <me@scantek.hot mail.com> wrote in message news:<bEdUb.202 02$CX7.1043@new ssvr27.news.pro digy.com>...[color=blue]
          > sorry, I didnt really look at the code, how is it breaking, error, not
          > working?[/color]


          I'll show you, just go down and view...

          Phil
          [color=blue]
          >
          > --
          > Mike Bradley
          > http://www.gzentools.com -- free online php tools
          > "Phil Powell" <soazine@erols. com> wrote in message
          > news:1cdca2a7.0 402040711.63478 c64@posting.goo gle.com...[color=green]
          > > I'm sorry but that too breaks. Perhaps a code review is in order, I
          > > realize that imageColorsTota l($this->image) produces 0, which I am
          > > afraid I don't understand:
          > >
          > > class ImageGrayscaleG enerator {
          > >
          > >[/color]
          > /*--------------------------------------------------------------------------
          > ----------------------------------------------------------------------------
          > ---[color=green]
          > > This class exists due to the rather poor performance of the
          > > imagecopymergeg ray() command
          > > Borrowing code snippet from
          > > http://us3.php.net/manual/en/functio...ymergegray.php first
          > > line comment
          > > Will perform actual grayscaling of image one pixel at a time.
          > > --------------------------------------------------------------------------[/color]
          > ----------------------------------------------------------------------------
          > -----*/[color=green]
          > >
          > > var $image, $image_width, $image_height;
          > >
          > > // REMEMBER TO USE REFERENCE POINTER ONTO $image OBJECT TO ENSURE
          > > "static" CHANGE TO OBJECT AND NOT TO INSTANCE
          > >
          > > function ImageGrayscaleG enerator(&$imag e) { // CONSTRUCTOR
          > > $this->image =& $image;
          > > }
          > >
          > > function makeGray() { // VOID METHOD
          > > print_r($this->image); print_r("<P>");
          > > print_r(@imageC olorsTotal($thi s->image) . "<P>");[/color][/color]

          ** STOP HERE! What happens is that imageColorsTota l($this->image) =
          0! Though the image is in color and I do a reference pointer to the
          $image resource paramters in the method call, and it actually DOES
          change the image according to the value of
          imageColorsTota l($this->image), it turns the entire image into one
          jet-black image, no tone, no hue, nothing, a big black box.

          Phil
          [color=blue][color=green]
          > > for ($i = 0; $i < @imagecolorstot al($this->image); $i++) {
          > > $colorArray = @imageColorsFor Index($this->image, $i);
          > > print_r($colorA rray); print_r("<P>");
          > > $avg = floor(($colorAr ray['red'] + $colorArray['green'] +
          > > $colorArray['blue']) / 3);
          > > @imageColorSet( $this->image, $i, $avg, $avg, $avg);
          > > }
          > > }
          > > }
          > >
          > >
          > > Thanx
          > > Phil
          > >
          > > "CountScubu la" <me@scantek.hot mail.com> wrote in message[/color]
          > news:<_rSTb.197 24$up5.18401@ne wssvr27.news.pr odigy.com>...[color=green][color=darkred]
          > > > Try running an average of the three colors:
          > > > $avg = floor( ( $color['red']) + $color['green']) + $color['blue']) ) /[/color][/color]
          > 3 )[color=green][color=darkred]
          > > > $R= $avg; $B = $avg; $G = $avg;
          > > > imageColorSet($ image_id, $a, $R, $G, $B);
          > > >
          > > >
          > > > --
          > > > Mike Bradley
          > > > http://www.gzentools.com -- free online php tools
          > > > "Phil Powell" <soazine@erols. com> wrote in message
          > > > news:1cdca2a7.0 402030910.a9109 fc@posting.goog le.com...
          > > > > I borrowed this code from a source:
          > > > >
          > > > >
          > > > >
          > > > > for($a=0;$a<ima gecolorstotal ($image_id);$a+ +)
          > > > > {
          > > > > $color = imageColorsForI ndex($image_id, $i);
          > > > > $R=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
          > > > > ($color['blue']);
          > > > > $G=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
          > > > > ($color['blue']);
          > > > > $B=.299 * ($color['red'])+ .587 * ($color['green'])+ .114 *
          > > > > ($color['blue']);
          > > > > imageColorSet($ image_id, $a, $R, $G, $B);
          > > > > }
          > > > >
          > > > > using an image (in this case I'm using a JPEG) that is a true color
          > > > > image I was unable to successfully use imagecopymergeg ray since that
          > > > > washed out my hues/saturation altogether making the image illegible
          > > > > (imagecopymerge gray + imagecreate); otherwise, the colors overrode
          > > > > imagecopymergeg ray (imagecopymerge gray + imagecreatetrue color).
          > > > >
          > > > > Using the code I borrowed I was able to change the image.. except that
          > > > > it turned jet black instead!
          > > > >
          > > > > Has anyone ever successfully grayscaled an image using GD library? If
          > > > > so, how did you do it?
          > > > >
          > > > > Thanx
          > > > > Phil[/color][/color][/color]

          Comment

          • CountScubula

            #6
            Re: Grayscaling Image with GD causes image to turn jet black!

            "Phil Powell" <soazine@erols. com> wrote in message
            news:1cdca2a7.0 402042019.1ed5f cce@posting.goo gle.com...[color=blue]
            >
            > I'll show you, just go down and view...
            >
            > Phil
            >
            > < Big-O-snip >[/color]

            Sometimes easier to re-invent the wheel (thats my my cars don't have model-t
            wheels on them)
            here is some code that works, and you can test here:




            <?php

            $imgFile = "girl1.jpg" ;

            $imSrc = imagecreatefrom jpeg($imgFile);

            $imW = imagesx($imSrc) ;
            $imH = imagesy($imSrc) ;

            $imDst = imagecreate($im W,$imH);

            // create 256 shades of grey
            for ($i=0; $i<256; $i++) {
            $colorNdx[$i] = imagecoloralloc ate($imDst,$i,$ i,$i);
            }

            for ($y=0; $y<$imH; $y++)
            {
            for ($x=0; $x<$imW; $x++)
            {
            $ndx = imagecolorat($i mSrc,$x,$y);
            $ndxColors = imagecolorsfori ndex($imSrc,$nd x);
            $avg = floor( ($ndxColors['red'] + $ndxColors['green'] +
            $ndxColors['blue']) / 3 );
            imagesetpixel($ imDst,$x,$y,$co lorNdx[$avg]);
            }
            }

            imagejpeg($imDs t);
            exit();

            ?>


            --
            Mike Bradley
            http://www.gzentools.com -- free online php tools


            Comment

            • Phil Powell

              #7
              Re: Grayscaling Image with GD causes image to turn jet black!

              IT WORKED AT LAST!!! Thanx a lot. By the way, your URL produced
              ASCII-related garbage on my screen, just so you know.

              Thanx again!!
              Phil

              "CountScubu la" <me@scantek.hot mail.com> wrote in message news:<vikUb.203 69$ja5.12921@ne wssvr27.news.pr odigy.com>...[color=blue]
              > "Phil Powell" <soazine@erols. com> wrote in message
              > news:1cdca2a7.0 402042019.1ed5f cce@posting.goo gle.com...[color=green]
              > >
              > > I'll show you, just go down and view...
              > >
              > > Phil
              > >
              > > < Big-O-snip >[/color]
              >
              > Sometimes easier to re-invent the wheel (thats my my cars don't have model-t
              > wheels on them)
              > here is some code that works, and you can test here:
              > http://www.gzentools.com/test/img2gry.php
              >
              >
              >
              > <?php
              >
              > $imgFile = "girl1.jpg" ;
              >
              > $imSrc = imagecreatefrom jpeg($imgFile);
              >
              > $imW = imagesx($imSrc) ;
              > $imH = imagesy($imSrc) ;
              >
              > $imDst = imagecreate($im W,$imH);
              >
              > // create 256 shades of grey
              > for ($i=0; $i<256; $i++) {
              > $colorNdx[$i] = imagecoloralloc ate($imDst,$i,$ i,$i);
              > }
              >
              > for ($y=0; $y<$imH; $y++)
              > {
              > for ($x=0; $x<$imW; $x++)
              > {
              > $ndx = imagecolorat($i mSrc,$x,$y);
              > $ndxColors = imagecolorsfori ndex($imSrc,$nd x);
              > $avg = floor( ($ndxColors['red'] + $ndxColors['green'] +
              > $ndxColors['blue']) / 3 );
              > imagesetpixel($ imDst,$x,$y,$co lorNdx[$avg]);
              > }
              > }
              >
              > imagejpeg($imDs t);
              > exit();
              >
              > ?>[/color]

              Comment

              • CountScubula

                #8
                Re: Grayscaling Image with GD causes image to turn jet black!

                Like like I forgot to inflate the tire after I reinvented the wheel, forgot
                to put:
                header("Content-type: image/jpeg");

                --
                Mike Bradley
                http://www.gzentools.com -- free online php tools
                "Phil Powell" <soazine@erols. com> wrote in message
                news:1cdca2a7.0 402051025.2dc18 05b@posting.goo gle.com...[color=blue]
                > IT WORKED AT LAST!!! Thanx a lot. By the way, your URL produced
                > ASCII-related garbage on my screen, just so you know.
                >
                > Thanx again!!
                > Phil
                >
                > "CountScubu la" <me@scantek.hot mail.com> wrote in message[/color]
                news:<vikUb.203 69$ja5.12921@ne wssvr27.news.pr odigy.com>...[color=blue][color=green]
                > > "Phil Powell" <soazine@erols. com> wrote in message
                > > news:1cdca2a7.0 402042019.1ed5f cce@posting.goo gle.com...[color=darkred]
                > > >
                > > > I'll show you, just go down and view...
                > > >
                > > > Phil
                > > >
                > > > < Big-O-snip >[/color]
                > >
                > > Sometimes easier to re-invent the wheel (thats my my cars don't have[/color][/color]
                model-t[color=blue][color=green]
                > > wheels on them)
                > > here is some code that works, and you can test here:
                > > http://www.gzentools.com/test/img2gry.php
                > >
                > >
                > >
                > > <?php
                > >
                > > $imgFile = "girl1.jpg" ;
                > >
                > > $imSrc = imagecreatefrom jpeg($imgFile);
                > >
                > > $imW = imagesx($imSrc) ;
                > > $imH = imagesy($imSrc) ;
                > >
                > > $imDst = imagecreate($im W,$imH);
                > >
                > > // create 256 shades of grey
                > > for ($i=0; $i<256; $i++) {
                > > $colorNdx[$i] = imagecoloralloc ate($imDst,$i,$ i,$i);
                > > }
                > >
                > > for ($y=0; $y<$imH; $y++)
                > > {
                > > for ($x=0; $x<$imW; $x++)
                > > {
                > > $ndx = imagecolorat($i mSrc,$x,$y);
                > > $ndxColors = imagecolorsfori ndex($imSrc,$nd x);
                > > $avg = floor( ($ndxColors['red'] + $ndxColors['green'] +
                > > $ndxColors['blue']) / 3 );
                > > imagesetpixel($ imDst,$x,$y,$co lorNdx[$avg]);
                > > }
                > > }
                > >
                > > imagejpeg($imDs t);
                > > exit();
                > >
                > > ?>[/color][/color]


                Comment

                • Phil Powell

                  #9
                  Re: Grayscaling Image with GD causes image to turn jet black!

                  Sorry I can't add that header() line, the moment I do, "index.php"
                  turns literally into an indiscernible JPEG image (that's assuming I'm
                  working with a JPEG, in my Image Catalog it could literally be
                  anything, even a video!)

                  Phil

                  "CountScubu la" <me@scantek.hot mail.com> wrote in message news:<VPwUb.983 0$G95.7608@news svr29.news.prod igy.com>...[color=blue]
                  > Like like I forgot to inflate the tire after I reinvented the wheel, forgot
                  > to put:
                  > header("Content-type: image/jpeg");
                  >
                  > --
                  > Mike Bradley
                  > http://www.gzentools.com -- free online php tools
                  > "Phil Powell" <soazine@erols. com> wrote in message
                  > news:1cdca2a7.0 402051025.2dc18 05b@posting.goo gle.com...[color=green]
                  > > IT WORKED AT LAST!!! Thanx a lot. By the way, your URL produced
                  > > ASCII-related garbage on my screen, just so you know.
                  > >
                  > > Thanx again!!
                  > > Phil
                  > >
                  > > "CountScubu la" <me@scantek.hot mail.com> wrote in message[/color]
                  > news:<vikUb.203 69$ja5.12921@ne wssvr27.news.pr odigy.com>...[color=green][color=darkred]
                  > > > "Phil Powell" <soazine@erols. com> wrote in message
                  > > > news:1cdca2a7.0 402042019.1ed5f cce@posting.goo gle.com...
                  > > > >
                  > > > > I'll show you, just go down and view...
                  > > > >
                  > > > > Phil
                  > > > >
                  > > > > < Big-O-snip >
                  > > >
                  > > > Sometimes easier to re-invent the wheel (thats my my cars don't have[/color][/color]
                  > model-t[color=green][color=darkred]
                  > > > wheels on them)
                  > > > here is some code that works, and you can test here:
                  > > > http://www.gzentools.com/test/img2gry.php
                  > > >
                  > > >
                  > > >
                  > > > <?php
                  > > >
                  > > > $imgFile = "girl1.jpg" ;
                  > > >
                  > > > $imSrc = imagecreatefrom jpeg($imgFile);
                  > > >
                  > > > $imW = imagesx($imSrc) ;
                  > > > $imH = imagesy($imSrc) ;
                  > > >
                  > > > $imDst = imagecreate($im W,$imH);
                  > > >
                  > > > // create 256 shades of grey
                  > > > for ($i=0; $i<256; $i++) {
                  > > > $colorNdx[$i] = imagecoloralloc ate($imDst,$i,$ i,$i);
                  > > > }
                  > > >
                  > > > for ($y=0; $y<$imH; $y++)
                  > > > {
                  > > > for ($x=0; $x<$imW; $x++)
                  > > > {
                  > > > $ndx = imagecolorat($i mSrc,$x,$y);
                  > > > $ndxColors = imagecolorsfori ndex($imSrc,$nd x);
                  > > > $avg = floor( ($ndxColors['red'] + $ndxColors['green'] +
                  > > > $ndxColors['blue']) / 3 );
                  > > > imagesetpixel($ imDst,$x,$y,$co lorNdx[$avg]);
                  > > > }
                  > > > }
                  > > >
                  > > > imagejpeg($imDs t);
                  > > > exit();
                  > > >
                  > > > ?>[/color][/color][/color]

                  Comment

                  Working...