-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.php
56 lines (39 loc) · 1.55 KB
/
output.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/*
* Start Configuration
*/
//What is your last.fm username of which you would like to get the now playing results from?
$username = "";
//What if your specific last.fm api key?
$api_key = "";
/*
* End Configuration
*/
header("Content-Type: image/png");
$info = json_decode(file_get_contents("http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=".$username."&api_key=".$api_key."&format=json"), true);
$img = @imagecreatefrompng("includes/images/NowPlaying - Background.png");
$text_colour = imagecolorallocate($img, 255, 0, 0); //http://colorpicker.com R(ed)/G(reeb)/B(lue)
$font = 'includes/fonts/KeepCalm.ttf';
imagettftext($img, 12, 0, 130, 30, $text_colour, $font, "Song/Track: ".$info['recenttracks']['track'][0]['name']);
imagettftext($img, 12, 0, 130, 50, $text_colour, $font, "Artist(s): ".$info['recenttracks']['track'][0]['artist']['#text']);
imagettftext($img, 12, 0, 130, 70, $text_colour, $font, "Album: ".$info['recenttracks']['track'][0]['album']['#text']);
if($info['recenttracks']['track'][0]['image'][1]['#text'])
{
$albumC = $info['recenttracks']['track'][0]['image'][1]['#text'];
}
else
{
$albumC = "includes/images/NoCover.png";
}
copy($albumC, 'includes/images/album.png');
imagepng($img, "includes/images/bg.png");
$dest = imagecreatefrompng('includes/images/bg.png');
$src = imagecreatefrompng('includes/images/album.png');
imagealphablending($dest, false);
imagesavealpha($dest, true);
imagecopymerge($dest, $src, 28, 18, 0, 0, 64, 64, 100);
imagepng($dest);
imagedestroy($dest);
imagedestroy($src);
imagedestroy($img);
?>