+ Reply to Thread
Page 2 of 6
FirstFirst 1 2 3 4 ... LastLast
Results 11 to 20 of 51

Thread: PHP:Tutorial - Getting to know GD

  1. #11
    Co-Administrator John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John's Avatar
    Join Date
    Jul 2006
    Age
    21
    Posts
    5,885
    Blog Entries
    25
    you can change the file the php script looks for by editing this line

    Code:
    $font 'font.ttf'//font file 
    change it to

    Code:
    $font 'font.TTF'//font file 

  2. #12
    TcM
    TcM is offline
    Code Warrior TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM's Avatar
    Join Date
    Aug 2006
    Posts
    11,461
    Blog Entries
    6
    Yeah I did that too before but.. still Broken image link :S

  3. #13
    Newbie codyg is an unknown quantity at this point
    Join Date
    Dec 2006
    Posts
    1

    Thumbs up Thanks

    Thanks for this, exactly want i needed and VERY helpful

  4. #14
    Newbie major is an unknown quantity at this point
    Join Date
    Jan 2007
    Posts
    2
    thanks!!!
    just the thing i was looking for
    prozit.net/ilu/index.php?form=sidewinder
    prozit.net/merry/index.php?form=Dan

    but i have one little problem
    how can i place the text in the midlle
    or by pixels

    and how can i pu the text in an angle
    Last edited by major; 01-13-2007 at 04:04 AM.

  5. #15
    Co-Administrator John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John's Avatar
    Join Date
    Jul 2006
    Age
    21
    Posts
    5,885
    Blog Entries
    25
    Quote Originally Posted by major View Post
    but i have one little problem
    how can i place the text in the midlle
    or by pixels
    Well by following the tutorial you know that these lines account for the location of the text:

    Code:
    $size imagettfbbox($fontsize0$font$text);
    $dx = (imagesx($im)) - (abs($size[2]-$size[0])) - 20
    Code:
    imagesx($im
    is the width of the image and
    Code:
    abs($size[2]-$size[0]) 
    is the width of the font

    In theory taking half the width of the image, and then subtracting half the width of the string should give you centered text so try this

    Code:
    $dx = (imagesx($im)/2) - (abs($size[2]-$size[0])/2); 
    Quote Originally Posted by major View Post
    and how can i put the text in an angle
    Quote Originally Posted by Sidewinder
    The imagettftext requires 8 arguments which are the resource image, font size, the angle, x location, y location, font color, the actual font, and the string to be printed.
    By taking a look at the php manuals reference to the imagettftext [ PHP: imagettftext - Manual ]
    angle:

    The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For example, a value of 90 would result in bottom-to-top reading text.
    There for to make the text on an angle
    You would do
    Code:
    imagettftext($im$size451512$color$font$text); 
    Where 45 is the angel degree.

    This code has not been tested

    hth

  6. #16
    Newbie major is an unknown quantity at this point
    Join Date
    Jan 2007
    Posts
    2
    it is writing
    <br />
    <b>Fatal error</b>: Call to undefined function: imagettfbbox() in <b>/home/labdan/domains/prozit.net/public_html/gd/in.php</b> on line <b>22</b><br />


    http://prozit.net/gd/in.php?text=sadsa
    ...
    how can i solve it
    and onther thing
    it is the same code for gif and jpg expet from changing image/gif
    and
    image.gif
    ?

  7. #17
    Newbie ConnorWilson is an unknown quantity at this point
    Join Date
    Jan 2007
    Posts
    4
    I never really understood GD, even though I'm pretty advanced at PHP. This cleared a lot of things up, thanks.

  8. #18
    Co-Administrator John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John's Avatar
    Join Date
    Jul 2006
    Age
    21
    Posts
    5,885
    Blog Entries
    25
    Quote Originally Posted by major View Post
    it is writing
    <br />
    <b>Fatal error</b>: Call to undefined function: imagettfbbox() in <b>/home/labdan/domains/prozit.net/public_html/gd/in.php</b> on line <b>22</b><br />


    http://prozit.net/gd/in.php?text=sadsa
    ...
    how can i solve it
    and onther thing
    it is the same code for gif and jpg expet from changing image/gif
    and
    image.gif
    ?
    Which part of the changed code is causing the error? And no, this code is only meant for png images, there are other functions you can use for gif's and jpg's such as imagecreatefromgif() or imagecreatefromjpeg() rather than imagecreatefromgif(). Although you have to change the functions the general code should remain the same.

    For more information on the GD functions take a look here PHP: gd_info - Manual

  9. #19
    Newbie kraam is an unknown quantity at this point
    Join Date
    Apr 2007
    Posts
    1
    cool thanks

  10. #20
    Newbie snailofsatan is an unknown quantity at this point
    Join Date
    May 2007
    Posts
    4
    hello! nice tutorial!! i was just wondering if you know how to wrap the text into a nice paragraph if the string is too long to fit onto the image?

    thankyou
    kev.

+ Reply to Thread
Page 2 of 6
FirstFirst 1 2 3 4 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. PHP:Tutorial - Email Verification
    By John in forum PHP Tutorials
    Replies: 3
    Last Post: 09-19-2007, 12:19 PM
  2. PHP:Tutorial The Date
    By John in forum PHP Tutorials
    Replies: 0
    Last Post: 01-10-2007, 06:10 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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