Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Usage: head.php?nick=Notch&size=48
- * Dimensions will be size px width and size px height
- */
- if(!isset($_GET['nick'])) {
- $_GET['nick'] = 'char';
- }
- if(!isset($_GET['size'])) {
- $_GET['size'] = 8;
- }
- $cache_file = 'cache_head/'.$_GET['nick'].'_'.$_GET['size'].'.png';
- $cache_life = '86400';
- $filemtime = @filemtime($cache_file);
- if (!$filemtime or (time() - $filemtime >= $cache_life)) {
- $width = $_GET['size'];
- $height = $_GET['size'];
- $img=imagecreatetruecolor($width,$height);
- imagealphablending($img, false);
- $transparent = imagecolorallocatealpha($img, 0, 0, 0, 127);
- imagefill($img, 0, 0, $transparent);
- imagesavealpha($img,true);
- imagealphablending($img, true);
- $im = @imagecreatefrompng('http://s3.amazonaws.com/MinecraftSkins/'.$_GET['nick'].'.png');
- if(!$im) {
- $im = @imagecreatefrompng('http://s3.amazonaws.com/MinecraftSkins/char.png');
- }
- imagealphablending($im, true);
- imagecopyresampled($img, $im, 0, 0, 0, 0, $width, $height, 8, 8);
- header("Content-type: image/png");
- imagepng($img);
- imagepng($img, $cache_file);
- imagedestroy($img);
- imagedestroy($im);
- } else {
- readfile($cache_file);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement