image_slicer package¶
Submodules¶
image_slicer.helpers module¶
Helper functions for image_slicer
.
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
¶
-
property
-
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_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 ofImage
instances. @paramwidth
- Optional, width of combined image. @paramheight
- Optional, height of combined image. @returnImage
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.