Solved

Php Text Image

Posted on 2011-09-21
2
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

690 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