minecraft-skins
v1.0.6
Published
Module to create 2D renders from Minecraft skins textures.
Downloads
27
Readme
🧍 minecraft-skins
Module to create 2D renders from Minecraft skins textures.
Usage
First, import the module:
// Using CommonJS const { renderFullBody, renderHead } = require("minecraft-skins"); // Using TypeScript or ESM import { renderFullBody, renderHead } from "minecraft-skins";
Then, you call the
renderFullBody
orrenderHead
function by passing a valid skin buffer:// Reading a file with a skin texture const skin = await readFile(path.join(__dirname, "skin.png")); // Using promises renderFullBody(skin).then(async (render) => { await writeFile(path.join(__dirname, "skin_full_body.png"), render); }); renderHead(skin).then(async (render) => { await writeFile(path.join(__dirname, "skin_head.png"), render); }); // Using async/await const fullBody = await renderFullBody(skin); await writeFile(path.join(__dirname, "skin_full_body.png"), render); const head = await renderHead(skin); await writeFile(path.join(__dirname, "skin_head.png"), render);
API
renderFullBody
- renderHead
renderFullBody(skin: Buffer | Image, options?: SkinImageOptions) => Promise<Buffer>
// Image class belongs to canvas
Render a 2D full image of the skin's body.
renderHead(skin: Buffer | Image, options?: SkinImageOptions) => Promise<Buffer>
// Image class belongs to canvas
Render a 2D image of the skin's head.
Both functions above have the same following arguments:
- skin (
Buffer | Image
): Skin texture. - options.scale (optional,
number
): Scale of the generated image. Defaults to1
. - options.layers (optional,
boolean
): If the renderer should include the layers of the skin. Defaults totrue
.
Both functions return a Promise
with the Buffer
of the image, or throw an error if something happens during the process.
checkSlim
checkSlim(skin: Buffer | Image) => Promise<boolean>
// Image class belongs to canvas
Utility function to check if exactly the pixel located at x=55
and y=20
on a skin is empty. This usually means that the skin is slim (Alex based skins, 3px
arms). This pixel is near the arm textures, commonly having a color on the classic skin format. Returns a Promise
with a boolean
indicating if the skin is slim or not.