Sprite Sheet Generator
Arrange multiple images into a downloadable PNG sprite sheet
Sprite Sheet Generator — what it does
Arrange multiple images into a single PNG sprite sheet with a column count, padding and background colour of your choosing. Sprite sheets exist because one image request is cheaper than twenty, and because a game engine or CSS rule can address each frame by its position in the grid.
Worked example
Five 400 × 400 icons (the logo fixture chosen five times under different names) arranged in 4 columns with 4 px padding on white; the other rows are derived from the code.
| Input | Columns, padding | Output |
|---|---|---|
| 5 icons, 400 × 400 each | 4, 4 px | sprite-sheet.png, 1620 × 812; 2 rows, cell 400 × 400 |
| 12 animation frames, 64 × 64 each | 6, 0 px | sprite-sheet.png, 384 × 128; 2 rows, no padding |
| 3 icons of 32 × 32, 48 × 48 and 64 × 64 | 4, 2 px | sprite-sheet.png, 200 × 68; columns clamped to 3, every icon drawn at 64 × 64 |
Width = columns × cell width + (columns + 1) × padding, so 4 × 400 + 5 × 4 = 1620; the cell is the largest width and largest height among the inputs. The status line shows the sheet size and the download is always sprite-sheet.png.
When this tool helps
- Packing animation frames into one sheet for a game engine or canvas animation.
- Combining interface icons into a single file addressed by CSS background position.
- Bundling a set of small images to reduce the number of requests a page makes.
How to use it
- Choose the images in frame order.
- Set the number of columns.
- Set padding and background colour.
- Generate and download the sprite sheet.
Accuracy, limits, and good practice
- Frames of identical size make the grid predictable, which is what lets code compute each frame's offset arithmetically.
- Padding prevents neighbouring frames bleeding into each other when the sheet is scaled or filtered, at the cost of a slightly larger file.
- Note the column count and frame size once generated — your code needs both to address the right cell.
Frequently asked questions
How do I use a sprite sheet in CSS?
Set the sheet as a background image and shift background-position by multiples of the frame size to show each icon.
Are sprite sheets still worth it on the web?
Less so under HTTP/2, where parallel requests are cheap. They remain standard for game animation frames.
Should frames be the same size?
For animation and code-driven addressing, yes. Uneven frames need a coordinate map rather than simple arithmetic.
What happens when my images are different sizes?
Every image is scaled to fill the cell — the largest width by the largest height — and centred, so smaller icons are enlarged, not just padded. For crisp output, give the tool frames that are already the same size.
What if I ask for more columns than I have images?
The column count is clamped to the number of images, so 3 images with 4 columns gives one row of 3. A blank or zero column count falls back to 4.
Related tools on this site
- Batch Image Watermark — Apply one text watermark to multiple images
- Image Color Picker — Click an image to identify HEX and RGB colors
- Remove Image Metadata — Re-encode images to remove EXIF and location data
Further reading: Getting images ready for the web, email and social media
Everything above runs inside this page. Sprite Sheet Generator needs no account, no upload, and no server round trip — close the tab and nothing is left behind.
圖片精靈圖生成器能做什麼
把多張圖片排成單一 PNG 精靈圖,欄數、間距與背景色由你決定。精靈圖之所以存在,是因為一次圖片請求比二十次便宜,也因為遊戲引擎或 CSS 規則能依格線位置指定每一格。
實際範例
五個 400 × 400 的圖示(同一個 logo 範例檔以五個不同檔名選取五次)排成 4 欄、4 px 留白、白底;其餘兩列依程式碼推算。
| 來源檔案 | 欄數、留白 | 下載檔案 |
|---|---|---|
| 5 個圖示,各 400 × 400 | 4,4 px | sprite-sheet.png,1620 × 812;2 列,格子 400 × 400 |
| 12 張動畫影格,各 64 × 64 | 6,0 px | sprite-sheet.png,384 × 128;2 列,無留白 |
| 3 個圖示,32 × 32、48 × 48、64 × 64 | 4,2 px | sprite-sheet.png,200 × 68;欄數被限制為 3,每個圖示都畫成 64 × 64 |
寬度 = 欄數 × 格寬 + (欄數 + 1)× 留白,所以 4 × 400 + 5 × 4 = 1620;格子取所有來源中最大的寬與最大的高。狀態列顯示成品尺寸,下載檔一律叫 sprite-sheet.png。
什麼時候用得上
- 把動畫影格打包成一張圖,供遊戲引擎或 canvas 動畫使用。
- 把介面圖示合併成單一檔案,用 CSS 背景位置定位。
- 把一組小圖打包,減少頁面發出的請求數。
使用步驟
- 依影格順序選擇圖片。
- 設定欄數。
- 設定間距與背景色。
- 產生並下載精靈圖。
精確度、限制與實務建議
- 尺寸一致的影格能讓格線可預測,程式才能用算術直接算出每格的偏移量。
- 間距可避免縮放或濾鏡時相鄰影格互相滲色,代價是檔案略大。
- 產生後請記下欄數與影格尺寸——程式需要這兩個數字才能定位正確格子。
常見問題
CSS 中怎麼使用精靈圖?
把整張圖設為背景圖,再依影格尺寸的倍數位移 background-position,即可顯示各個圖示。
網頁上還值得用精靈圖嗎?
在 HTTP/2 之下效益較小,因為並行請求成本很低。但它在遊戲動畫影格上仍是標準做法。
影格需要一樣大嗎?
用於動畫與程式定位時需要。尺寸不一的影格需要座標對照表,而非單純算術。
圖片大小不一會怎樣?
每張圖都會被縮放到填滿格子(最大寬 × 最大高)並置中,所以較小的圖示會被放大,不只是補白。想要清晰的成品,請先把影格做成相同尺寸。
欄數設得比圖片數還多會怎樣?
欄數會被限制為圖片數,所以 3 張圖設 4 欄會得到一列 3 張。欄數留空或填 0 會退回 4。
本站相關工具
延伸閱讀: 為網頁、電子郵件與社群媒體準備圖片
以上步驟全部在這個頁面內完成,圖片精靈圖生成器 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。