Jump to content

JPEG "Now Playing" Sig Help


Recommended Posts

Guys, I'm currently editing the code for my sig (which I found here). What I want is for the percentage to stay in the middle of the bar...This is how it looks right now:

- removed -

And I want to change the position of the percentage...This is the code I have to edit:

<?php
Header ('Content-type: image/jpeg');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
Header('Pragma: no-cache');

// Set the dimensions

$img_width = 430;
$img_height = 50;

// Create the image

$image = imagecreate(430, 50);

// Set the colours

$black    = imagecolorallocate($image, 0, 0, 0);
$white    = imagecolorallocate($image, 255, 255, 255);
$red       = imagecolorallocate($image, 255, 0, 0);
$grey     = imagecolorallocate($image, 204, 204, 204);
$green   = imagecolorallocate($image, 128, 220, 0);

// set the bg colour and border

imagefilledrectangle($image, 0, 0, $img_width, $img_height, $white);
imageline($image, 0, 0, 0, $img_height, $black); // left border
imageline($image, 0, 0, $img_width, 0, $black); // top border
imageline($image, 0, $img_height - 1, $img_width, $img_height - 1, $black); // bottom border
imageline($image, $img_width - 1, 0, $img_width - 1, $img_height - 1, $black); // right border

// Get song info from the text file

$song_info = file("info.txt");
$main_info = explode(" - ", $song_info[0]);
$artist = trim($main_info[0]);
$title = trim($main_info[1]);
$real_length = $song_info[1];

$for = time() - $song_info[2];
$total = trim($song_info[4]);

$minutes = $for / 60;
$break = explode(".", $minutes);

$current_secs = $for % 60;
$current_mins = $break[0];

$length = $song_info[4];
$totalmins = $current_mins * 60;
$totalsecs = $current_secs + $totalmins;
$percent = $totalsecs / $length * 100;
$percent = round($percent, 0);


$font = '/path/to/ttf/font';

if ($for <= $total)
{
 ImageTTFText ($image, 8, 0, 10, 17, $black, $font, "gamehead200 is listening to ".$artist." - ".$title);

 // progress bar

 $width = $percent * 3;
 $width = round($width, 0);

 imagefilledrectangle($image, 11, 22, $width, 40, $red);

 imageline($image, 10, 21, 310, 21, $black); // top border
 imageline($image, 10, 21, 10, 41, $black); // left border
 imageline($image, 10, 41, 310, 41, $black); // bottom border
 imageline($image, 310, 21, 310, 41, $black); // right border

 if ($current_secs <= 9)
 {
    $current_secs = "0" . $current_secs;
 }

 ImageTTFText ($image, 11, 0, $width - 7, 37, $black, $font, $percent . "%");
 ImageTTFText ($image, 11, 0, 315, 37, $black, $font, $current_mins .":".$current_secs."/".$real_length);
}
else
{
 ImageTTFText ($image, 8, 0, 10, 27, $black, $font, "I am currently not listening to any music OR Winamp is not open!");
}

// output and destroy

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


?>

Any ideas on how to do this?

Link to comment
Share on other sites


try and change

$width = $percent * 3;

$width = round($width, 0);

to something a bit further on, like * 53, or where ever you want it

No, the thing is that when the bar moves, so does the percentage, so it won't work that way...I think I have to change something in the bar properties as well...

Link to comment
Share on other sites

eep

ImageTTFText ($image, 11, 0, $width - 7, 37, $black, $font, $percent . "%");

ImageTTFText ($image, 11, 0, 315, 37, $black, $font, $current_mins .":".$current_secs."/".$real_length);

mayeb its to do with this, but the only thing i know is HTMl :) i don't even know what kind of coding this is, is it php?

Link to comment
Share on other sites

eep

ImageTTFText ($image, 11, 0, $width - 7, 37, $black, $font, $percent . "%");

ImageTTFText ($image, 11, 0, 315, 37, $black, $font, $current_mins .":".$current_secs."/".$real_length);

mayeb its to do with this, but the only thing i know is HTMl :) i don't even know what kind of coding this is, is it php?

Yes! Its PHP, with GD!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...