SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Passionate Web Developer Egyptechno's Avatar
    Join Date
    Jan 2004
    Location
    Dubai
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [GD Help] Rotate the Text with imagestring()

    iam working on new project these days ..

    so, in a part of it it's supposed to write on a picture ..

    i used imagettftext() to write it .. and to rotate the text but
    imagettftext() only use true type fonts .. so it's not anti-alised

    imagestring() make nice font .. but i can't rotate it ..

    any ideas ?

  2. #2
    SitePoint Wizard dominique's Avatar
    Join Date
    Dec 2000
    Location
    orbis terrarum
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's kind of lame, but it works. Write in a new image, rotate it, then copy it back into your image.

    E.g.:
    PHP Code:
    $label "Y-Axis Label";
    $labelfont 2;

    // pixel-width of label
    $txtsz imagefontwidth($labelfont) * strlen($label);
    // pixel-height of label
    $txtht imagefontheight($labelfont);

    // define temp image
    $labelimage imagecreate($txtsz$txtsz);
    $white imagecolorallocate($labelimage0xFF0xFF0xFF);
    $black imagecolorallocate($labelimage0x000x000x00);

    // write to the temp image
    imagestring($labelimage$labelfont0$txtsz/$txtht/2$label $black);

    // rotate the temp image
    $labelimage1 imagerotate($labelimage90$white);

    // copy the temp image back to the real image
    imagecopy($image$labelimage13$vmargin $ysize/$txtsz/2$txtsz/$txtht/20$txtht$txtsz);

    // destroy temp images, clear memory
    imagedestroy($labelimage);
    imagedestroy($labelimage1); 


Bookmarks

Posting Permissions

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