Image Slicer

Slice images into tiles and rejoin them. Compatible with Python 2.7+, 3.4+. Relies on Pillow for image manipulation.

Installation

To download and install the latest release:

$ pip install image_slicer

Or, for developers, to get the bleeding-edge, unreleased version:

$ pip install -e git://github.com/samdobson/image-slicer.git#egg=image-slicer

Run tests:

$ python setup.py test

Command-line tools

Two CLI tools are provided: slice-image and join-image. These will be added to your PATH and can thus be called from any directory.

slice-image

Usage:

$ slice-image image num_tiles

Unless an output directory is specified with --dir or -d tiles will be saved in the same location as the image. The original filename will be used as a prefix unless overridden with --prefix or -p.

join-tiles

Usage:

$ join-tiles tile

Any of the tile images can be used as an argument - the others will be discovered automatically. Unless an output directory is specified with --dir or -d the image will be saved in the same location as the tiles. The prefix of the tiles will be used to save the image unless this is overridden with --filename or -f.

Methods

See all functions.

Methodology

Images are always split into exactly equal parts, even if this means creating more than the requested number.

Note

In future versions this behaviour will be overridable.

Tile filenames are appended with a 2-digit representation of the tile’s grid position (e.g image_03_02.jpg).

Limitations

The maximum number of tiles that can be produced is 9800. This is an arbitrary limit which ensures that row and column numbers can be conveniently represented by two digits. Increasing it would break get_columns_rows() and consequently, join_tiles().

Development

Fork the repository on GitHub, commit your changes and send a pull request.

Troubleshooting

If the following doesn’t help then open an issue.

IOError: decoder %s not available

You are missing some of the libraries required for Pillow. The Pillow documentation will be able to help you. Try starting with the platform-specific instructions.

Dependencies

Just one: Pillow. It will be installed automatically by pip or python setup.py.

Indices and tables