Advertisement
Guest User

Untitled

a guest
May 11th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. <?php
  2.     header("Content-Type: image/png");
  3.    
  4.     $size = isset($_GET['w']) && is_numeric($_GET['w']) && $_GET['w'] <= 1600  && $_GET['w'] >= 8 ? $_GET['w'] : 100;
  5.     $helm = isset($_GET['h']) && $_GET['h'] == 1 ? true : false;
  6.  
  7.     // only used when h=1
  8.     $inset = $size / 18;
  9.     $scaled = $size * 8 / 9;
  10.    
  11.     if(isset($_GET['n'])){
  12.         $url = "http://s3.amazonaws.com/MinecraftSkins/".$_GET['n'].".png";
  13.     } else {
  14.         $url = "http://s3.amazonaws.com/MinecraftSkins/char.png";
  15.     }
  16.    
  17.     if(getimagesize($url)){
  18.         $image = imagecreatefrompng($url);
  19.         $output = imagecreatetruecolor($size, $size);                                                                                      
  20.        
  21.         if($helm){
  22.             $output_image = imagecopyresampled($output, $image, $inset, $inset, 8, 8, $scaled, $scaled, 8, 8);
  23.             $output_image_helm = imagecopyresampled($output, $image, 0, 0, 40, 8, $size, $size, 8, 8);
  24.         } else {
  25.             $output_image = imagecopyresampled($output, $image, 0, 0, 8, 8, $size, $size, 8, 8);
  26.         }
  27.     } else {
  28.         $image = imagecreatefrompng("http://s3.amazonaws.com/MinecraftSkins/char.png");
  29.         $output = imagecreatetruecolor($size, $size);
  30.  
  31.         // Steve has no helm, but make sure the faces are scaled to the same size for custom and non-custom
  32.         // skins when helms are enabled
  33.         if($helm){
  34.             $output_image = imagecopyresampled($output, $image, $inset, $inset, 8, 8, $scaled, $scaled, 8, 8);
  35.         } else {
  36.             $output_image = imagecopyresampled($output, $image, 0, 0, 8, 8, $size, $size, 8, 8);
  37.         }
  38.     }
  39.    
  40.     imagepng($output);
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement