我生的小缩略图,为什么那么差....... 初步判定这与gd的版本有关。我在win32环境下分别使用gd2.0和gd1.6.2,执行同样的缩略图程序。结果是:gd2.0 损失约50%颜色信息gd1.6.2 基本无损失 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 gd2.0不行地,其实没必要用PHP作小图,还是在客户端用PHOTOSHOP做的好 gd、gd2都适用的写法。<?php$image = "vintdev.JPG"; // 原图$thumbw = 200; // 期望的目标图宽$thumbh = 50; // 期望的目标图高$size = getimagesize($image); // 获取原图大小$scale = min($thumbw/$size[0], $thumbh/$size[1]); // 计算缩放比例$width = (int)($size[0]*$scale);$height = (int)($size[1]*$scale);$deltaw = (int)(($thumbw - $width)/2);$deltah = (int)(($thumbh - $height)/2);$src_img = ImageCreateFromJPEG($image); // 载入原图if(function_exists("imagecreatetruecolor")) $dst_img = imagecreatetruecolor($thumbw, $thumbh); // 创建目标图else $dst_img = imagecreate($thumbw, $thumbh); // 创建目标图$back = ImageColorAllocate($dst_img, 255,255,255); // 填充的背景色imagefill($dst_img,0,0,$back);if(function_exists("ImageCopyResampled")) ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img),ImageSY($src_img)); // 复制图片else ImageCopyResized($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img),ImageSY($src_img)); // 复制图片imagejpeg($dst_img,"aaa_2.jpg"); // 创建图片imagepng($dst_img,"aaa_2.png"); // 创建图片imagepng($src_img,"ipcover_org.png");ImageDestroy($src_img);ImageDestroy($dst_img);?>对比<br>原图<img src=vintdev.JPG><br>缩略图<img src=aaa_2.png><img src=aaa_2.jpg> 哈哈,原来是imagecreatetruecolor函数在作怪。谢谢 xuzuning(唠叨) 分页 php如何打印页面并判断是否打印成功(打印机),我用window.print()!但是这个函数没有返回值 php如何更新html代码 类似于js脚本 PHP页面静态代码被显示 如何让file_put_contents()函数获取不到文件的时候不终止php程序 数组问题 Php有没有按行读文件的函数?或者怎么判断回车符? 为什么文件写入不成功? 我做了一个表单,提交表单时,英文字母提交很正常,但是中文字母提交以后转换为看不懂的字母,我该怎么办? 请问function里面怎么调用外面的数组 php可以在PWS下用吗?怎么用? 第一次接触模版(PHPLIB)的几个问题。
<?php
$image = "vintdev.JPG"; // 原图
$thumbw = 200; // 期望的目标图宽
$thumbh = 50; // 期望的目标图高$size = getimagesize($image); // 获取原图大小
$scale = min($thumbw/$size[0], $thumbh/$size[1]); // 计算缩放比例
$width = (int)($size[0]*$scale);
$height = (int)($size[1]*$scale);
$deltaw = (int)(($thumbw - $width)/2);
$deltah = (int)(($thumbh - $height)/2);$src_img = ImageCreateFromJPEG($image); // 载入原图if(function_exists("imagecreatetruecolor"))
$dst_img = imagecreatetruecolor($thumbw, $thumbh); // 创建目标图
else
$dst_img = imagecreate($thumbw, $thumbh); // 创建目标图$back = ImageColorAllocate($dst_img, 255,255,255); // 填充的背景色
imagefill($dst_img,0,0,$back);if(function_exists("ImageCopyResampled"))
ImageCopyResampled($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img),ImageSY($src_img)); // 复制图片
else
ImageCopyResized($dst_img, $src_img, $deltaw, $deltah, 0, 0, $width, $height, ImageSX($src_img),ImageSY($src_img)); // 复制图片imagejpeg($dst_img,"aaa_2.jpg"); // 创建图片
imagepng($dst_img,"aaa_2.png"); // 创建图片
imagepng($src_img,"ipcover_org.png");
ImageDestroy($src_img);
ImageDestroy($dst_img);
?>
对比<br>
原图<img src=vintdev.JPG><br>
缩略图<img src=aaa_2.png><img src=aaa_2.jpg>