$h) && ($W > $w)) { if ($rB > $rS) { $height = $h; $width = $height/$rB; } else { $width = $w; $height = $width*$rB; } } elseif ($H > $h) { $height = $h; $width = $height/$rB; } elseif ($W > $w) { $width = $w; $height = $width*$rB; } else { $height = $H; $width = $W; } $zx = $W/$width; $zy = $H/$height; $create_function = images::checkTrueColor() ? 'imagecreatetruecolor' : 'imagecreate'; if (($img2 = $create_function(round($width),round($height))) === false) { return false; } //images::CopyResampleBicubic($img2,$img,0,0,0,0,$width,$height,$zx,$zy); imagecopyresized($img2,$img,0,0,0,0,round($width),round($height),$W,$H); if (!is_dir(dirname($file))) { $dmod = fileperms(dirname(dirname($file))); if (@mkdir(dirname($file),$dmod) === false) { return false; } chmod(dirname($file),$dmod); } if ($dest_type == 'png') { $endfunction = 'imagepng'; } elseif ($dest_type == 'jpeg') { $endfunction = 'imagejpeg'; } if (@$endfunction($img2,$file,80) === false) { return false; } chmod($file,fileperms(dirname($file)) & ~0111); imagedestroy($img2); return true; } function CopyResampleBicubic(&$dst, &$src, $dstx, $dsty, $srcx, $srcy, $w, $h, $zoomX, $zoomY = '') { if (!$zoomY) { $zoomY = $zoomX; } $palsize = ImageColorsTotal($src); for ($i = 0; $i<$palsize; $i++) { $colors = ImageColorsForIndex($src, $i); ImageColorAllocate($dst, $colors['red'], $colors['green'], $colors['blue']); } $zoomX2 = (int)($zoomX/2); $zoomY2 = (int)($zoomY/2); $dstX = imagesx($dst); $dstY = imagesy($dst); $srcX = imagesx($src); $srcY = imagesy($src); for ($j = 0; $j<($h-$dsty); $j++) { $sY = (int)($j*$zoomY)+$srcy; $y13 = $sY+$zoomY2; $dY = $j+$dsty; if (($sY >= $srcY) or ($dY >= $dstY) or ($y13 >= $srcY)) { break 1; } for ($i = 0; $i<($w-$dstx); $i++) { $sX = (int)($i*$zoomX)+$srcx; $x34 = $sX+$zoomX2; $dX = $i+$dstx; if (($sX >= $srcX) or ($dX >= $dstX) or ($x34 >= $srcX)) { break 1; } $c1 = ImageColorsForIndex($src, ImageColorAt($src, $sX, $y13)); $c2 = ImageColorsForIndex($src, ImageColorAt($src, $sX, $sY)); $c3 = ImageColorsForIndex($src, ImageColorAt($src, $x34, $y13)); $c4 = ImageColorsForIndex($src, ImageColorAt($src, $x34, $sY)); $r = ($c1['red']+$c2['red']+$c3['red']+$c4['red'])/4; $g = ($c1['green']+$c2['green']+$c3['green']+$c4['green'])/4; $b = ($c1['blue']+$c2['blue']+$c3['blue']+$c4['blue'])/4; ImageSetPixel($dst, $dX, $dY, ImageColorClosest($dst, $r, $g, $b)); } } } function type($p) { if (($size = @getimagesize($p)) === false) { return false; } $type = $size[2]; if ($type == '1') { return 'gif'; } elseif ($type == '2') { return 'jpeg'; } elseif ($type == '3') { return 'png'; } else { return false; } } function checkTrueColor() { if (function_exists('gd_info')) { $gdinfo = gd_info(); $gdversion = $gdinfo['GD Version']; if (strpos($gdversion,'2.') !== false) { return true; } } return false; } } ?>