SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    imagecolorallocate only printing grey text?

    Hi I am using imagecolorallocate to print text over a png image, however it doesn't matter what colour I try and change the text to it always appears grey. I'm really not sure what is going wrong and just can't get this to work, any help would be most appreciated.

    Thanks

    Code:
    <?php 
    header("Content-Type: image/PNG");
    $image = ImageCreateFromPNG("news-paper-headline.png");
    
    $font = 'impact.ttf';
    $fontSize = "35";
    $fontRotation = "0";
    $color = imagecolorallocate($image, 000, 000, 139);
    $colorShadow = imagecolorallocate($image, 0x00, 0x00, 0x00);
    
    if (isset($_GET['line1'])) {
    $line1 = $_GET['line1'];
    }
    if (isset($_GET['line2'])) {
    $line2 = $_GET['line2'];
    }
    if (isset($_GET['line3'])) {
    $line3 = $_GET['line3'];
    }
    if (isset($_GET['line4'])) {
    $line4 = $_GET['line4'];
    }
    
    ImageTTFText($image, $fontSize, $fontRotation, 50, 250, $colorShadow, $font, $line1);
    ImageTTFText($image, $fontSize, $fontRotation, 50, 250, $color, $font, $line1);
    
    ImageTTFText($image, $fontSize, $fontRotation, 50, 300, $colorShadow, $font, $line2);
    ImageTTFText($image, $fontSize, $fontRotation, 50, 300, $color, $font, $line2);
    
    ImageTTFText($image, $fontSize, $fontRotation, 50, 350, $colorShadow, $font, $line3);
    ImageTTFText($image, $fontSize, $fontRotation, 50, 350, $color, $font, $line3);
    
    ImageTTFText($image, $fontSize, $fontRotation, 50, 400, $colorShadow, $font, $line4);
    ImageTTFText($image, $fontSize, $fontRotation, 50, 400, $color, $font, $line4);
    
    ImagePng ($image);
    imagedestroy($image);
    
    ?>

  2. #2
    SitePoint Member
    Join Date
    May 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If anyone can help I would really appreciate it, still stuck :-(


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
  •