Solved

Php Text Image

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dynamic varibles 5 32
Using javascript confirmation for a delete in mysql 5 31
mysqli insert query problems 4 22
comma true 6 33
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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 a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

770 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