Hello! =3
Let me preface this by saying I am very much the beginner, but I’ve placed this here since it seems a bit more complex than something like “How do I allocate a color”? If I’ve done wrong, I apologize. ^.^;
I’ve written a script which is supposed to dynamically draw a progress bar onto an existing png, and for the most part, it works. However, I’m having an issue with the colors. =/
Here is the script:
[php]<?php
$v1 = $_GET[‘goal’];
$v2 = $_GET[‘auro’];
$v3 = 300*($v2/$v1);
$hex = $_GET[‘bar’];
$color[‘r’] = hexdec(substr($hex, 0, 2));
$color[‘g’] = hexdec(substr($hex, 2, 2));
$color[‘b’] = hexdec(substr($hex, 4, 2));
$my_img = imagecreatefrompng ( ‘bgbubble.png’ );
$bar = imagecreate ( 300, 12 );
$background_color = imagecolorallocate($bar, $color[‘r’], $color[‘g’], $color[‘b’]);
if ($v2<=$v1)
imagecopy ( $my_img , $bar , 14 , 64 , 0 , 0 , $v3 , 12 );
elseif ($v2>$v1)
imagecopy ( $my_img , $bar , 14 , 64 , 0 , 0 , 300 , 12 );
$text_colour = imagecolorallocate( $my_img, 0, 0, 0 );
imagestring( $my_img, 2, 135, 63, “$v2 // $v1”, $text_colour );
header( “Content-type: image/png” );
imagepng( $my_img );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background_color );
imagedestroy( $bar );
imagedestroy( $my_img );
?>[/php]
Here is what ‘bgbubble’ looks like:
Here is what it looks like scripted using this url:
The problem? The end of the url is a hex color. In this case, yellow, and its clearly not displaying that way.
It works on this image just fine:
Since I don’t make the images, I can’t speak to their details, unfortunately.
But as far as the script goes, I’ve tried everything I can google. So… help, please?