Upgraded to GD 2.0: Now thumbnail pics are 16 colors??
Posted: Sat Mar 29, 2003 12:47 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.p ... yresampled
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
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.p ... yresampled
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