Jump to content

GD 2 different text colours


Chris92

Recommended Posts

Hi, I'm making a soort of label that has the day number and month on it with GD, one problem is I want to make the day number green which works fine but when I try setting the month to grey it just stays white.

Here's the current code I'm using:

<?php
header("Content-type: image/Gif");

$im = imagecreatefromgif("back.gif");
$green = imagecolorallocate($back, 117, 144, 48);
$grey = imagecolorallocate($back, 85, 85, 85);
imagettftext($im, 18, 0, 11, 25, $green, 'CALIBRI.TTF', "{$_GET['q']}");
imagettftext($im, 14, 0, 10, 43, $grey, 'CALIBRI.TTF', "{$_GET['w']}");

imagegif($im);
imagedestroy($im);
?>

 

http://chrishmmens.freehostia.com/images/label.php?q=10&w=FEB

 

I treid switching the green and grey variables around which caused the month to come up in grey but the day came up in white.

I also treid setting the grey variable after the day number was set onto the images which stopped the image from showing up all together.

 

Thanks for any help, Chris.

 

 

Link to comment
Share on other sites

Solved! I simply put the colorallocate funtion inside of the funtion to set the string:

<?php
header("Content-type: image/Gif");

$im = imagecreatefromgif("back.gif");

imagettftext($im, 18, 0, 11, 25, imagecolorallocate($im, 117, 144, 48), 'CALIBRI.TTF', "{$_GET['q']}");
imagettftext($im, 14, 0, 10, 43, imagecolorallocate($im, 85, 85, 85), 'CALIBRI.TTF', "{$_GET['w']}");

imagegif($im);
imagedestroy($im);
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.