• A few people have been scammed on the site, Only use paypal to pay for items for sale by other members. If they will not use paypal, its likely a scam NEVER SEND E-TRANSFERS OF ANY KIND.

Custom 'Fuelly' signature

sumo

Site Supporter
Joined
Jan 27, 2016
Messages
592
Reaction score
4
Points
18
Location
SW Ontario
Visit site
For the techies on here, in case you are interested, here is the code that generates my 'Fuelly' signature.

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);
?>
The program starts with this template:
bike_template.png

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
mileage.php


Below is what I put in my Settings -> Edit Signature
1.JPG

I do need to know my L/100 and track that on Google Sheets.
1.jpg
 
Last edited:
Interesting. I'm actually in the middle of Java Programming course so it is neat to compare the two languages. There are obviously differences but there are similarities too. I've played around with PHP but only for a limited amount. I needed a script that would rotate a picture on a website. I wanted the picture to change every hour on the hour. I used PHP to make this happen. Thanks for posting.
 
Back
Top