php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35808 ImageTTFtext output Black&White image error
Submitted: 2005-12-26 17:55 UTC Modified: 2006-01-09 20:39 UTC
From: pm5884 at email dot si Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 4.4.1 OS: WinXP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: pm5884 at email dot si
New email:
PHP Version: OS:

 

 [2005-12-26 17:55 UTC] pm5884 at email dot si
Description:
------------
A interesting problem with imagettftest function, it can't output 2 color (black & white - 1 BitsPerPixel) images. It always switches to at least 16 color's (4 BitsPerPixel). I need 2 color output, how can I get it???


Reproduce code:
---------------
<?
$image = ImageCreate(100,30);
$background_color = ImageColorAllocate($image, 255, 255, 255);
$text_color = ImageColorAllocate($image, 0, 0, 0);
$ttf_font = './font/Arial.ttf';
$text = 'test';
echo imagecolorstotal($image)."<br>";
ImageTtfText($image ,10 ,0 ,23 ,23 ,$text_color, $ttf_font, $text);
echo imagecolorstotal($image);
ImagePNG($image,"./file.png");
ImageDestroy($image);
?>

Expected result:
----------------
BLACK & WHITE image

Actual result:
--------------
16 clor image

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-26 18:10 UTC] pajoye@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Disable antialiasing if you want only 2 colors (bgd+fgd):
ImageTtfText($image ,50 ,0 ,23 ,23 , -$text_color, $ttf_font, $text);




 [2006-01-07 19:05 UTC] pm5884 at email dot si
Thank you for your previous help, i must admit that  i don't have many experience with image and font manipulation.

With your help i have managed to make a Black&white image but the result is still not god enough.
I must write characters to a small image and in get a cut down characters (http://users.volja.net/pm5884/34.png and 32.png--please zoom in). 
Can i setup the imagettftext function so that i get better results?
Or is it a bug of antializing?
 [2006-01-09 20:39 UTC] pm5884 at email dot si
I now that the GD library uses the Freetype library to generate glyphs.  Can it be possible that I most set another parameter to better hint characters (grid-fitting) when making small black & white characters? Is it possible to select hinting method when using  imagettftext()? Is there a another way to get better results?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 21:01:35 2025 UTC