1

I have a big problem generating thumbs with phpThumb (or any other image resizing library)

First let me show you the visible problem: http://aep.w3mt.biz/content/mediacontent/products/427/aztec-pearls-1.jpg_gz.jpg (this is the generated image) http://aep.w3mt.biz/content/mediacontent/products/427/aztec-pearls-1.jpg (this is the source image)

As you can see, the image is larger and it's generated via php thumb, 100% qualiti, fill color.

The backgroud of the source image is pure white but the backgroud of the generated image has horizontal #fefefe stripes. This is visible and very annoying on crystal clear displays.

I'm wondering if anybody had this problem and if there's a solution for this bug.

Other sizes generated:

Thank you in advance!

Lucian Vasile
  • 482
  • 5
  • 17

1 Answers1

0

Here is how I generate thumbnails, you are welcome to try this:

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);
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432