A sprite sheet that looks tiny on disk can quietly consume four times the GPU memory you budgeted. A 1080x1080 PNG may compress down to a few hundred KB on disk, yet once decoded on the GPU as uncompressed RGBA8 with mipmaps and padded up to the next Power-of-Two container (2048x2048), it jumps past 21 MB of VRAM.

Meanwhile, most web sprite cutters ask studios to upload unreleased character art, VFX sheets, and UI tilesets to remote servers just to extract individual frames.

Here is how we built a 100% browser-local Sprite Sheet Slicer and Texture Atlas Inspector using HTML5 Canvas, an iterative 8-connected breadth-first search (BFS) island detector, and a zero-dependency Store-method ZIP packager:

1. Auditing GPU Power-of-Two & RGBA8 VRAM Before Engine Import

Compressed file size says very little about GPU cost. Inspecting texture readiness locally comes down to three exact checks over the decoded RGBA8 buffer:

Sheet Dimensions POT Check Raw RGBA8 VRAM (W * H * 4) With Mipmaps (~1.33x) Next POT Expansion
256 x 128 PASS 128.0 KB 170.7 KB 256 x 128 (+0%)
300 x 200 Non-POT 234.4 KB 312.5 KB 512 x 256 (+118%)
1024 x 1024 PASS 4.00 MB 5.33 MB 1024 x 1024 (+0%)
1080 x 1080 Non-POT 4.45 MB 5.93 MB 2048 x 2048 (+260%)

Counting alpha === 0 pixels also flags sheets exceeding 65% empty transparent space so artists can switch from sparse fixed grids to tightly packed bounding boxes.

2. Iterative 8-Connected BFS Auto-Island Detection (Zero Stack Overflow)

For irregular sprite sheets without a uniform grid, naive recursive flood-fill crashes with Maximum call stack size exceeded once a single connected character exceeds roughly 10,000 pixels.

Our Auto-Island detector replaces recursion with a flat typed-array queue (Uint8Array foreground mask + Int32Array BFS queue):

  1. 8-connected pixel scanning: Joins diagonal pixel-art outlines (dx, dy in [-1, 0, 1]) above your alphaThreshold (default 10).
  2. Block-pyramid acceleration > 2,000,000 pixels: High-resolution atlases run BFS on a downsampled block grid and refine each bounding box back to exact 1-pixel edges at native resolution.
  3. Merge-Gap & visual row clustering: Merges detached hats, sparks, or floating weapons within mergeGap pixels, filters stray 1-2px compression specks, and clusters slightly uneven vertical offsets (|midY - row.midY| <= max(4, floor(medianH * 0.55))) so animation rows stay ordered left-to-right.
import { detectAlphaIslands, auditAtlasGpu, exportTexturePackerJson, exportCssSprites, exportGodotTres, } from 'sprite-sheet-island-slicer'; const frames = detectAlphaIslands(rgbaBytes, width, height, { alphaThreshold: 10, mergeGap: 2, minPixels: 4, padding: 1, }); const gpu = auditAtlasGpu(width, height, frames, { rgba: rgbaBytes }); console.log({ isPot: gpu.isPowerOfTwo, nextPot: [gpu.nextPotWidth, gpu.nextPotHeight], vramBytes: gpu.vramBytes, wastedAlphaPct: gpu.wastedTransparentPct, }); const godotTres = exportGodotTres(frames, 'res://sprites/cyber-knight.png', { fps: 8 }); 

3. Escaped Engine Exports & Zero-Dependency Client-Side Store ZIP

Directly interpolating frame names or paths into CSS (sprites.css) or Godot 4 .tres (SpriteFrames / AtlasTexture) files breaks parsers if a name contains quotes, newlines, brackets, or braces. The open-source core neutralizes CSS selectors and url('...') tokens with CSS hex escapes, protects TexturePacker maps against __proto__ keys, and escapes Godot string literals and sub-resource IDs.

For multi-frame downloads, PNG slices are already Deflate-compressed, so re-compressing them in JS wastes CPU. Apps66 uses a 164-line Store-method ZIP builder (A66ClientZip with compression method 0, UTF-8 flag 0x0800, and an IEEE 802.3 0xedb88320 CRC32 table) to pack all active PNG slices plus atlas.json inside browser memory in milliseconds.

Try It Locally or Clone the MIT Core