1.0.6 • Published 5 months ago

minecraft-skins v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

🧍 minecraft-skins

Module to create 2D renders from Minecraft skins textures.

Technoblade head Technoblade full body

Usage

  1. First, import the module:

    // Using CommonJS
    const { renderFullBody, renderHead } = require("minecraft-skins");
    
    // Using TypeScript or ESM
    import { renderFullBody, renderHead } from "minecraft-skins";
  2. Then, you call the renderFullBody or renderHead 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 to 1.
  • options.layers (optional, boolean): If the renderer should include the layers of the skin. Defaults to true.

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.

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago