Solved

Php Text Image

Posted on 2011-09-21
2
255 Views
Last Modified: 2012-05-12
Hello Experts,

I am creating a menu using the Franklin Condensed Font...

I have tried fontface but it renders diferently to the screenshot I produced in Photoshop.

I like the "smooth" option used in photoshop on this font, so I tried to recreate it using this php script...
<?php
// Set the content-type
header('Content-Type: image/png');

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $black);

// The text to draw
$text = 'COMPANY PROFILE';
// Replace path by your own font path
$font = 'franklin.ttf';


// Add the text
imagettftext($im, 10, 0, 10, 20, $white, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

But as you can see from the screenshot... the output image is of a poor quality next to the photoshop screenshot...

Any Ideas??
 PHP and Photoshop Output
0
Comment
Question by:maccaj51
2 Comments
 
LVL 14

Accepted Solution

by:
Scott Madeira earned 500 total points
ID: 36574387
I assume you are trying to use the script to dynamically create the menu each time.  If so, I'd recommend that you make the images in Photoshop and use them on the web site.  It will cut down on the processing required by the server to build your menus.

If I missed the boat on this one, let me know what your end goal is....

For image quality, you may want to play with the imagequlaity parameter.  Higher quality will make a bigger file.  There is a trade-off invovled.  imagejpeg() has a default quality of 75 (out of 100.)
0
 

Author Closing Comment

by:maccaj51
ID: 36579127
Cheers... I think im going to create them in PS
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now