-
Notifications
You must be signed in to change notification settings - Fork 27
Convert skin or cape from png to config
ace edited this page May 31, 2023
·
4 revisions
- Copy the below script and save as
skin.php
- Copy png files to the same directory as the script
- Execute the script
php skin.php
- It will create a text file for each png file
- Copy contents of text file(s) into config
Skin
Data
field
<?php
function toHex($img) : string {
$bytes = "";
for ($y = 0; $y < imagesy($img); $y++) {
for ($x = 0; $x < imagesx($img); $x++) {
$rgba = @imagecolorat($img, $x, $y);
$a = ((~($rgba >> 24)) << 1) & 0xff;
$r = ($rgba >> 16) & 0xff;
$g = ($rgba >> 8) & 0xff;
$b = $rgba & 0xff;
$bytes .= chr($r) . chr($g) . chr($b) . chr($a);
}
}
@imagedestroy($img);
return bin2hex($bytes);
}
foreach(new IteratorIterator(new DirectoryIterator(".")) as $fileInfo)
if(strtolower($fileInfo->getExtension()) === "png")
file_put_contents($fileInfo->getBasename().".txt",toHex(imagecreatefrompng($fileInfo->getBasename())));