gd动态曲线 php_PHP: GD 和图像处理 函数 - Manual

This is an example of get high resolution images.

* Class name      : resizeImage

* Created by   : wang

* Description   : This class is to resize the image from original size to new size

*/classresizeImage{/**

* Function name : resize_img

* Description   : This function is to resize image

* @param          : $origimg variable is the original image

* @param          : $newimg variable is the new image

* @param          : $w variable is the width of image

* @param          : $f variable is the height of image

*/public  functionresize_img($origimg,$newimg,$w,$h){$info=getimagesize($origimg);$mime=$info['mime'];// Make sure that the requested file is actually an imageif(substr($mime,0,6) !='image/')

{header('HTTP/1.1 400 Bad Request');

return'Error: requested file is not an accepted type: '.$origimg;

exit();

}// Check they extention of image$extension=image_type_to_extension($info[2]);

if(strtolower($extension) =='.png'){$img=$this->resize_imagepng($origimg,$w,$h);imagepng($img,$newimg);imagedestroy($img);

}elseif(strtolower($extension) =='.jpeg'){$img=$this->resize_imagejpeg($origimg,$w,$h);imagejpeg($img,$newimg);imagedestroy($img);

}elseif(strtolower($extension=='.gif')){$img=$this->resize_imagegif($origimg,$w,$h);imagegif($img,$newimg);imagedestroy($img);

}

}/**

* End function name : resize_img

*/

/**

* Function name : resize_imagepng

* Description   : This function is to resize png image

* @param          : $file variable is the original image

* @param          : $w variable is the width of image

* @param          : $f variable is the height of image

*/private functionresize_imagepng($file,$w,$h) {

list($width,$height) =getimagesize($file);$src=imagecreatefrompng($file);$dst=imagecreatetruecolor($w,$h);imagecopyresampled($dst,$src,0,0,0,0,$w,$h,$width,$height);

return$dst;

}/**

* End function name : resize_imagepng

*/

/**

* Function name : resize_imagejpeg

* Description   : This function is to resize jpeg image

* @param          : $file variable is the original image

* @param          : $w variable is the width of image

* @param          : $f variable is the height of image

*/private functionresize_imagejpeg($file,$w,$h) {

list($width,$height) =getimagesize($file);$src=imagecreatefromjpeg($file);$dst=imagecreatetruecolor($w,$h);imagecopyresampled($dst,$src,0,0,0,0,$w,$h,$width,$height);

return$dst;

}/**

* End function name : resize_imagejpeg

*/

/**

* Function name : resize_imagegif

* Description   : This function is to resize gif image

* @param          : $file variable is the original image

* @param          : $w variable is the width of image

* @param          : $f variable is the height of image

*/private functionresize_imagegif($file,$w,$h) {

list($width,$height) =getimagesize($file);$src=imagecreatefromgif($file);$dst=imagecreatetruecolor($w,$h);imagecopyresampled($dst,$src,0,0,0,0,$w,$h,$width,$height);

return$dst;

}/**

* End function name : resize_imagegif

*/}/**

* End class name : resizeImage

*/?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值