increasing image / text resolution in GD

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
giles
Forum Commoner
Posts: 34
Joined: Thu Sep 14, 2006 2:34 pm

increasing image / text resolution in GD

Post by giles »

Hi all,

I'm trying GD out for the first time. Here's my issue.

I'm interested in using GD to turn text into an image that I can then rotate by 90 degrees (as a way round browsers not being able to handle vertical text). It all works but the final image resolution appears to be somewhat low ... I guess the standard 72dpi. Trouble is that this image is going to placed adjacent to normal HTML text, which is going to render anywhere between 300 to 1200 dpi when printed on a nomal desktop printer .... so (you guessed it) my GD text looks aliasing and raggady next to my HTML text.

Is there anyway that I can get GD to render at a higher DPI so I can try match the quality?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: increasing image / text resolution in GD

Post by onion2k »

Nope. You're stuck with 72dpi. Browsers can really only display 72dpi images anyway though, so it's not really a problem most of the time.

You can 'fake' it by making a much larger image and then downsampling it with imagecopyresampled(), essentially a cheap way of doing anti-aliasing, but it's not perfect.
giles
Forum Commoner
Posts: 34
Joined: Thu Sep 14, 2006 2:34 pm

Re: increasing image / text resolution in GD

Post by giles »

thanks for your reply.You mention your fix as a 'cheap' way ... I'm wondering if there is an 'expensive' way? (I've tried your suggestion and Aliasing is still apparent)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: increasing image / text resolution in GD

Post by onion2k »

The expensive way is to write your own anti-aliasing code. It's also the really, really hard way.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: increasing image / text resolution in GD

Post by Kieran Huggins »

I've found that the issue is often solved by using imagecopyresampled() instead of imagecopyresized()
Post Reply