src/ext-3rd/tinymce/plugins/images/connector/php/Image_Toolbox.class.php
function _imageCopyResampledWorkaround2(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
    {
        ImagePaletteCopy($dst_img, $src_img);
        $rX = $src_w / $dst_w;
        $rY = $src_h / $dst_h;
        $w = 0;
        for ($y = $dst_y; $y < $dst_h; $y++)
        {
            $ow = $w;
            $w = round(($y + 1) * $rY);
            $t = 0;
            for ($x = $dst_x; $x < $dst_w; $x++)
            {
                $r = $g = $b = 0;
                $a = 0;
                $ot = $t;
                $t = round(($x + 1) * $rX);
                for ($u = 0; $u < ($w - $ow); $u++)
                {
                    for ($p = 0; $p < ($t - $ot); $p++)
                    {
                        $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $ot + $p, $ow + $u));
                        $r += $c['red'];
                        $g += $c['green'];
                        $b += $c['blue'];
                        $a++;
                    }
                }
                ImageSetPixel($dst_img, $x, $y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
            }
        }
    }
function _imageCopyResampledWorkaround2(&$dst_img, &$src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h)
    {
        ImagePaletteCopy($dst_img, $src_img);
        $rX = $src_w / $dst_w;
        $rY = $src_h / $dst_h;
        $w = 0;
        for ($y = $dst_y; $y < $dst_h; $y++)
        {
            $ow = $w;
            $w = round(($y + 1) * $rY);
            $t = 0;
            for ($x = $dst_x; $x < $dst_w; $x++)
            {
                $r = $g = $b = 0;
                $a = 0;
                $ot = $t;
                $t = round(($x + 1) * $rX);
                for ($u = 0; $u < ($w - $ow); $u++)
                {
                    for ($p = 0; $p < ($t - $ot); $p++)
                    {
                        $c = ImageColorsForIndex($src_img, ImageColorAt($src_img, $ot + $p, $ow + $u));
                        $r += $c['red'];
                        $g += $c['green'];
                        $b += $c['blue'];
                        $a++;
                    }
                }
                ImageSetPixel($dst_img, $x, $y, ImageColorClosest($dst_img, $r / $a, $g / $a, $b / $a));
            }
        }
    }
function _imageCopyResampledWorkaround2 ( & $ dst_img , & $ src_img , $ dst_x , $ dst_y , $ src_x , $ src_y , $ dst_w , $ dst_h , $ src_w , $ src_h ) { ImagePaletteCopy ( $ dst_img , $ src_img ) ; $ rX = $ src_w / $ dst_w ; $ rY = $ src_h / $ dst_h ; $ w = 0 ; for ( $ y = $ dst_y ; $ y < $ dst_h ; $ y ++ ) { $ ow = $ w ; $ w = round ( ( $ y + 1 ) * $ rY ) ; $ t = 0 ; for ( $ x = $ dst_x ; $ x < $ dst_w ; $ x ++ ) { $ r = $ g = $ b = 0 ; $ a = 0 ; $ ot = $ t ; $ t = round ( ( $ x + 1 ) * $ rX ) ; for ( $ u = 0 ; $ u < ( $ w - $ ow ) ; $ u ++ ) { for ( $ p = 0 ; $ p < ( $ t - $ ot ) ; $ p ++ ) { $ c = ImageColorsForIndex ( $ src_img , ImageColorAt ( $ src_img , $ ot + $ p , $ ow + $ u ) ) ; $ r += $ c [ 'red' ] ; $ g += $ c [ 'green' ] ; $ b += $ c [ 'blue' ] ; $ a ++ ; } } ImageSetPixel ( $ dst_img , $ x , $ y , ImageColorClosest ( $ dst_img , $ r / $ a , $ g / $ a , $ b / $ a ) ) ; } } }
alternative workaround function for bicubic resizing. works well for downsizing and upsizing. VERY VERY slow. taken from php.net comments

@access private
alternative workaround function for bicubic resizing . works well for downsizing and upsizing . VERY VERY slow . taken from php . net comments