Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Vancouver, BC
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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/showthrea...ecopyresampled

    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

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    seldom ruined but by myself


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •