#24120 [Opn->Bgs]: imagecopyresized / imagecopyresampled result is bad
| From: | rasmus@php.net | Date: | Wed, 11 Jun 2003 08:06:41 +0000 |
| Subject: | #24120 [Opn->Bgs]: imagecopyresized / imagecopyresampled result is bad | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-41667@lists.php.net to get a copy of this message | ||
ID: 24120
Updated by: rasmus@php.net
Reported By: mail at martin-schultheiss dot de
-Status: Open
+Status: Bogus
Bug Type: GD related
Operating System: RedHat-Linux 7.3
PHP Version: 4.3.2
New Comment:
Didn't I already answer this exact report a while ago? You need to use
imagecreatetruecolor() instead of imagecreate() in your code to avoid
getting a palletted image.
Previous Comments:
------------------------------------------------------------------------
[2003-06-11 03:03:12] mail at martin-schultheiss dot de
Hi!
I have upgraded from php 4.1.x to 4.3.2 with the builtin
gd library.
Now the result of the imagecopyresized funtion is very
bad, and the result of the imagecopyresampled function
too.
I don`t know how to describe the error exactly, so please
take a look at http://www.martin-schultheiss.de/test.jpg
and http://www.martin-schultheiss.de/test2.jpg
If I dont resize the image but simply read it with
imagecreatefromjpeg the result is OK.
The code used to create the image is:
$source = imagecreatefromjpeg ($filename);
$x = imagesx($source);
$y = imagesy($source);
$max = max($x, $y);
$format = $y > $x; //Portrait or Landscape
$size = 640;
if ($size != $max) { //Image has to be resized
if ($format) {
$result = imagecreate(($x*$size)/$y,$size);
imagecopyresized($result, $source, 0, 0, 0, 0,
(($x*$size)/$y) - 1, $size - 1, $x - 1, $y - 1);
} else {
$result = imagecreate($size,($y*$size)/$x);
imagecopyresized($result, $source, 0, 0, 0, 0, $size - 1,
(($y*$size)/$x) - 1, $x - 1, $y - 1);
}
imageDestroy($source);
} else {
$result = $source;
}
imagejpeg($result);
imageDestroy($result);
Bye,
Martin
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24120&edit=1