...

View Full Version : Upgraded to GD 2.0: Now thumbnail pics are 16 colors??



camarosource
03-29-2003, 06:54 PM
We had a PHP script made for us which holds a database of vehicle information. A file "thumbnail.php" script is a program that was written that displays the full sized image as a resized image on the browser screen.

Our server recently changed to PHP 4.3.1 and GD 2.X and now the thumbnail.php script is having problems.

The thumbnail.php images (jpg) that display are displayed as 16 colors and very much washed out.

From reading up on forums, particularily:

http://forum.rackshack.net/showthread.php?threadid=19299&highlight=imagecopyresampled

It seems we need to add a new function "imagecreatetruecolor()" to the small thumbnail.php script.

Personally I don't know PHP and so I need someone here who could help implement this function to my thumbnail.php script:

[THUMBNAIL.PHP]

(removed opening php tag)

isset($_GET['img']) or die();

$loc_full = $_SERVER['DOCUMENT_ROOT'].'/new_site/camaro_info_db/images/'.$_GET['img'];

if (preg_match('/\.gif$/i', $loc_full)) {
header('Content-type: image/gif');
readfile($loc_full);
die();
}

header('Content-type: image/jpeg');

//get original image's size
list($full_x, $full_y) = getimagesize($loc_full);

//get thumbnail's size
$thumb_x = isset($_GET['x']) ? $_GET['x'] : 120;
$thumb_y = isset($_GET['y']) ? $_GET['y'] : 90;

//create an image object from the original, and create a new blank object
$full = imagecreatefromjpeg($loc_full);
$thumb = imagecreate($thumb_x, $thumb_y);

//copy and resize the original into $thumb
imagecopyresampled($thumb, $full, 0, 0, 0, 0, $thumb_x, $thumb_y, $full_x, $full_y);

imagejpeg($thumb, '', 80);

(removed closing php tag)

Thanks

Shecky
03-31-2003, 12:37 PM
gd2, including the gd extentions bundled with php 4.3+ are not entirely up to par. Somehow they missed the fact that imagecopyresampled is extremely buggy. If theres a workaround re: the bug, i'm sure its been posted by someone on php.net's imagecopyresampled function page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum