您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php使用GD创建保持宽高比缩略图的方法

2026/2/1 14:58:05发布14次查看
这篇文章主要介绍了php使用gd创建保持宽高比缩略图的方法,涉及php使用gd库操作图片的技巧,需要的朋友可以参考下
本文实例讲述了php使用gd创建保持宽高比缩略图的方法。分享给大家供大家参考。具体如下:
/*** create a thumbnail image from $inputfilename no taller or wider than* $maxsize. returns the new image resource or false on error.* author: mthorn.net*/function thumbnail($inputfilename, $maxsize = 100){ $info = getimagesize($inputfilename); $type = isset($info['type']) ? $info['type'] : $info[2]; // check support of file type if ( !(imagetypes() & $type) ) {// server does not support file typereturn false; } $width = isset($info['width']) ? $info['width'] : $info[0]; $height = isset($info['height']) ? $info['height'] : $info[1]; // calculate aspect ratio $wratio = $maxsize / $width; $hratio = $maxsize / $height; // using imagecreatefromstring will automatically detect the file type $sourceimage = imagecreatefromstring(file_get_contents($inputfilename)); // calculate a proportional width and height no larger than the max size. if ( ($width
希望本文所述对大家的php程序设计有所帮助。

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product