php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21265 unexpected low color depth
Submitted: 2002-12-29 09:25 UTC Modified: 2002-12-29 13:13 UTC
From: tho dot r at gmx dot net Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.0/4.4.0 OS: Linux
Private report: No CVE-ID: None
 [2002-12-29 09:25 UTC] tho dot r at gmx dot net
Hi!

Before switching to PHP 4.3.0 we could create a "nice" colored thumbnail from an image via PHP and GD (1.8.x) with the following code:

$thumb  = imagecreate($twidth, $theight);
$orig = @imagecreatefromjpeg($file);
if (!$orig) {
  echo "Couldn't load JPEG image '$file'.";
  exit();
}

imagecopyresized($thumb, $orig, 0, 0, 0, 0, $twidth,
                 $theight, $width, $height);
mkdir(dirname($thumbnail),0777);
imagejpeg($thumb,$thumbnail,65);

We had a switch statement for any supported image type (JPEG, GIF and PNG). The created image is of course smaller but has the same color depth as the original.
After using PHP 4.3.0 and its bundled GD2 library the image is also created but the result has very less colors (maybe 16). I've put an example here:
http://thoralf.log-out.net/tmp/php4.3.0.html
I'm not sure, if I did a mistake or if there is something missing now - but it works with PHP4.2.2 very well.

The PHPInfo from the server can be found here:
http://m84.de/phpinfo.php

bye
Thoralf

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-29 13:13 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The image you are making a thumbnail is a truecolor image, therefor when creating the thumbnail, you should use imagecreatetruecolor() & not imagecreate().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 03:01:33 2024 UTC