小丁的屋舍
PHP | Minecraft 皮肤文件中获取头像
2022-04-05
查看标签
10213次浏览

Minecraft 皮肤文件中获取头像可用于论坛头像绑定,增强落地化

// 此处以 Skinme 皮肤站的皮肤为例
$skin = "http://www.skinme.cc/uniskin/textures/{$id}";
$skin = file_get_contents($skin);
$im = imagecreatefromstring($skin);
$size = 300; // 头像尺寸
$view = 'f'; // 视角方向
// f: 正面
// b: 背面(后脑勺)
// l: 左侧
// r: 右侧
$av = imagecreatetruecolor($size, $size);
$x = array('f' => 8, 'l' => 16, 'r' => 0, 'b' => 24);

// 裁剪头像
imagecopyresized($av, $im, 0, 0, $x[$view], 8, $size, $size, 8, 8);
// 修复 BUG
imagecolortransparent($im, imagecolorat($im, 63, 0));
// 添加头饰
imagecopyresized($av, $im, 0, 0, $x[$view] + 32, 8, $size, $size, 8, 8);

header('Content-type: image/png');
imagepng($av);
imagedestroy($im);
imagedestroy($av);
exit();

来源:sunxyw

留下足迹请遵守法律规则哦~
April 26th, 2022 at 10:06 am
April 26th, 2022 at 10:06 am

评论区被机器人占领了

访客
May 1st, 2022 at 10:28 am小丁
May 1st, 2022 at 10:28 am
@。 

没时间管理博客了!随他去吧。高考完在整

博主
April 26th, 2022 at 10:05 am
April 26th, 2022 at 10:05 am

你是什么鬼东西

访客