imageTTFText with GD2, problems converting from pixels to points

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
hi everyone,

i created a script that outputs an image (transparent with text) based
on parameters passed by $_GET.
everything in my application works with 'pixels' and since GD2 this
function (imagettftext) uses 'points' as the text size unit.

i've searched everywhere for a solution to convert from pixels to
points (or the other way around) but with no luck...  each place says
something different and i can't find a good answer.

any ideas of how to solve this?

thanks a lot!

Re: imageTTFText with GD2, problems converting from pixels to points

Quoted text here. Click to load it

as far as I know pixels are for (computer) screens, and points are for  

1 point (assuming Postscript) = 1/72 th of an inch
( )

How those relate depends on the resolution of the screen.
The resolution of your screen depends on the screen settings, and is not a  
fixed value.
Some people assume 72 DPI for screen. Some OS's use 96 DPI. Most of the time  
you can adjust DPI somewhere in computer settings. For Windows that used to  
be for type only, not for images.

Basically it all means: there is no real way to convert between points and  
pixels... because there is no general relationship between the two.

I usually try until things look good on as much screens I can try it on.
How is that for helping you? ;-)

Good luck,

Re: imageTTFText with GD2, problems converting from pixels to points wrote:
Quoted text here. Click to load it

I'm not sure this is still valid, since my notes on it are from 2005. PHP
docs say on imagettftext "Depending on your version of GD, this should be
specified as the pixel size (GD1) or point size (GD2)". As I recall, this
is more a terminology change than anything else. It is usually considered
that there are 72 typesetting points to the inch. It turns out that GD2 is
assuming there are 72 pixels to the inch. So the font size is in pixels and
points, because as far as GD thinks they are the same.

A lot of software makes this mistake. They specify font sizes in points
without knowing the display resolution. And 72DPI is too low for today's

Site Timeline