original_string: function _imageCopyResampledWorkaround(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
      {
          /*
          for ($i = 0; $i < imagecolorstotal($src_img); $i++)
          {
              $colors = ImageColorsForIndex ($src_img, $i);
              ImageColorAllocate ($dst_img, $colors['red'],$colors['green'], $colors['blue']);
          }
          */
          $scaleX = ($src_w - 1) / $dst_w;
          $scaleY = ($src_h - 1) / $dst_h;
  
          $scaleX2 = $scaleX / 2.0;
          $scaleY2 = $scaleY / 2.0;
  
          for ($j = $src_y; $j < $src_y + $dst_h; $j++)
          {
              $sY = $j * $scaleY;
              for ($i = $src_x; $i < $src_x + $dst_w; $i++)
              {
                  $sX = $i * $scaleX;
  
                  $c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX, (int)$sY + $scaleY2));
                  $c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX, (int)$sY));
                  $c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX + $scaleX2, (int)$sY + $scaleY2));
                  $c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX + $scaleX2, (int)$sY));
  
                  $red = (integer)(($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4);
                  $green = (integer)(($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4);
                  $blue = (integer)(($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4);
  
                  $color = ImageColorClosest($dst_img, $red, $green, $blue);
                  ImageSetPixel($dst_img, $dst_x + $i - $src_x, $dst_y + $j - $src_y, $color);
              }
          }
      }
code: function _imageCopyResampledWorkaround(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
      {
          /*
          for ($i = 0; $i < imagecolorstotal($src_img); $i++)
          {
              $colors = ImageColorsForIndex ($src_img, $i);
              ImageColorAllocate ($dst_img, $colors['red'],$colors['green'], $colors['blue']);
          }
          */
          $scaleX = ($src_w - 1) / $dst_w;
          $scaleY = ($src_h - 1) / $dst_h;
  
          $scaleX2 = $scaleX / 2.0;
          $scaleY2 = $scaleY / 2.0;
  
          for ($j = $src_y; $j < $src_y + $dst_h; $j++)
          {
              $sY = $j * $scaleY;
              for ($i = $src_x; $i < $src_x + $dst_w; $i++)
              {
                  $sX = $i * $scaleX;
  
                  $c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX, (int)$sY + $scaleY2));
                  $c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX, (int)$sY));
                  $c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX + $scaleX2, (int)$sY + $scaleY2));
                  $c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, (int)$sX + $scaleX2, (int)$sY));
  
                  $red = (integer)(($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) / 4);
                  $green = (integer)(($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) / 4);
                  $blue = (integer)(($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) / 4);
  
                  $color = ImageColorClosest($dst_img, $red, $green, $blue);
                  ImageSetPixel($dst_img, $dst_x + $i - $src_x, $dst_y + $j - $src_y, $color);
              }
          }
      }
code_tokens: function _imageCopyResampledWorkaround ( & $ dst_img , & $ src_img , $ dst_x , $ dst_y , $ src_x , $ src_y , $ dst_w , $ dst_h , $ src_w , $ src_h ) { /*
          for ($i = 0; $i < imagecolorstotal($src_img); $i++)
          {
              $colors = ImageColorsForIndex ($src_img, $i);
              ImageColorAllocate ($dst_img, $colors['red'],$colors['green'], $colors['blue']);
          }
          */ $ scaleX = ( $ src_w - 1 ) / $ dst_w ; $ scaleY = ( $ src_h - 1 ) / $ dst_h ; $ scaleX2 = $ scaleX / 2.0 ; $ scaleY2 = $ scaleY / 2.0 ; for ( $ j = $ src_y ; $ j < $ src_y + $ dst_h ; $ j ++ ) { $ sY = $ j * $ scaleY ; for ( $ i = $ src_x ; $ i < $ src_x + $ dst_w ; $ i ++ ) { $ sX = $ i * $ scaleX ; $ c1 = ImageColorsForIndex ( $ src_img , ImageColorAt ( $ src_img , ( int ) $ sX , ( int ) $ sY + $ scaleY2 ) ) ; $ c2 = ImageColorsForIndex ( $ src_img , ImageColorAt ( $ src_img , ( int ) $ sX , ( int ) $ sY ) ) ; $ c3 = ImageColorsForIndex ( $ src_img , ImageColorAt ( $ src_img , ( int ) $ sX + $ scaleX2 , ( int ) $ sY + $ scaleY2 ) ) ; $ c4 = ImageColorsForIndex ( $ src_img , ImageColorAt ( $ src_img , ( int ) $ sX + $ scaleX2 , ( int ) $ sY ) ) ; $ red = ( integer ) ( ( $ c1 [ 'red' ] + $ c2 [ 'red' ] + $ c3 [ 'red' ] + $ c4 [ 'red' ] ) / 4 ) ; $ green = ( integer ) ( ( $ c1 [ 'green' ] + $ c2 [ 'green' ] + $ c3 [ 'green' ] + $ c4 [ 'green' ] ) / 4 ) ; $ blue = ( integer ) ( ( $ c1 [ 'blue' ] + $ c2 [ 'blue' ] + $ c3 [ 'blue' ] + $ c4 [ 'blue' ] ) / 4 ) ; $ color = ImageColorClosest ( $ dst_img , $ red , $ green , $ blue ) ; ImageSetPixel ( $ dst_img , $ dst_x + $ i - $ src_x , $ dst_y + $ j - $ src_y , $ color ) ; } } }
docstring: workaround function for bicubic resizing. works well for downsizing only. VERY slow. taken from php.net comments
  
  @access private
docstring_tokens: workaround function for bicubic resizing . works well for downsizing only . VERY slow . taken from php . net comments