Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First problem : your characters are ugly: that's because you need to set a palette with less colors when using imagecreatetruecolor.</p> <pre><code>$image = imagecreatetruecolor(550, 20); imagetruecolortopalette($image, true, 256); </code></pre> <p>should solve this problem.</p> <p>Second problem : there is no transparency.</p> <p>As you can see on <a href="http://php.net/manual/en/function.imagesavealpha.php" rel="nofollow">PHP manual</a>, </p> <blockquote> <p>imagesavealpha() sets the flag to attempt to save full alpha channel information (as opposed to single-color transparency) when saving PNG images.</p> </blockquote> <p>This function does not work with GIF files.</p> <p>You can use <a href="http://fr.php.net/manual/en/function.imagecolortransparent.php" rel="nofollow">imagecolortransparent</a> instead but this will not be perfect because fonts has anti-aliasing to make their border sweeter.</p> <p>Here is my code:</p> <pre><code>&lt;?php $lastlisten = "test test test test test test"; error_reporting(E_ALL); header("Content-type: image/gif"); $image = imagecreatetruecolor(550, 20); imagetruecolortopalette($image, true, 256); $transparent=imagecolorallocatealpha($image,255,255,255,127); imagecolortransparent( $image, $transparent); imagefilledrectangle($image,0,0,550,20,$transparent); $black = imagecolorallocate($image, 0, 0, 0); $font_path = dirname(__FILE__) . '/font.ttf'; imagettftext($image, 9, 0, 16, 13, $black, $font_path, $lastlisten); imagegif($image); </code></pre> <p>Result <a href="http://home.fuz.org/tests/test.php" rel="nofollow">here</a></p> <p>Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload