zooui.tilesystem.tiler module¶
ZooUI Tiler System - Tile and Tile structure creation.
- class zooui.tilesystem.tiler.Tiler(infile, media_id=None, filext='jpg', tilesize=256)[source]¶
Bases:
Thread- Constructor:
Tiler(infile, media_id, filext, tilesize)
- Parameters :
infile : str media_id : Optional[str] filext : str tilesize : int
Tiler(infile, media_id, filext, tilesize) –> None
Tiler objects are used for tiling images.
- Constructor:
Tiler(infile, media_id, filext, tilesize)
- Parameters :
infile : str media_id : Optional[str] filext : str tilesize : int
Tiler(infile, media_id, filext, tilesize) –> None
Create a new Tiler for tiling the media given by media_id with the image given by infile.
If media_id is omitted, it will be set to infile.
Tiles will be saved in the format indicated by filext and with the dimensions given by tilesize.
images are tiled with the following procedure: the number of tiles to cover a row of the image is calculated, the last tile of the row is of the minimum width to finish the image and standard height (256). the last row tiles are of the minimum height to finish the image and the last tile is of the minimum size to cover the bottom right corner of the image. The example below will have a self.numtiles_across_total = 2:
+-------+ | t1 |t2| | | | |----+--| | t3 |t4| +-------+
- __calculate_maxtilelevel()¶
- Method :
__calculate_maxtilelevel()
- Parameters :
None
__calculate_maxtilelevel() –> int
Calculate the maxtilelevel, which is the smallest non-negative integer such that: tilesize * (1 << maxtilelevel) >= max(width, height) i.e. if tilelevel 0 contains a single tile, then the tiles in maxtilelevel are the same resolution as the input image
- __calculate_numtiles()¶
- Method :
__calculate_numtiles()
- Parameters :
None
__calculate_numtiles() –> int
Calculate the total number of tiles required.
- __load_row_from_file(row)¶
- Method :
__load_row_from_file(row)
- Parameters :
row : int
__load_row_from_file(row) –> Optional[List[Tile]]
Load the requested row from the image file.
Precondition: calls to this function must take consecutive values for row i.e. the first call must have row=0, then the next call must have row=1, etc.
- __mergerows(row_a, row_b=None)¶
- Method :
__mergerows(row_a, row_b)
- Parameters :
row_a : Optional[List[Tile]] row_b : Optional[List[Tile]]
__mergerows(row_a, row_b) –> Optional[List[Tile]]
Merge blocks of 4 tiles (or blocks of 2 if row_b is None) into a single tile.
- __savetile(tile, tilelevel, row, col)¶
- Method :
__savetile(tile, tilelevel, row, col)
- Parameters :
tile : Tile tilelevel : int row : int col : int
__savetile(tile, tilelevel, row, col) –> None
Save the given tile to disk.
- __tiles(tilelevel=0, row=0)¶
- Method :
__tiles(tilelevel, row)
- Parameters :
tilelevel : int row : int
__tiles(tilelevel, row) –> Optional[List[Tile]]
Recursive function which retrieves the tiles in the given row, saves them, scales each dimension by 1/2, and then returns them as a list.
As the function is recursive, all higher-resolution sub-tiles contained within the requested tile will be saved in the process. Therefore, requesting row 0 from tilelevel 0 will result in the entire image being tiled.
- _scanline()[source]¶
- Method :
Tiler._scanline()
- Parameters :
None
Tiler._scanline() –> str
Return string containing pixels of the next row.
- property progress¶
- Property:
Tiler.progress
- Parameters :
None
Tiler.progress –> float
Tiling progress ranging from 0.0 to 1.0. A value of 1.0 indicates that the tiling has completely finished.
- class zooui.tilesystem.tiler.TilingHandle(future, infile, media_id=None)[source]¶
Bases:
objectA handle to a running or completed tiling process.
This class wraps a Future and provides a similar interface to the thread-based Tiler class, with progress and error properties.
Create a new TilingHandle.
- Parameters:
future – The Future object from the process pool
infile – Path to the source file
media_id – Media identifier for tile storage
- property error¶
Return the error message if tiling failed, None otherwise.
- property progress¶
Return the tiling progress.
Since process-based tiling doesn’t support incremental progress, this returns 0.0 while running and 1.0 when done.
- zooui.tilesystem.tiler.submit_tiling(infile, media_id=None, filext='jpg', tilesize=256)[source]¶
Submit a tiling job to run in a separate process.
- Parameters:
infile – Path to the source PPM file
media_id – Media identifier for tile storage (defaults to infile)
filext – Tile file extension (‘jpg’ or ‘png’)
tilesize – Tile size in pixels
- Returns:
A Future object that will contain the tiling result