php gd等比例缩放压缩图片函数_

上传人:一** 文档编号:24917610 上传时间:2021-07-16 格式:DOCX 页数:10 大小:14.94KB
收藏 版权申诉 举报 下载
php gd等比例缩放压缩图片函数__第1页
第1页 / 共10页
php gd等比例缩放压缩图片函数__第2页
第2页 / 共10页
php gd等比例缩放压缩图片函数__第3页
第3页 / 共10页
资源描述:

《php gd等比例缩放压缩图片函数_》由会员分享,可在线阅读,更多相关《php gd等比例缩放压缩图片函数_(10页珍藏版)》请在装配图网上搜索。

1、php gd等比例缩放压缩图片函数_ 本文实例为大家分享了php gd等比例缩放压缩图片函数,供大家参考,具体内容如下 ?php /* * desription 推断是否gif动画 * param sting $image_file图片路径 * return boolean t 是 f 否 */ function check_gifcartoon($image_file) $fp = fopen($image_file,rb); $image_head = fread($fp,1024); fclose($fp); return preg_match(/.chr(0x21).chr(0xff)

2、.chr(0x0b).NETSCAPE2.0./,$image_head)?false:true; /* * desription 压缩图片 * param sting $imgsrc 图片路径 * param string $imgdst 压缩后保存路径 */ function compressed_image($imgsrc,$imgdst) list($width,$height,$type)=getimagesize($imgsrc); $new_width = ($width600?600:$width)*0.9; $new_height =($height600?600:$heig

3、ht)*0.9; 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);

4、/75代表的是质量、压缩图片容量大小 imagejpeg($image_wp, $imgdst,75); imagedestroy($image_wp); break; 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, $wi

5、dth, $height); /75代表的是质量、压缩图片容量大小 imagejpeg($image_wp, $imgdst,75); 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, $ne

6、w_height, $width, $height); /75代表的是质量、压缩图片容量大小 imagejpeg($image_wp, $imgdst,75); imagedestroy($image_wp); break; php and gd 函数参考表 gd_info 取得当前安装的 GD 库的信息 getimagesize 取得图像大小 getimagesizefromstring Get the size of an image from a string image_type_to_extension 取得图像类型的文件后缀 image_type_to_mime_type 取得 g

7、etimagesize,exif_read_data,exif_thumbnail,exif_imagetype 所返回的图像类型的 MIME 类型 image2wbmp 以 WBMP 格式将图像输出到扫瞄器或文件 imageaffine Return an image containing the affine tramsformed src image, using an optional clipping area imageaffinematrixconcat Concat two matrices (as in doing many ops in one go) imageaffin

8、ematrixget Return an image containing the affine tramsformed src image, using an optional clipping area imagealphablending 设定图像的混色模式 imageantialias 是否用法抗锯齿(antialias)功能 imagearc 画椭圆弧 imagechar 水平地画一个字符 imagecharup 垂直地画一个字符 imagecolorallocate 为一幅图像安排颜色 imagecolorallocatealpha 为一幅图像安排颜色 + alpha imagec

9、olorat 取得某像素的颜色索引值 imagecolorclosest 取得与指定的颜色最接近的颜色的索引值 imagecolorclosestalpha 取得与指定的颜色加透亮度最接近的颜色 imagecolorclosesthwb 取得与给定颜色最接近的色度的黑白色的索引 imagecolordeallocate 取消图像颜色的安排 imagecolorexact 取得指定颜色的索引值 imagecolorexactalpha 取得指定的颜色加透亮度的索引值 imagecolormatch 使一个图像中调色板版本的颜色与真彩色版本更能匹配 imagecolorresolve 取得指定颜色

10、的索引值或有可能得到的最接近的替代值 imagecolorresolvealpha 取得指定颜色 + alpha 的索引值或有可能得到的最接近的替代值 imagecolorset 给指定调色板索引设定颜色 imagecolorsforindex 取得某索引的颜色 imagecolorstotal 取得一幅图像的调色板中颜色的数目 imagecolortransparent 将某个颜色定义为透亮色 imageconvolution 用系数 div 和 offset 申请一个 3x3 的卷积矩阵 imagecopy 拷贝图像的一部分 imagecopymerge 拷贝并合并图像的一部分 image

11、copymergegray 用灰度拷贝并合并图像的一部分 imagecopyresampled 重采样拷贝部分图像并调整大小 imagecopyresized 拷贝部分图像并调整大小 imagecreate 新建一个基于调色板的图像 imagecreatefromgd2 从 GD2 文件或 URL 新建一图像 imagecreatefromgd2part 从给定的 GD2 文件或 URL 中的部分新建一图像 imagecreatefromgd 从 GD 文件或 URL 新建一图像 imagecreatefromgif 由文件或 URL 创建一个新图象。 imagecreatefromjpeg

12、由文件或 URL 创建一个新图象。 imagecreatefrompng 由文件或 URL 创建一个新图象。 imagecreatefromstring 从字符串中的图像流新建一图像 imagecreatefromwbmp 由文件或 URL 创建一个新图象。 imagecreatefromwebp 由文件或 URL 创建一个新图象。 imagecreatefromxbm 由文件或 URL 创建一个新图象。 imagecreatefromxpm 由文件或 URL 创建一个新图象。 imagecreatetruecolor 新建一个真彩色图像 imagecrop Crop an image usi

13、ng the given coordinates and size, x, y, width and height imagecropauto Crop an image automatically using one of the available modes imagedashedline 画一虚线 imagedestroy 销毁一图像 imageellipse 画一个椭圆 imagefill 区域填充 imagefilledarc 画一椭圆弧且填充 imagefilledellipse 画一椭圆并填充 imagefilledpolygon 画一多边形并填充 imagefilledrec

14、tangle 画一矩形并填充 imagefilltoborder 区域填充到指定颜色的边界为止 imagefilter 对图像用法过滤器 imageflip Flips an image using a given mode imagefontheight 取得字体高度 imagefontwidth 取得字体宽度 imageftbbox 给出一个用法 FreeType 2 字体的文本框 imagefttext 用法 FreeType 2 字体将文本写入图像 imagegammacorrect 对 GD 图像应用 gamma 修正 imagegd2 将 GD2 图像输出到扫瞄器或文件 image

15、gd 将 GD 图像输出到扫瞄器或文件 imagegif 输出图象到扫瞄器或文件。 imagegrabscreen Captures the whole screen imagegrabwindow Captures a window imageinterlace 激活或禁止隔行扫描 imageistruecolor 检查图像是否为真彩色图像 imagejpeg 输出图象到扫瞄器或文件。 imagelayereffect 设定 alpha 混色标记以用法绑定的 libgd 分层效果 imageline 画一条线段 imageloadfont 载入一新字体 imagepalettecopy 将调

16、色板从一幅图像拷贝到另一幅 imagepalettetotruecolor Converts a palette based image to true color imagepng 以 PNG 格式将图像输出到扫瞄器或文件 imagepolygon 画一个多边形 imagepsbbox 给出一个用法 PostScript Type1 字体的文本方框 imagepsencodefont 转变字体中的字符编码矢量 imagepsextendfont 扩充或精简字体 imagepsfreefont 释放一个 PostScript Type 1 字体所占用的内存 imagepsloadfont 从文

17、件中加载一个 PostScript Type 1 字体 imagepsslantfont 倾斜某字体 imagepstext 用 PostScript Type1 字体把文本字符串画在图像上 imagerectangle 画一个矩形 imagerotate 用给定角度旋转图像 imagesavealpha 设置标记以在保存 PNG 图像时保存完整的 alpha 通道信息(与单一透亮色相反) imagescale Scale an image using the given new width and height imagesetbrush 设定画线用的画笔图像 imagesetinterpo

18、lation Set the interpolation method imagesetpixel 画一个单一像素 imagesetstyle 设定画线的风格 imagesetthickness 设定画线的宽度 imagesettile 设定用于填充的贴图 imagestring 水平地画一行字符串 imagestringup 垂直地画一行字符串 imagesx 取得图像宽度 imagesy 取得图像高度 imagetruecolortopalette 将真彩色图像转换为调色板图像 imagettfbbox 取得用法 TrueType 字体的文本的范围 imagettftext 用 TrueT

19、ype 字体向图像写入文本 imagetypes 返回当前 PHP 版本所支持的图像类型 imagewbmp 以 WBMP 格式将图像输出到扫瞄器或文件 imagewebp Output an WebP image to browser or file imagexbm 将 XBM 图像输出到扫瞄器或文件 iptcembed 将二进制 IPTC 数据嵌入到一幅 JPEG 图像中 iptcparse 将二进制 IPTC 块解析为单个标记 jpeg2wbmp 将 JPEG 图像文件转换为 WBMP 图像文件 png2wbmp 将 PNG 图像文件转换为 WBMP 图像文件 以上就是本文的全部内容,盼望对大家学习PHP程序设计有所关心。 .

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!