Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts

    Rotate text 30degrees or more?

    Hi guys,

    I wonder if it is possible to rotate a piece of text with PHP?

    I have searched around on google and found only IE-solutions and solutions saying that I have to write the text to an image and then rotate it with some GD-library or something. But my problem is that my text is a PHP-date script which changes output every day, - that's why I can not just make it an image.

    Does anyone know how to get around that one?
    Last edited by CaptainB; 03-27-2009 at 12:59 PM.

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    solutions saying that I have to write the text to an image and then rotate it with some GD-library or something
    you would use that to generate that img on page load... so it's not like it's a static img or something. think of a captcha solution for example.

  • Users who have thanked ohgod for this post:

    CaptainB (03-27-2009)

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Thank you.

    I've now found and modified a possible solution which generates an image with some text and sets a background-color. However, how would I modify it to not set a background-color but write the text on top of an image instead?

    PHP Code:
    <?php     header("Content-Type: image/jpeg"); create_image(); 
    exit(); 
     
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    http://www.webcheatsheet.com/PHP/dynamic_image_generation.php
    <?php 
    //Send a generated image to the browser 

    function create_image() 


        
    $pass Patrick

        
    //Set the image width and height 
        
    $width 100
        
    $height 20;  

        
    //Create the image resource 
        
    $image ImageCreate($width$height);  

        
    //We are making three colors, white, black and gray 
        
    $white ImageColorAllocate($image255255255); 
        
    $black ImageColorAllocate($image000); 
        
    $grey ImageColorAllocate($image204204204); 

        
    //Make the background black 
        
    ImageFill($image00$black); 

        
    //Add generated string in white to the image
        
    ImageString($image3303$pass$white); 

     

        
    //Output the newly created image in jpeg format 
        
    ImageJpeg($image); 
        
        
    //Free up resources
        
    ImageDestroy($image); 

    ?> 






    </body>
    </html>
    I guess this is the part which needs to be modified in some way:
    PHP Code:
        //Make the background black 
        
    ImageFill($image00$black); 
    Last edited by CaptainB; 03-27-2009 at 11:51 AM.

  • #4
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Nevermind, I figured it out. You have to replace the 'image' variable with the "createimagefrompng":
    PHP Code:
        $image ImageCreatefrompng("captcha.png"); 
    I also found this: http://www.alistapart.com/articles/dynatext


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •