PHP Developers Network
http://forums.devnetwork.net/

Transparency gone, only black background
http://forums.devnetwork.net/viewtopic.php?f=40&t=131414
Page 1 of 1

Author:  stephankn [ Wed Aug 31, 2011 6:00 pm ]
Post subject:  Transparency gone, only black background

Hi,

I hope to get some advice here.
I'm currently working on a little script that dynamically creates images that will serve as an overlay to other images by using transparent areas. The browser will layer these using OpenLayers.

Up to last week my prototype worked fine. The images had a completely transparent background with different colored blocks being slightly transparent.

Now the transparency is gone, I just get a black background where in the past the transparency had been. I was actively working on the script, but don't remember having changed anything substantial on the painting itself.

What I did: I updated apache on the server to fix the DOS problem regarding range requests. I checked the logs, that update did only affect apache. Config files look unchanged. No php or GD was changed if I see it right.

System is a debian squeeze. apache2 is 2.2.16-6+squeeze2, php5 is 5.3.3-7+squeeze3, php5-gd is 5.3.3-7+squeeze3

So is this an issue with the software or with my script? I have created the following code to reproduce the problem:
When invoked from the command line the image is like expected. Problem occurs when called using apache and mod_php.

Syntax: [ Download ] [ Hide ]
<?php

$img = imagecreatetruecolor(256, 256);
imagealphablending($img, false);
imagesavealpha($img, true); // single color transparency works with savealpha = false
$transparent = imagecolorallocatealpha( $img, 0x00, 0x00, 0x00, 127 );
//imagecolortransparent($img, $transparent); // causing single-color transparency. I also want colored parts being transparent so this is no option
imagefill($img, 0, 0, $transparent);
$color_yellow = imagecolorallocatealpha($img, 255, 214, 51, 40);
imagefilledrectangle($img, 0, 0, 15, 15, $color_yellow);
header("Content-type: image/png");              
imagepng($img);
imagedestroy($img);


Thank you already for your time,

Stephan

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/