sumo
Site Supporter
For the techies on here, in case you are interested, here is the code that generates my 'Fuelly' signature.
The program starts with this template:
modifies it by adding L/100 and MPG and then displays the modified image as my signature.
All I supply is the L/100 (litres per hundred, notice metric=3.381 below) which gets rounded and the MPG is calculated by conversion. For example:
http://files.forestcitynetwerxs.com/mileage.php?metric=3.381
Below is what I put in my Settings -> Edit Signature
I do need to know my L/100 and track that on Google Sheets.
PHP:
<?php
// Read template image into memory variable $im
$im = imagecreatefrompng("bike_template.png");
// Change $im to transparent background
imagesavealpha($im, true);
// 'Get' value from url ie: [url]http://files.forestcitynetwerxs.com/mileage.php?metric=3.381[/url]
$metric = htmlspecialchars($_GET["metric"]);
// Convert metric L/100 into miles per US gallon
if ($metric==0){
$usgal = "0";
}else{
$usgal = round(((100*3.785411784)/(1.609344*$metric)),1);
};
// Convert numbers to text rounded to nearest decimal point
$metric = sprintf("%3.1f", $metric);
$usgal = sprintf("%4.1f", $usgal);
$textcolor = imagecolorallocate($im, 255, 0, 0); // Set textcolor to red --> '255,0,0'
$mysize = 0;
$x = 163;
$y = 20;
// Add text to $im
// specify size, x and y coordinate, the actual text and the color
imagestring($im, $mysize+3, $x-1, $y+0, "L/100", $textcolor);
imagestring($im, $mysize+4, $x+10, $y+10, $metric, $textcolor);
imagestring($im, $mysize+3, $x+10, $y+26, "M", $textcolor);
imagestring($im, $mysize+3, $x+19, $y+26, "P", $textcolor);
imagestring($im, $mysize+3, $x+27, $y+26, "G", $textcolor);
imagestring($im, $mysize+4, $x+2, $y+36, $usgal, $textcolor);
// Now that the image $im in memory has had the red text placed where I want it
// output the image
header('Content-type: image/png');
imagepng($im);
// That being done clean up after yourself
imagedestroy($im);
?>
modifies it by adding L/100 and MPG and then displays the modified image as my signature.
All I supply is the L/100 (litres per hundred, notice metric=3.381 below) which gets rounded and the MPG is calculated by conversion. For example:
http://files.forestcitynetwerxs.com/mileage.php?metric=3.381
Below is what I put in my Settings -> Edit Signature
I do need to know my L/100 and track that on Google Sheets.
Last edited: