# Colors in a image

**URL:** https://forum.kirupa.com/t/colors-in-a-image/242798
**Category:** programming
**Created:** [October 30, 2007, 2:46pm UTC](https://forum.kirupa.com/t/colors-in-a-image/242798 "2007-10-30T14:46:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ReesBeest](https://avatars.discourse-cdn.com/v4/letter/r/eb8c5e/32.png) [@ReesBeest](https://forum.kirupa.com/u/ReesBeest)
#### Post date: [October 30, 2007, 2:46pm UTC](https://forum.kirupa.com/t/colors-in-a-image/242798/1 "2007-10-30T14:46:29Z")

</div>

I have a image (png), which i load with “imagecreatefrompng”. When I’m writing to the image with “imagestring” using red and white color I get different color results. Can someone explain that to me?

see example hear : [http://www.reesbeest.nl/servershot/voorbeeld.php](http://www.reesbeest.nl/servershot/voorbeeld.php)

The code :

[COLOR=Red]\<?  
header(“Content-type: image/png”);

$sv\_plaatje = “rb\_sv\_03.png”;  
$randomnr = 1;

$randomnr = rand( 1, 4);  
switch( $randomnr){  
case 1:  
$sv\_plaatje = “rb\_sv\_01.png”;  
break;  
case 2:  
$sv\_plaatje = “rb\_sv\_02.png”;  
break;  
case 3:  
$sv\_plaatje = “rb\_sv\_03.png”;  
break;  
case 4:  
$sv\_plaatje = “rb\_sv\_04.png”;  
break;  
}

$image = imagecreatefrompng($sv\_plaatje);  
$white = imagecolorallocate($image, 255, 255, 255);  
$red = imagecolorallocate($image, 255, 0, 0);

imagestring($image, 3, 110, 20, “RB Public Base”, $white);  
imagestring($image, 3, 110, 35, “81.19.219.128:28960”, $white);  
imagestring($image, 3, 110, 50, “COD UO”, $white);  
imagestring($image, 3, 110, 65, “BAS”, $white);  
imagestring($image, 3, 110, 80, “mp\_foy”, $white);  
imagestring($image, 3, 325, 35, “1/32”, $white);  
imagestring($image, 3, 325, 50, “No”, $white);  
imagestring($image, 3, 325, 65, “On”, $white);  
imagestring($image, 3, 325, 80, “1.51”, $white);

// Player info

imagestring($image, 3, 20, 114, “=RB=”, $red);  
imagestring($image, 3, 48, 114, “ReesBeest”, $white);

imagepng($image);  
imagedestroy($image);

?\>  
[/COLOR]  
If you do refresh a few times it will cycle thru 4 different images. I will then show what I mean.

Thanks in advance  
Rees
