Python 3 Script to Split an Image into Multiple Images (Rows & Columns) and Download it in Command Line

 

Project description

split-image

Downloads Downloads

Quickly split an image into rows and columns (tiles).

split-image is a Python package that you can use from the command line to split an image into tiles.

Installation

pip install split-image

Usage

From the command line:

 

 

 

 

Basic examples

split-image cat.png 2 2

This splits the cat.png image in 4 tiles (2 rows and 2 columns).

split-image bridge.png 3 4 -s

This splits the bridge.png image in 12 tiles (3 rows and 4 columns). The -square arguments resizes the image into a square before splitting it. The background color used to fill the square is determined from the image automatically.

Other options

Reverse split:

split-image bridge.jpg 2 2 -r

Will attempt to merge similarly named image tiles to one image. So, if you have these images in the current directory:

  • bridge_0.jpg
  • bridge_1.jpg
  • bridge_2.jpg
  • bridge_3.jpg

they will be merged according to their file name:

Cleanup:

split-image test.jpg 4 2 --cleanup

Will delete the original image after the process.

Leave a Reply