Forum Moderators: coopster
so i added the code bettween the lines of stars, which gets rid of the black, where it should do, but makes it blueish/grey and the font color remains the same.
please could you tell me why this is happening and how to make it display my text as black and transparency as transprent.
<?php
header ('content-type: image/png');
$im = imagecreatefrompng('bars/title_test.png');
********************************************
// added here got rid of black border, but it did not //make the fill white, like the back ground
imageAlphaBlending($im, true);
imageSaveAlpha($im, true);
// ************************
$fontpath = '/usr/www/users/mimi7818/fonts/';
$texttobeadded = "test text for button";
$x = 10;
$y = 30;
$color = imagecolorallocate ($im, 0,0,0);
imagettftext ($im,30,0,$x,$y,$color,'/usr/www/users/mimi7818/fonts/HIROSHT.TTF', $texttobeadded);
imagepng ($im);
?>
[edited by: jatar_k at 4:55 am (utc) on Oct. 19, 2004]
[edit reason] removed links [/edit]
I suspected that this difference probably had to do with how the images were constructed and saved in graphics editors. It's possible to save the background color of a transparent background in gimp, for example.
Worst of all, I found that this behavior of transparent stuff changed when moving from platform to platform. What worked lovely in my rather irkish GD2 install on Debian (irkish: doesn't have imagerotate or imagecreatefromgif) refused to work on my host's install of GD2 on Red Hat. Hooorah.
At this point, there's not much I can do for you except commiserate a bit. Maybe there's a bigger gd wiz on these boards who can help the both of us here with a truly golden tip.
I can offer some very klugey advice, though, so here it is. You might try turning off imagealphablending once you've already printed out your text on the png, and maybe turning off imagesavealpha. Try juggling around these values, turning it on here, turning it off there, and seeing what you get.
For my script, I encouraged users to upload graphics without transparency, and since mine also did weird stuff with png and gif in an area that was added on to the bottom of the image, I actually give them the option of changing their image to jpeg format, which solved these issues. So they see their image as uploaded with the stuff that gd does, and if they don't like it, they click on 'switch to jpeg' and it looks better again.
Good luck.