Solved

Php Text Image

Posted on 2011-09-21
2
256 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
php call to a non-object 3 34
Site hacked - decoding the PHP? 15 72
WordPress website error - Unable to access website. 5 35
javascript date picker in php while loop 5 28
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

864 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

23 Experts available now in Live!

Get 1:1 Help Now