image_slicer package

Submodules

image_slicer.helpers module

Helper functions for image_slicer.

image_slicer.helpers.get_basename(filename)[source]

Strip path and extension. Return basename.

image_slicer.helpers.get_columns_rows(filenames)[source]

Derive number of columns and rows from filenames.

image_slicer.helpers.open_images(directory)[source]

Open all images in a directory. Return tuple of Image instances.

image_slicer.main module

class image_slicer.main.Tile(image, number, position, coords, filename=None)[source]

Bases: object

Represents a single tile.

property basename

Strip path and extension. Return base filename.

property column
generate_filename(directory='/home/runner/work/image_slicer/image_slicer/docs', prefix='tile', format='png', path=True)[source]

Construct and return a filename for this tile.

property row
save(filename=None, format='png')[source]
image_slicer.main.calc_columns_rows(n)[source]

Calculate the number of columns and rows required to divide an image into n parts.

Return a tuple of integers in the format (num_columns, num_rows)

image_slicer.main.get_combined_size(tiles)[source]

Calculate combined size of tiles.

image_slicer.main.get_image_column_row(filename)[source]

Determine column and row position for filename.

image_slicer.main.join(tiles, width=0, height=0)[source]

@param tiles - Tuple of Image instances. @param width - Optional, width of combined image. @param height - Optional, height of combined image. @return Image instance.

image_slicer.main.open_images_in(directory)[source]

Open all images in a directory. Return tuple of Tile instances.

image_slicer.main.save_tiles(tiles, prefix='', directory='/home/runner/work/image_slicer/image_slicer/docs', format='png')[source]
Write image files to disk. Create specified folder(s) if they

don’t exist. Return list of Tile instance.

Args:

tiles (list): List, tuple or set of Tile objects to save. prefix (str): Filename prefix of saved tiles.

Kwargs:

directory (str): Directory to save tiles. Created if non-existant.

Returns:

Tuple of Tile instances.

image_slicer.main.slice(filename, number_tiles=None, col=None, row=None, save=True, DecompressionBombWarning=True)[source]

Split an image into a specified number of tiles.

Args:

filename (str): The filename of the image to split. number_tiles (int): The number of tiles required.

Kwargs:

save (bool): Whether or not to save tiles to disk. DecompressionBombWarning (bool): Whether to suppress Pillow DecompressionBombWarning

Returns:

Tuple of Tile instances.

image_slicer.main.validate_image(image, number_tiles)[source]

Basic sanity checks prior to performing a split.

image_slicer.main.validate_image_col_row(image, col, row)[source]

Basic checks for columns and rows values

Module contents

Top-level package for Image Slicer.

image_slicer.get_module_version()[source]