Skip to main content

A package that lets you quickly split an image into rows and columns (tiles).

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:

split-image [-h] [-s] image_path rows cols

As a regular module import:

from split_image import split_image

split_image(image_path, rows, cols, should_square, should_cleanup, [output_dir])
# e.g. split_image("bridge.jpg", 2, 2, True, False)

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 cat.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:

  • cat_0.jpg
  • cat_1.jpg
  • cat_2.jpg
  • cat_3.jpg

they will be merged according to their file name:

Directory batch process:

split-image image_dir 4 2

Will split all images contained in the image_dir folder.

Cleanup:

split-image test.jpg 4 2 --cleanup

Will delete the original image after the process.

Large images:

split-image test.jpg 4 2 --load-large-images

When working with large images (over 178,956,970 pixels), you may get an error. Pass this flag to override this.

Assign output folder:

split-image test.jpg 2 2 --output-dir <dir-name>

Set the output directory for image tiles (e.g. 'outp/images'). Defaults to the current working directory.

Quiet mode:

split-image test.jpg 3 4 --quiet

Will suppress all log messages (except errors and warnings) when running.

Arguments list:


positional arguments:
  image_path    The path to the image or directory with images to split.
  rows          How many rows to split the image into (horizontal split).
  cols          How many columns to split the image into (vertical split).

optional arguments:
  -h, --help                Show this help message and exit
  -s, --square              If the image should be resized into a square before splitting.
  -r, --reverse             Reverse the splitting process, i.e. merge multiple tiles of an image into one.
  --cleanup                 After splitting or merging, delete the original image/images.
  --load-large-images       Pass this flag for use with really large images.
  --output-dir <dir-name>   Set the output directory for image tiles (e.g. 'outp/images'). 
  --quiet                   Run without printing any messages.

Cat photo by Manja Vitolic on Unsplash

Bridge photo by Lance Asper on Unsplash

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

split_image-2.0.3.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

split_image-2.0.3-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file split_image-2.0.3.tar.gz.

File metadata

  • Download URL: split_image-2.0.3.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for split_image-2.0.3.tar.gz
Algorithm Hash digest
SHA256 4143a5444a0fe6b6b07c60a760a60b25964d7dab1ec9b3d267e42e339f6033e1
MD5 0ad307d1be88c9c68addadaa4a2fe937
BLAKE2b-256 794c0fff455a1099327eed1fcb4637745a3d4baceb8e804bac1d9187853b0c37

See more details on using hashes here.

File details

Details for the file split_image-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: split_image-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for split_image-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 40eb84c1b851c3966d51b27ec210dca5a49a5d682f8b729eb9f710fdc221e9ce
MD5 b900d1828b440e087fa9e6b1e74f2fdc
BLAKE2b-256 b85f450a9e63f6ea6dd7c74079f515c3ae9f33bcdf4165e81467e321d33782a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page