Added a Cool Function 9


I added a cool function to the header. If you notice the image at the top… It’s an image, but really its made from a php script and a ttf font. I got the original script from the WordPress Support Forums and made some code cleanup changes and improved it so you can set all the parameters along with setting the size of the box dynamically based on the size of font and length of text.

You can view the source and sample code by downloading this file.


Leave a Reply

9 thoughts on “Added a Cool Function

  • MtDewVirus

    Thought about this script again and thought I’d check back. I’d like to be able to limit the width of the image it creates, can it wrap by words somehow? That would be Ultra-Cool!!

  • Patrick

    Hmm, yeah could limit the width of the email it creates, but that will then crop the text at that width.

    As for wrapping the Words, that’s a bit tougher, I believe there would be a way, but you’d have to calculate the size of the line, compare it to the size of the box and… well, over my head. There is some decent documentation on this GD PHP function at http://www.php.net.

  • Chris P.

    Great piece of code. In the titles.php I changed the shadow calcs to:

    $shdw_x = $shdw_x_offset + $txt_x; // Shadow Horizontal Calculation
    $shdw_y = $shdw_y_offset + $txt_y; // Shadow Vertical Calculation

    as it looked like the calc was being repeated. Also, have you tried doing this with ImageMagick? Wondering if I can cut down the output file size even further.

  • Vince

    Great little trick! Is there any way to smooth out the resulting edges so as to take care of the jaggedness of the font?

    Thanks!