php图片等比例压缩
2015-04-23 17:30
302 查看
<?php /** * desription 压缩图片 * @param sting $imgsrc 图片路径 * @param string $imgdst 压缩后保存路径 */ function image_png_size_add($imgsrc,$imgdst,$dst_w,$dst_h){ list($width,$height,$type)=getimagesize($imgsrc); $new_width = $dst_w; $new_height =$dst_h; switch($type){ case 1: $giftype=check_gifcartoon($imgsrc); if($giftype){ header('Content-Type:image/gif'); $image_wp=imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromgif($imgsrc); imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_wp, $imgdst,100); imagedestroy($image_wp); } case 2: header('Content-Type:image/jpeg'); $image_wp=imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($imgsrc); imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_wp, $imgdst,100); imagedestroy($image_wp); break; case 3: header('Content-Type:image/png'); $image_wp=imagecreatetruecolor($new_width, $new_height); $image = imagecreatefrompng($imgsrc); imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_wp, $imgdst,100); imagedestroy($image_wp); break; } } image_png_size_add('active1.jpg','active2.jpg',110,110);
相关文章推荐
- PHP按一定比例压缩图片的方法
- php gd等比例缩放压缩图片函数
- PHP等比例压缩图片的实例代码
- php等比例压缩图片(jpg,jif,png图片等比例压缩)
- PHP图片处理函数 类 (水印图,缩略图)[关于等比例压缩与裁剪压缩]
- php等比例压缩图片
- 黄聪:php实现上传图片和等比例缩略图压缩图片
- php gd等比例缩放压缩图片函数
- PHP 按一定比例压缩图片,保持清晰度
- PHP等比例缩放图片大小压缩图片空间
- PHP 图片操作(按照指定尺寸压缩,按照比例裁剪)
- php等比例压缩图片【原创】
- php实现上传图片和等比例缩略图压缩图片
- php等比例压缩图片
- PHP 按一定比例压缩图片,保持清晰度
- php实现等比例压缩图片
- 求助:PHP图片压缩的问题
- 等比例压缩图片到指定的KB大小
- PHP实现图片上传并压缩
- 图片按指定比例缩放并压缩至指定大小,解决保存图片文件体积过大bug。