手机
当前位置:查字典教程网 >编程开发 >php教程 >PHP实现原比例生成缩略图的方法
PHP实现原比例生成缩略图的方法
摘要:本文实例讲述了PHP实现原比例生成缩略图的方法。分享给大家供大家参考,具体如下:$y){//图片宽大于高$sx=abs(($y-$x)/2)...

本文实例讲述了PHP实现原比例生成缩略图的方法。分享给大家供大家参考,具体如下:

<"jiequ.jpg"; // 原图 $imgstream = file_get_contents($image); $im = imagecreatefromstring($imgstream); $x = imagesx($im);//获取图片的宽 $y = imagesy($im);//获取图片的高 // 缩略后的大小 $xx = 140; $yy = 200; if($x>$y){ //图片宽大于高 $sx = abs(($y-$x)/2); $sy = 0; $thumbw = $y; $thumbh = $y; } else { //图片高大于等于宽 $sy = abs(($x-$y)/2.5); $sx = 0; $thumbw = $x; $thumbh = $x; } if(function_exists("imagecreatetruecolor")) { $dim = imagecreatetruecolor($yy, $xx); // 创建目标图gd2 } else { $dim = imagecreate($yy, $xx); // 创建目标图gd1 } imageCopyreSampled ($dim,$im,0,0,$sx,$sy,$yy,$xx,$thumbw,$thumbh); header ("Content-type: image/jpeg"); imagejpeg ($dim, false, 100); ?>

希望本文所述对大家PHP程序设计有所帮助。

【PHP实现原比例生成缩略图的方法】相关文章:

用PHP生成自己的LOG文件

php循环table实现一行两列显示的方法

PHP date函数常用时间处理方法

PHP调用三种数据库的方法(3)

生成缩略图

用PHP代码在网页上生成图片

PHP生成唯一订单号的方法汇总

php实现修改新闻时删除图片的方法

实现树状结构的两种方法

PHP使用flock实现文件加锁的方法

精品推荐
分类导航