Skip to content

How to Slice an Image into a Specific Number of Tiles

If you have a target number of tiles in mind, but you don't want to calculate the grid dimensions yourself, you can use the --number-of-tiles option.

The --number-of-tiles Option

Instead of --grid, you can provide --number-of-tiles (or -n) with an integer value. image-slicer will then find the best grid layout to create that many tiles.

Note: The number of tiles must have factors other than 1 and itself. For example, you can't create a grid of 7 tiles.

Example

Let's slice our source image into 8 tiles.

imslice docs/assets/source.png docs/assets/8_tiles --number-of-tiles 8

image-slicer will determine that an 8-tile grid is best arranged as 4 columns and 2 rows.

The Result

Here are the 8 tiles produced by the command:

Tile 0,0 Tile 0,1 Tile 0,2 Tile 0,3
Tile 1,0 Tile 1,1 Tile 1,2 Tile 1,3