On this page
How to use it#
- Click Choose images or drop files on the box. Files are sorted by name, so
walk_1.png,walk_2.png… stay in order. - Drag thumbnails to reorder frames; the × button removes one.
- Set Columns (0 picks a near-square layout automatically), Spacing between cells and Padding around the sheet.
- Cell size "Largest frame" fits every frame; "Custom" uses a fixed size and crops or centres frames.
- Check the animation preview, then download the PNG, the JSON frame data, or copy the Pygame loader.
Images are processed in your browser and never uploaded.
Loading the sheet in Pygame#
The copied loader matches your exact layout. It looks like this for four 32 × 32 frames in one row:
FRAME_W, FRAME_H = 32, 32
COLUMNS, ROWS = 4, 1
SPACING, PADDING = 0, 0
FRAME_COUNT = 4
def load_frames(path="spritesheet.png"):
sheet = pygame.image.load(path).convert_alpha()
frames = []
for i in range(FRAME_COUNT):
col, row = i % COLUMNS, i // COLUMNS
x = PADDING + col * (FRAME_W + SPACING)
y = PADDING + row * (FRAME_H + SPACING)
frames.append(sheet.subsurface((x, y, FRAME_W, FRAME_H)).copy())
return framesThen follow the sprite animation tutorial to play the frames at a steady speed.
The JSON format#
{
"image": "spritesheet.png", "width": 128, "height": 32,
"cell": { "w": 32, "h": 32 }, "columns": 4, "rows": 1, "spacing": 0, "padding": 0,
"frames": [ { "index": 0, "name": "walk_1.png", "x": 0, "y": 0, "w": 32, "h": 32 } ]
}Read it with Python's json module when frame positions are irregular or you want frame names in your code.
When to use spacing and padding#
If you scale or rotate frames in Pygame with filtering (smoothscale, rotozoom), neighbouring frames can bleed into each other along the edges. One or two pixels of spacing prevents that. For plain blit and scale, zero spacing is fine.