Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. <?php
  2. $path_skin = $_SERVER['DOCUMENT_ROOT'].'/uploads/minecraft/skins/';
  3. $path_cloak = $_SERVER['DOCUMENT_ROOT'].'/uploads/minecraft/cloaks/';
  4. function imageflip2(&$result, &$img, $rx = 0, $ry = 0, $x = 0, $y = 0, $size_x = null, $size_y = null) {
  5. if ($size_x < 1) $size_x = imagesx($img);
  6. if ($size_y < 1) $size_y = imagesy($img);
  7. imagecopyresampled($result, $img, $rx, $ry, ($x + $size_x-1), $y, $size_x, $size_y, 0-$size_x, $size_y);
  8. }
  9.  
  10. if ( !empty($_GET["user_name"]) ) $user_name = $_GET["user_name"];
  11. if (!file_exists($path_skin."$user_name.png")) $user_name = "default";
  12. if ( !empty($_GET["fx"]) ) $fx = $_GET["fx"];
  13. else $fx = 128;
  14. $fy = $fx*2;
  15.  
  16. $way_skif = $path_skin.$user_name.'.png';
  17. if (!file_exists($way_skif)) $user_name = 'default';
  18. $skif= getimagesize($way_skif);
  19. $h=$skif['0'];
  20. $w=$skif['1'];
  21. $ratio=$h/64;
  22.  
  23. if ( isset($_GET["mode"]) ) $mode=(int)$_GET["mode"];
  24. else $mode = 1;
  25.  
  26.  
  27. header ("Content-type: image/png");
  28.  
  29.  
  30. $way_skin = $path_skin.$user_name.'.png';
  31.  
  32.  
  33. if (!file_exists($way_skin)) $user_name = 'default';
  34.  
  35. $skin = imagecreatefrompng($way_skin);
  36.  
  37. $way_cloak = $path_cloak.$user_name.'.png';
  38. $cloak = imagecreatefrompng($way_cloak);
  39.  
  40. $preview = imagecreatetruecolor(16*$ratio, 32*$ratio);
  41.  
  42. $transparent = imagecolorallocatealpha($preview, 255, 255, 255, 127);
  43. imagefill($preview, 0, 0, $transparent);
  44.  
  45. if ($mode == 1) {
  46.  
  47. if ($way_cloak)
  48. imagecopy($preview, $cloak, 3*$ratio, 8*$ratio, 12*$ratio, 1*$ratio, 10*$ratio, 16*$ratio);
  49.  
  50. //Front skin side render
  51.  
  52. //face
  53. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 8*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  54. //arms
  55. imagecopy($preview, $skin, 0*$ratio, 8*$ratio, 44*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  56. imageflip2($preview, $skin, 12*$ratio, 8*$ratio, 44*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  57. //chest
  58. imagecopy($preview, $skin, 4*$ratio, 8*$ratio, 20*$ratio, 20*$ratio, 8*$ratio, 12*$ratio);
  59. //legs
  60. imagecopy($preview, $skin, 4*$ratio, 20*$ratio, 4*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  61. imageflip2($preview, $skin, 8*$ratio, 20*$ratio, 4*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  62. //hat
  63. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 40*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  64.  
  65.  
  66.  
  67. } else if ($mode == 2) {
  68.  
  69. //Back side render
  70.  
  71. //back body
  72. imagecopy($preview, $skin, 4*$ratio, 8*$ratio, 32*$ratio, 20*$ratio, 8*$ratio, 12*$ratio);
  73. //head back
  74. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 24*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  75. //back arms
  76. imageflip2($preview, $skin, 0*$ratio, 8*$ratio, 52*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  77. imagecopy($preview, $skin, 12*$ratio, 8*$ratio, 52*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  78.  
  79. //back legs
  80. imageflip2($preview, $skin, 4*$ratio, 20*$ratio, 12*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  81. imagecopy($preview, $skin, 8*$ratio, 20*$ratio, 12*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  82.  
  83. //hat back
  84. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 56*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  85.  
  86. if ($way_cloak)
  87. imagecopy($preview, $cloak, 3*$ratio, 8*$ratio, 1*$ratio, 1*$ratio, 10*$ratio, 16*$ratio);
  88.  
  89. } else if ($mode == 3) {
  90.  
  91. if ($way_cloak)
  92. imagecopy($preview, $cloak, 3*$ratio, 8*$ratio, 12*$ratio, 1*$ratio, 10*$ratio, 16*$ratio);
  93.  
  94. } else if ($mode == 4) {
  95.  
  96. if ($way_cloak)
  97. imagecopy($preview, $cloak, 3*$ratio, 8*$ratio, 1*$ratio, 1*$ratio, 10*$ratio, 16*$ratio);
  98.  
  99. } else if ($mode == 5) {
  100.  
  101. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 8*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  102. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 40*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  103.  
  104. } else if ($mode == 6) {
  105.  
  106. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 24*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  107. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 56*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  108.  
  109. } else if ($mode == 7) {
  110.  
  111. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 8*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  112. //arms
  113. imagecopy($preview, $skin, 0*$ratio, 8*$ratio, 44*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  114. imageflip2($preview, $skin, 12*$ratio, 8*$ratio, 44*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  115. //chest
  116. imagecopy($preview, $skin, 4*$ratio, 8*$ratio, 20*$ratio, 20*$ratio, 8*$ratio, 12*$ratio);
  117. //legs
  118. imagecopy($preview, $skin, 4*$ratio, 20*$ratio, 4*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  119. imageflip2($preview, $skin, 8*$ratio, 20*$ratio, 4*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  120. //hat
  121. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 40*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  122.  
  123. } else if ($mode == 8) {
  124.  
  125. imagecopy($preview, $skin, 4*$ratio, 8*$ratio, 32*$ratio, 20*$ratio, 8*$ratio, 12*$ratio);
  126. //head back
  127. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 24*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  128. //back arms
  129. imageflip2($preview, $skin, 0*$ratio, 8*$ratio, 52*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  130. imagecopy($preview, $skin, 12*$ratio, 8*$ratio, 52*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  131.  
  132. //back legs
  133. imageflip2($preview, $skin, 4*$ratio, 20*$ratio, 12*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  134. imagecopy($preview, $skin, 8*$ratio, 20*$ratio, 12*$ratio, 20*$ratio, 4*$ratio, 12*$ratio);
  135.  
  136. //hat back
  137. imagecopy($preview, $skin, 4*$ratio, 0*$ratio, 56*$ratio, 8*$ratio, 8*$ratio, 8*$ratio);
  138.  
  139. }
  140.  
  141. $fullsize = imagecreatetruecolor($fx,$fy);
  142.  
  143. imagesavealpha($fullsize, true);
  144. $transparent = imagecolorallocatealpha($fullsize, 255, 255, 255, 127);
  145. imagefill($fullsize, 0, 0, $transparent);
  146.  
  147. imagecopyresized($fullsize, $preview, 0, 0, 0, 0, imagesx($fullsize), imagesy($fullsize), imagesx($preview), imagesy($preview));
  148.  
  149.  
  150. imagepng($fullsize);
  151.  
  152. imagedestroy($fullsize);
  153. imagedestroy($preview);
  154. imagedestroy($skin);
  155. if ($way_cloak) imagedestroy($cloak);
  156. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement