2

I 'm trying to add text on a specific image. Its working perfectly but the quality of image is low especially for papyrus.ttf font. How can i improve the quality of text in the image. But i need high quality to print the output. Here is my code.. its very simple.

header("Content-Type: image/jpeg");
$im = imagecreatefromjpeg("cosmos.jpg");  
$black = ImageColorAllocate($im, 0, 0, 0);
Imagettftext($im, 14, 0, 10, 15, $black, 'papyrus.ttf', "Corey and Lisa ");
Imagettftext($im, 14, 0, 10, 35, $black, 'papyrus.ttf', " 1994, june");
Imagejpeg($im, '', 100);
ImageDestroy($im);

Download: http://wneeds.com/gdtest.zip

1 Answer 1

7

If imageTTFText fails in Quality, the next step to try is ImageFTText(). It uses the FreeType library to render fonts, which usually means significantly better quality. It needs to be installed and compiled into PHP to work, which it most often is. Try calling the function and you'll see whether that is the case.

If that doesn't do, the next step is using ImageMagick either through the command line, or through the appropriate PHP extension. But try Freetype first, it could already be enough.

Sign up to request clarification or add additional context in comments.

8 Comments

Completely agree. If you don't care about resources you can try to make the image larger than needed and downsize to your needed size which should be slight quality improvement of the font, but it is a bit resource waste.
thanks for all. I have tried with imagefttext(). But not getting better quality. i didn't use imagemagick before. So i think i have to go on that. but i was expecting more from gd. The code i supplied is a simple.. but in my system , i made for dynamic packets with dynamic message. so i have to change lot of thing if i go with image magic. @pekka can u pls check the code with imageFTText() and check the output. u may can find out whats happening. may be i'm doing some wrong. i will be grateful to u if u change the source and give me a simple solution. thanks again.
@apu can you post some images of real live examples please, along with images of what it is supposed to look like?
in my question i have posted a zip file link.In that folder all files are available. wneeds.com/gdtest.zip. expected output is here. its generated with photoshop. wneeds.com/mike%20and%20kendra.jpg
@apueee I don't have a PHP with Freetype handy, and versions can differ. Can you make a screenshot of the result you're getting right now?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.