【发布时间】:2011-02-06 23:41:09
【问题描述】:
我在从上传的图片创建缩略图时遇到问题,我的问题是
(i) 质量 (ii) 作物
http://welovethedesign.com.cluster.cwcs.co.uk/phpimages/large.jpg http://welovethedesign.com.cluster.cwcs.co.uk/phpimages/thumb.jpg
如果您看起来质量很差,并且裁剪是从顶部拍摄的,并且不是原始图像的大小调整,尽管尺寸意味着它是成比例的。
原件是 1600px 宽 1100px 高。
任何帮助将不胜感激。
$thumb =
$targetPath."Thumbs/".$fileName;
$imgsize =
getimagesize($targetFile); $image =
imagecreatefromjpeg($targetFile);
$width = 200; //New width of image
$height = 138; //This maintains
proportions
$src_w = $imgsize[0]; $src_h =
$imgsize[1];
$thumbWidth = 200; $thumbHeight =
138; // Intended dimension of thumb
// Beyond this point is simply code.
$sourceImage =
imagecreatefromjpeg($targetFile);
$sourceWidth = imagesx($sourceImage);
$sourceHeight = imagesy($sourceImage);
$targetImage =
imagecreate($thumbWidth,$thumbHeight);
imagecopyresized($targetImage,$sourceImage,0,0,0,0,$thumbWidth,$thumbWidth,imagesx($sourceImage),imagesy($sourceImage));
//imagejpeg($targetImage,
"$thumbPath/$thumbName");
imagejpeg($targetImage, $thumb);
chmod($thumb, 0755);
【问题讨论】:
-
为了更好的使用质量
imagecopyresampled(): php.net/imagecopyresampled -
质量和以前差不多,我现在主要做CF开发,但我好像记得有一种方法可以让你插入质量
-
不要采取这种错误的方式,但您粘贴的示例代码是一团糟。您应该尝试去除绒毛,看看它是否解决了某些问题,至少如果没有,它会让其他人更容易立即看到问题。
标签: php image gd thumbnails