large_image_source_vips package


large_image_source_vips.girder_source module

class large_image_source_vips.girder_source.VipsGirderTileSource(*args, **kwargs)[source]

Bases: VipsFileTileSource, GirderTileSource

Vips large_image tile source for Girder.

Initialize the tile class. See the base class for other available parameters.


path – a filesystem path for the tile source.

cacheName = 'tilesource'
name = 'vips'

Name of the tile source

Module contents

class large_image_source_vips.VipsFileTileSource(*args, **kwargs)[source]

Bases: FileTileSource

Provides tile access to any libvips compatible file.

Initialize the tile class. See the base class for other available parameters.


path – a filesystem path for the tile source.

addTile(tile, x=0, y=0, mask=None, interpretation=None)[source]

Add a numpy or image tile to the image, expanding the image as needed to accommodate it.

  • tile – a numpy array, PIL Image, vips image, or a binary string with an image. The numpy array can have 2 or 3 dimensions.

  • x – location in destination for upper-left corner.

  • y – location in destination for upper-left corner.

  • mask – a 2-d numpy array (or 3-d if the last dimension is 1). If specified, areas where the mask is false will not be altered.

  • interpretation – one of the pyvips.enums.Interpretation or ‘L’, ‘LA’, ‘RGB’, “RGBA’. This defaults to RGB/RGBA for 3/4 channel images and L/LA for 1/2 channels. The special value ‘pixelmap’ will convert a 1 channel integer to a 3 channel RGB map. For images which are not 1 or 3 bands with an optional alpha, specify MULTIBAND. In this case, the mask option cannot be used.

property bandFormat
property bandRanges
cacheName = 'tilesource'
property crop

Crop only applies to the output file, not the internal data access.

It consists of x, y, w, h in pixels.

extensions = {None: 5}

A dictionary of known file extensions and the SourcePriority given to each. It must contain a None key with a priority for the tile source when the extension does not match.


Return additional known metadata about the tile source. Data returned from this method is not guaranteed to be in any particular format or have specific values.


a dictionary of data or None.


Return a dictionary of metadata containing levels, sizeX, sizeY, tileWidth, tileHeight, magnification, mm_x, mm_y, and frames.


metadata dictionary.


Get the magnification at a particular level.


magnification, width of a pixel in mm, height of a pixel in mm.


Return a string reflecting the state of the tile source. This is used as part of a cache key when hashing function return values.


a string hash value of the source state.

getTile(x, y, z, pilImageAllowed=False, numpyAllowed=False, **kwargs)[source]

Get a tile from a tile source, returning it as an binary image, a PIL image, or a numpy array.

  • x – the 0-based x position of the tile on the specified z level. 0 is left.

  • y – the 0-based y position of the tile on the specified z level. 0 is top.

  • z – the z level of the tile. May range from [0, self.levels], where 0 is the lowest resolution, single tile for the whole source.

  • pilImageAllowed – True if a PIL image may be returned.

  • numpyAllowed – True if a numpy image may be returned. ‘always’ to return a numpy array.

  • sparseFallback – if False and a tile doesn’t exist, raise an error. If True, check if a lower resolution tile exists, and, if so, interpolate the needed data for this tile.

  • frame – the frame number within the tile source. None is the same as 0 for multi-frame sources.


either a numpy array, a PIL image, or a memory object with an image file.

mimeTypes = {None: 8}

A dictionary of common mime-types handled by the source and the SourcePriority given to each. This are used in place of or in additional to extensions.

property minHeight
property minWidth
property mm_x
property mm_y
name = 'vipsfile'

Name of the tile source

write(path, lossy=True, alpha=True, overwriteAllowed=True, vips_kwargs=None)[source]

Output the current image to a file.

  • path – output path.

  • lossy – if false, emit a lossless file.

  • alpha – True if an alpha channel is allowed.

  • overwriteAllowed – if False, raise an exception if the output path exists.

  • vips_kwargs – if not None, save the image using these kwargs to the write_to_file function instead of the automatically chosen ones. In this case, lossy is ignored and all vips options must be manually specified.

large_image_source_vips.canRead(*args, **kwargs)[source]

Check if an input can be read by the module class.*args, **kwargs)[source]

Create a new image, collecting the results from patches of numpy arrays or smaller images.*args, **kwargs)[source]

Create an instance of the module class.