【问题标题】:phpThumb (imagecreatefromjpeg) on white images generates #fefefe stripes白色图像上的 phpThumb (imagecreatefromjpeg) 生成 #fefefe 条纹
【发布时间】:2014-05-09 16:32:59
【问题描述】:

我在使用 phpThumb(或任何其他图像大小调整库)生成拇指时遇到了一个大问题

首先让我向您展示可见的问题: http://aep.w3mt.biz/content/mediacontent/products/427/aztec-pearls-1.jpg_gz.jpg(这是生成的图片) http://aep.w3mt.biz/content/mediacontent/products/427/aztec-pearls-1.jpg(这是源图)

如您所见,图片较大,是通过 php thumb、100% qualiti、填充颜色生成的。

源图像的背景是纯白色的,但生成的图像的背景有水平的#fefefe 条纹。这在水晶般清晰的显示器上是可见的并且非常烦人。

我想知道是否有人遇到此问题,是否有解决此错误的方法。

生成的其他尺寸:

提前谢谢你!

【问题讨论】:

    标签: php image phpthumb


    【解决方案1】:

    这是我生成缩略图的方法,欢迎您尝试:

    header("Content-type: image/jpeg");
    $collection = $_GET['collection'];
    $ref        = $_GET['ref'];
    $maxthumb=100;
    $filename=DirectoryNameFromCollectionNumber($collection) . "/" . $ref . ".jpg";
    $size = getimagesize($filename);
    $ratio = $size[0]/$size[1]; // width/height
    if( $ratio > 1) {
        $width = $maxthumb;
        $height = $maxthumb/$ratio;
    }
    else {
        $width = $maxthumb*$ratio;
        $height = $maxthumb;
    }
    $src = imagecreatefromstring(file_get_contents($filename));
    $dst = imagecreatetruecolor($width,$height);
    imagecopyresampled($dst,$src,0,0,0,0,$width,$height,$size[0],$size[1]);
    imagedestroy($src);
    imagejpeg($dst);
    imagedestroy($dst);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-10
      • 2013-09-27
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 2019-06-16
      相关资源
      最近更新 更多