note 79316 added to function.imagecolorat
| From: | phocis | Date: | Tue, 20 Nov 2007 17:47:31 +0000 |
| Subject: | note 79316 added to function.imagecolorat | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132438@lists.php.net to get a copy of this message | ||
I believe GD has an issue with transparent mattes and alpha blending. It seems GD thinks that some
images have a black matte transparency (meaning that the image is built on a black matte instead of
transparent).
And while "alan hogan dot com slash contact" solution does deal with this, the results
seem to be... glitchy. you get different results each time you do it, and they are not always the
best.
So I made a different solution that, while it looks better on a white background and is consistent,
still sort of mangles the image just a bit by merging all blended pixels with the transparent color.
// Load image
$img = imagecreatefrompng('my_broken_png.png');
// Make matte canvas
$matte = imagecreatetruecolor(16,16);
$trans_color = imagecolorallocatealpha($matte,254,254,254,0);
imagefill($matte, 0,0,$trans_color);
// Put the old image on the matte
imagecopy($matte,$img,0,0,0,0,16,16);
// Turn the matte color into full alpha (blended pixels will not be affected)
imagecolortransparent($matte,$trans_color);
// Display image
header('Content-Type: image/gif');
imagegif($matte);
----
Server IP: 69.147.83.197
Probable Submitter: 64.79.222.10
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorat.php
Edit -- https://master.php.net/note/edit/79316
Del: integrated -- https://master.php.net/note/delete/79316/integrated
Del: useless -- https://master.php.net/note/delete/79316/useless
Del: bad code -- https://master.php.net/note/delete/79316/bad+code
Del: spam -- https://master.php.net/note/delete/79316/spam
Del: non-english -- https://master.php.net/note/delete/79316/non-english
Del: in docs -- https://master.php.net/note/delete/79316/in+docs
Del: other reasons-- https://master.php.net/note/delete/79316
Reject -- https://master.php.net/note/reject/79316
Search -- https://master.php.net/manage/user-notes.php