<?php

if(!defined('IN_GATEWEI')) {
	exit('Access Denied');
	}

function thumbimage($srcimg, $thumb_width, $thumb_height)
{

	//$srcimg ,$desimg 为文件路径及文件名
	//$img ,$thumbimg为获取到的文件标示符
	   list($width, $height, $type) = getimagesize($srcimg);

	    if($type==1){
			$img =  imagecreatefromgif($srcimg);
       }
       elseif($type==2){
			$img =  imagecreatefromjpeg($srcimg);
       }
       elseif($type==3){
         $img =  imagecreatefrompng($srcimg);
       }

	   $thumbimg = imagecreatetruecolor($thumb_width,$thumb_height);
	   imagecopyresampled($thumbimg, $img, 0, 0, 0, 0, $thumb_width,$thumb_height, $width, $height);
	    if($type==1){
			$desimg=str_replace(".gif", ".thumb.gif", $srcimg);
			$img =  imagegif($thumbimg,$desimg);
       }
       elseif($type==2){
		   $desimg=str_replace(".jpg", ".thumb.jpg", $srcimg);
		   $img =  imagejpeg($thumbimg,$desimg);
       }
       elseif($type==3){
		   $desimg=str_replace(".jpg", ".thumb.png", $srcimg);
         $img =  imagepng($thumbimg,$desimg);
       }
	   
}

    
    //thumbimage('img/bbb.jpg', 200, 150);
?>