original_string: public function toGrayscale()
      {
          $this->getInfo();
  
          $this->edited = imagecreate($this->width['orig'], $this->height['orig']);
  
          //Creates the 256 color palette
          for ($c=0;$c<256;$c++)
  
      {
              $palette[$c] = imagecolorallocate($this->edited,$c,$c,$c);
          }
  
          //Reads the origonal colors pixel by pixel
          for ($y=0;$y<$this->height['orig'];$y++)
  
      {
              for ($x=0;$x<$this->width['orig'];$x++)
  
      {
                  $rgb = imagecolorat($this->original,$x,$y);
                  $r = ($rgb >> 16) & 0xFF;
                  $g = ($rgb >> 8) & 0xFF;
                  $b = $rgb & 0xFF;
  
                  //This is where we actually use yiq to modify our rbg values, and then convert them to our grayscale palette
                  $gs = $this->colorToGray($r,$g,$b);
                  imagesetpixel($this->edited,$x,$y,$palette[$gs]);
              }
          }
  
      }
code: public function toGrayscale()
      {
          $this->getInfo();
  
          $this->edited = imagecreate($this->width['orig'], $this->height['orig']);
  
          //Creates the 256 color palette
          for ($c=0;$c<256;$c++)
  
      {
              $palette[$c] = imagecolorallocate($this->edited,$c,$c,$c);
          }
  
          //Reads the origonal colors pixel by pixel
          for ($y=0;$y<$this->height['orig'];$y++)
  
      {
              for ($x=0;$x<$this->width['orig'];$x++)
  
      {
                  $rgb = imagecolorat($this->original,$x,$y);
                  $r = ($rgb >> 16) & 0xFF;
                  $g = ($rgb >> 8) & 0xFF;
                  $b = $rgb & 0xFF;
  
                  //This is where we actually use yiq to modify our rbg values, and then convert them to our grayscale palette
                  $gs = $this->colorToGray($r,$g,$b);
                  imagesetpixel($this->edited,$x,$y,$palette[$gs]);
              }
          }
  
      }
code_tokens: public function toGrayscale ( ) { $ this -> getInfo ( ) ; $ this -> edited = imagecreate ( $ this -> width [ 'orig' ] , $ this -> height [ 'orig' ] ) ; //Creates the 256 color palette for ( $ c = 0 ; $ c < 256 ; $ c ++ ) { $ palette [ $ c ] = imagecolorallocate ( $ this -> edited , $ c , $ c , $ c ) ; } //Reads the origonal colors pixel by pixel for ( $ y = 0 ; $ y < $ this -> height [ 'orig' ] ; $ y ++ ) { for ( $ x = 0 ; $ x < $ this -> width [ 'orig' ] ; $ x ++ ) { $ rgb = imagecolorat ( $ this -> original , $ x , $ y ) ; $ r = ( $ rgb >> 16 ) & 0xFF ; $ g = ( $ rgb >> 8 ) & 0xFF ; $ b = $ rgb & 0xFF ; //This is where we actually use yiq to modify our rbg values, and then convert them to our grayscale palette $ gs = $ this -> colorToGray ( $ r , $ g , $ b ) ; imagesetpixel ( $ this -> edited , $ x , $ y , $ palette [ $ gs ] ) ; } } }
docstring: Converts the image being edited to grayscale
docstring_tokens: Converts the image being edited to grayscale