php 压缩图片

2015-12-15 0 843
php 压缩图片
/*打开图片*/ 
$src = "aa.jpg";  
$info = getimagesize($src);  
$type = image_type_to_extension($info[2],false);  
$fun = "imagecreatefrom".$type;  
$image = $fun($src);  
   
/*操作图片*/ 
//1.内存中建立一个300,200真色彩图片  
$image_thumb = imagecreatetruecolor(200,300);  
//2.核心步骤,将原图复制到真色彩图片上  
imagecopyresampled($image_thumb, $image, 0, 0, 0, 0, 200, 300, $info[0], $info[1]);  
//3.销毁原始图片  
imagedestroy($image);  
   
/*输出图片*/ 
//浏览器  
header("Content-type:".$info['mime']);  
$fun = "image".$type;  
$fun($image_thumb);  
//保存图片  
$fun($image_thumb,'aa_a.'.$type);  
/*销毁图片*/ 
imagedestroy($image_thumb);

遇见资源网 php php 压缩图片 http://www.ox520.com/8070.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务