WordPress.org

Forums

Is there a way to convert images out of text? (35 posts)

  1. frankpereiro
    Member
    Posted 10 years ago #

    Hi all, I've been looking throughout the forum and I haven't seen anything on it.
    I would like to know if there's a way to convert text to an image. I've seen some sites that display an image as their post title and I don't know how you do that.
    Sorry if this is a stupid question but I have no idea.
    Kind regards to all.

  2. OperaManiac
    Member
    Posted 10 years ago #

    Photomatt has apparently hired elves to do the work on his site ( http://www.photomatt.net )...
    Just kiddin, there are php modules that does this and I believe LaughingLizard posted something. He would be online soon to help ya out! :)

  3. Laughinglizard
    Member
    Posted 10 years ago #

    @frankperiero: Take a look at this entry and see if that makes sense. If you run into trouble, please let me know and I will try to help.
    http://weblogtoolscollection.com/archives/2004/03/16/creating-dynamic-pngs-from-text-using-php/
    Peace

  4. frankpereiro
    Member
    Posted 10 years ago #

    Thanks Sushbubh and LaughngLizard for such a quick reply.
    I visited the link LaughingLizard provided and read the article that Mark wrote. There's a link to some tutorial but when you get to that other page there is no tutorial there.
    Maybe there is another tutorial.
    Greetings

  5. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    This is the code I use to generate my titles:
    http://photomatt.net/css/dante/titles.phps
    It's a little more complicated than necesarry because I'm goind faux-shadows and have some other fluff.

  6. Stevarino
    Member
    Posted 10 years ago #

    http://www.shauninman.com/mentary/past/ifr_an_fir_alternative.php
    Update: http://www.shauninman.com/mentary/past/ifr_revisited_and_revised.php
    A really cool new way to replace text. Check it out! It uses javascript and SWF files, no PHP whatsoever. This is the stuff that makes me giddy. :D

  7. OperaManiac
    Member
    Posted 10 years ago #

    whoa! matt released the elves code :D

  8. frankpereiro
    Member
    Posted 10 years ago #

    Thanks allusion,
    What should I do with that code? Place it in my index.php file where the title of the post goes?
    Thanks also to Stevariano, I'm looking at the page you recommended.
    Thanks again for all your help, greetings.

  9. Sandman
    Member
    Posted 10 years ago #

    Yeah, now just to figure out where to put the code and how to call it.

  10. Sandman
    Member
    Posted 10 years ago #

    So, instead of putting:
    Title: Bloggedy Blog
    I would put:
    Title: <img src="title.php?text=Bloggedy Blog" />
    ?

  11. Sandman
    Member
    Posted 10 years ago #

    No, that didn't work. Hmmm...

  12. rpeeck
    Member
    Posted 10 years ago #

    ^^ that's what it looks like...

  13. Sandman
    Member
    Posted 10 years ago #

    What? ^ ^
    ???

  14. Beel
    Member
    Posted 10 years ago #

    Sandman: You have to look at the code provided, this would be how you would call it...
    <img src="titles.php?letters=Bloggedy Blog" />

  15. Sandman
    Member
    Posted 10 years ago #

    I did look at the code, but what I'm saying is that when I put:
    <img src="titles.php?letters=Bloggedy Blog" />
    ...into the Title form of a new post, it causes the page to go haywire.

  16. Sandman
    Member
    Posted 10 years ago #

    Ok, it's creating an image with no text - that's the problem.

  17. TechGnome
    Moderator
    Posted 10 years ago #

    A quick scan of the code matt supplied shows that he's using the dante.ttf font. So... either you need to get that font, or another and upload it to your site, then change the line
    $font = '/home/photomat/dante.ttf';
    to the font loaded on your site.
    TG

  18. Sandman
    Member
    Posted 10 years ago #

    Got it! Props to Beel for helping this newbie get the hack to work.
    Sweet!
    Thanks again, guys.

  19. Anonymous
    Unregistered
    Posted 10 years ago #

    I followed the directions here (user Matt code, call it from a file.php with
    <img src='ttf.php?letters=TEST'>
    And it prints the infinity symbol, and background color but nothing else. Test at http://www.babbler.us/test.php What I am doing wrong? The phpinfo at http://www.babbler.us/phpinfo.php

  20. Beel
    Member
    Posted 10 years ago #

    You have to have it linked to a proper font, no font = no letters

  21. Anonymous
    Unregistered
    Posted 10 years ago #

    I uploaded the fonts. I have arial.ttf and georgia.ttf there right now. It would not print the infinity symbol if the font were not there, right?

  22. Anonymous
    Unregistered
    Posted 10 years ago #

    <?php
    $font = '/home/photomat/dante.ttf';
    $letter = urldecode(urldecode($letters));
    $letter = str_replace('_', ' ', $letter);
    $letter = str_replace('.png', '', $letter);
    $im = imagecreate (730, 50);
    $black = imagecolorallocate ($im, 244, 249, 217); // Background
    $white = imagecolorallocate ($im, 69, 78, 63); // Text
    $shadow = imagecolorallocate ($im, 230, 242, 166);
    imagettftext ($im, 32, 0, 23, 34, $shadow, $font, $letter); // Text shadow
    imagettftext ($im, 36, 0, 1, 24, $shadow, $font, '∞'); // Infinity symbol shadow
    imagettftext ($im, 36, 0, 0, 22, imagecolorallocate ($im, 170, 193, 43), $font, '∞'); // Infinity symbol
    imagettftext ($im, 32, 0, 20, 32, $white, $font, $letter); // Text
    header('Content-Type: image/png');
    imagePNG($im);
    imagedestroy ($im);
    ?>

    Where is $black beeing used? The urldecode twice is right? Something is not working right, the infinity symbol prints, the text doesn't... Weird...

  23. Beel
    Member
    Posted 10 years ago #

    You need to change:
    $font = '/home/photomat/dante.ttf';
    to point to your font.

  24. Anonymous
    Unregistered
    Posted 10 years ago #

    I have. I just copied his original code, since I had questions about it. I have a file named ttf.php:
    <?php
    $font = '/home/babbler.us/babbler/www/ttf/georgia.ttf';
    $letter = urldecode(urldecode($letters));
    $letter = str_replace('_', ' ', $letter);
    $letter = str_replace('.png', '', $letter);
    $im = imagecreate (730, 50);
    $black = imagecolorallocate ($im, 244, 249, 217); // Background
    $white = imagecolorallocate ($im, 69, 78, 63); // Text
    $shadow = imagecolorallocate ($im, 230, 242, 166);
    imagettftext ($im, 32, 0, 23, 34, $shadow, $font, $letter); // Text shadow
    imagettftext ($im, 36, 0, 1, 24, $shadow, $font, '∞'); // Infinity symbol shadow
    imagettftext ($im, 36, 0, 0, 22, imagecolorallocate ($im, 170, 193, 43), $font, '∞'); // Infinity symbol
    imagettftext ($im, 32, 0, 20, 32, $white, $font, $letter); // Text
    header('Content-Type: image/png');
    imagePNG($im);
    imagedestroy ($im);
    ?>

    And yes, gerogia.ttf is there, otherwise the symbol would not print. On the imagettftext lines, if I change $text for some value, like 'David', then it will print.
    The test.php file contains:
    <img src="ttf.php?letters=THIS IS A TEST TO SEE HOW THIS WORKS">
    I also tried <img src='ttf.php?letters=THIS IS A TEST TO SEE HOW THIS WORKS'>
    The symbol prints, the text will not.

  25. seriocomic
    Member
    Posted 10 years ago #

    I tried to explain how this was done in a sorta step-by-step way when Matt gave me his elf code a while back:
    http://www.seriocomic.com/rhetoric/posts/2004/04/22/the-one-about-making-titles/
    Hope that helps someone...

  26. Anonymous
    Unregistered
    Posted 10 years ago #

    Seriocomic, somehow the variable $text is not beeing passed. How or why could that be? Please see http://www.babbler.us/test.php

  27. Beel
    Member
    Posted 10 years ago #

    Do a test to see if it is an issue with your server. In the code at the top put $letters = "test"; and run the file.

  28. Anonymous
    Unregistered
    Posted 10 years ago #

    If I do that Beel, it works. What could be causing that?

  29. Beel
    Member
    Posted 10 years ago #

    Now try this, put $letters = $_GET['letters']; in place of that line and then try and pass the text.

  30. Anonymous
    Unregistered
    Posted 10 years ago #

    It works!! What the heck? Why it wasn't working before? Please do tell.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.