php - Alphabet border in transparent background image is unwanted? -
i using code creating images text written in transparent backgrounds.
<?php // set content-type header('content-type: image/gif'); // create image $im = imagecreatetruecolor(400, 150); // create colors $black = imagecolorallocate($im, 0, 0, 0); $acolor = imagecolorallocate($im, 153, 204, 153); imagecolortransparent($im, $black); // text draw $text = 'testing...'; // replace path own font path $font = 'arial.ttf'; // add text imagettftext($im, 50, 0, 10, 100, $acolor, $font, $text); // using imagegif() imagegif($im,"img.gif"); imagedestroy($im); ?>
but text written in img.gif has unwanted color(black) on borders of alphabets('e,s,n,g'). how can finish color.the generated image
arial font download site http://code.google.com/p/ireader/downloads/detail?name=arial.ttf
the gif format cannot handle alpha transparency. can have 100% transparent (= invisible), or 100% opaque (= visible) pixels.
your text seems have anti-aliased, soft edges.
those edges aren't 100% transparent, they're not 100% opaque - mixture of foreground , background. makes them appear softer.
because gif format can't deal these nuances, library uses mixture of green , black simulate "weaker" green.
if use png format, problem should go away: png supports alpha transparency. there issues need if still need support ie6, every other browser, work fine straight away.
Comments
Post a Comment