记住用户名密码
function CreateThumbs($image_path,$thumb_width,$thumb_height,$thumb_pro,$thumb_path,$ml=1,$thumb_quality=100){ if ($thumb_path!=''){ /* $thumb_array=explode('/',$thumb_path); if (count($thumb_array)>=2){ $thumb_parent=''; if ($ml==1) $thumb_parent='../'; $thumb_dir=$thumb_parent.$thumb_array[0].'/'.$thumb_array[1].'/'; if (is_date($thumb_array[1]) && !is_dir($thumb_dir)) mkdir($thumb_dir); } */ if ($ml==1){ $image_path='../'.$image_path; $thumb_path='../'.$thumb_path; } $image_size=getimagesize($image_path); switch($thumb_pro){ case 1: $image_width=$image_size[0]; $image_height=$image_size[1]; if ($image_size[0]>$thumb_width && $image_size[1]>$thumb_height){ $image_width=$image_size[0]/$image_size[1]*$thumb_height; $image_height=$thumb_height; if ($image_width>$thumb_width){ $image_width=$thumb_width; $image_height=$image_size[1]/$image_size[0]*$thumb_width; } } elseif($image_size[0]>$thumb_width && $image_size[1]<=$thumb_height){ $image_width=$thumb_width; $image_height=$image_size[1]/$image_size[0]*$thumb_width; } elseif($image_size[1]>$thumb_height && $image_size[0]<=$thumb_width){ $image_width=$image_size[0]/$image_size[1]*$thumb_height; $image_height=$thumb_height; } break; case 2: $image_width=$thumb_width; $image_height=$image_size[1]/$image_size[0]*$thumb_width; if ($image_size[0]<$thumb_width){ $image_width=$image_size[0]; $image_height=$image_size[1]; } break; case 3: $image_width=$image_size[0]/$image_size[1]*$thumb_height; $image_height=$thumb_height; if ($image_size[1]<$thumb_height){ $image_width=$image_size[0]; $image_height=$image_size[1]; } break; default: $image_width=$thumb_width; $image_height=$thumb_height; break; } switch($image_size[2]){ case 1: //gif $image_path=imagecreatefromgif($image_path); break; case 2: //jpg $image_path=imagecreatefromjpeg($image_path); break; case 3: //png $image_path=imagecreatefrompng($image_path); imagesavealpha($image_path,true); break; case 6: //bmp break; } $image=imagecreatetruecolor($image_width,$image_height); if ($image_size[2]==3){ imagealphablending($image,false); imagesavealpha($image,true); } else{ $color=imagecolorallocate($image,255,255,255); imagefill($image,0,0,$color); } imagecopyresampled($image,$image_path,0,0,0,0,$image_width,$image_height,$image_size[0],$image_size[1]); switch($image_size[2]){ case 1: //gif imagegif($image,$thumb_path,$thumb_quality); break; case 2: //jpg imagejpeg($image,$thumb_path,$thumb_quality); break; case 3: //png imagepng($image,$thumb_path); break; case 6: //bmp break; } imagedestroy($image); } }
目前有 0 条留言 其中:访客:0 条, 博主:0 条