Skip to main content
Glama

get_frame_data

Extract pixel data from animation frames as 2D arrays for analysis, manipulation, or export in pixel art projects.

Instructions

Get all pixel data from a frame as a 2D array

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject identifier
layerIndexNoLayer index (default: 0)
frameIndexNoFrame index (default: 0)

Implementation Reference

  • The implementation of the 'get_frame_data' tool logic, which retrieves pixels from a specific frame and converts them into a 2D array of color strings.
    private getFrameDataTool(
      projectId: string,
      layerIndex: number,
      frameIndex: number
    ): object {
      const piskel = this.getProject(projectId);
      const frame = this.getFrame(projectId, layerIndex, frameIndex);
      const width = piskel.getWidth();
      const height = piskel.getHeight();
      const pixels = frame.getPixels();
    
      const data: string[][] = [];
      for (let y = 0; y < height; y++) {
        const row: string[] = [];
        for (let x = 0; x < width; x++) {
          const color = pixels[y * width + x];
          row.push(color === 0 ? 'transparent' : intToHex(color));
        }
        data.push(row);
      }
    
      return { width, height, data };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yafeiaa/piskel-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server