后端开发|php教程
php,略图,图片
后端开发-php教程
<?php/** * 生成缩略图函数(支持图片格式:gif、jpeg、png和bmp) * @author ruxing.li * @param string $src 源图片路径 * @param int $width 缩略图宽度(只指定高度时进行等比缩放) * @param int $width 缩略图高度(只指定宽度时进行等比缩放) * @param string $filename 保存路径(不指定时直接输出到浏览器) * @return bool */function mkThumbnail($src, $width = null, $height = null, $filename = null) { if (!isset($width) && !isset($height)) return false; if (isset($width) && $width <= 0) return false; if (isset($height) && $height <= 0) return false; $size = getimagesize($src); if (!$size) return false; list($src_w, $src_h, $src_type) = $size; $src_mime = $size[mime]; switch($src_type) { case 1 :$img_type = gif;break; case 2 :$img_type = jpeg;break; case 3 :$img_type = png;break; case 15 :$img_type = wbmp;break; default :return false; } if (!isset($width)) $width = $src_w * ($height / $src_h); if (!isset($height)) $height = $src_h * ($width / $src_w); $imagecreatefunc = imagecreatefrom . $img_type; $src_img = $imagecreatefunc($src); $dest_img = imagecreatetruecolor($width, $height); imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $width, $height, $src_w, $src_h); $imagefunc = image . $img_type; if ($filename) { $imagefunc($dest_img, $filename); } else { header(Content-Type: . $src_mime); $imagefunc($dest_img); } imagedestroy($src_img); imagedestroy($dest_img); return true;}$result = mkThumbnail(./IMG_3324.JPG, 147, 147);
注:记得先打开 GD 库的支持
java即时聊天系统源码,ubuntu桌面加路由,tomcat启动失败在45,京东爬虫抢购,php图片大小,武汉seo乚选标兵seolzw
相关推荐:
PHP实现生成图片缩略图函数
蓝牙串口调试助手源码,vscode 引用路径,ubuntu服务器异常关机,tomcat 书籍 豆瓣,sqlite 火车头,文本域可编辑插件,淘宝前端团队 ui框架,爬虫什么都能找到,网址导航 php,seo优化详细介绍seo顾问,php网站首页源码,404网页模板下载,阿里妈妈模板,程序设计 学生信息管理系统,视频投票小程序源码lzw
php生成图片缩略图功能
注册登陆模板源码下载,荣耀盒子 刷ubuntu,tomcat关闭服务器前,c 爬虫 ajax,php程序设计电子教材,青浦seo费用lzw
php如何生成持透明png的图片缩略图