Package mapproxy :: Package core :: Module image
[hide private]
[frames] | no frames]

Module image

source code

Image and tile manipulation (transforming, merging, etc).
Classes [hide private]
  LayerMerger
Merge multiple layers into one image.
  ImageSource
This class wraps either a PIL image, a file-like object, or a file name.
  ReadBufWrapper
This class wraps everything with a read method and adds support for seek, etc.
  MessageImage
Base class for text rendering in images (for watermarks, exception images, etc.)
  ExceptionImage
Image for exceptions.
  WatermarkImage
Image with large, faded message.
  AttributionImage
Image with attribution information.
  TileMerger
Merge multiple tiles into one image.
  TileSplitter
Splits a large image into multiple tiles.
  ImageTransformer
Transform images between different bbox and spatial reference systems.
  TiledImage
An image built-up from multiple tiles.
Functions [hide private]
ImageSource
merge_images(images, format='png', size=None, transparent=True)
Merge multiple images into one.
source code
 
img_to_buf(img, format='png', paletted=None) source code
 
quantize(img, colors=256, alpha=False, defaults=None) source code
 
filter_format(format) source code
 
font_file(font_name) source code
ImageSource
message_image(message, size, format='png', bgcolor='#ffffff', transparent=False)
Creates an image with text (message).
source code
ImageSource
attribution_image(message, size, format='png', transparent=False, inverse=False)
Creates an image with text attribution (message).
source code
 
_luminance(color)
Returns the luminance of a RGB tuple.
source code
 
griddify(quad, steps)
Divides a box (quad) into multiple boxes (steps x steps).
source code
 
is_single_color_image(image)
Checks if the image contains only one color.
source code
Variables [hide private]
  _pil_ttf_support = True
  log = logging.getLogger(__name__)
  image_filter = {'bicubic': 3, 'bilinear': 2, 'nearest': 0}
Function Details [hide private]

merge_images(images, format='png', size=None, transparent=True)

source code 
Merge multiple images into one.
Parameters:
  • images - list of ImageSource, bottom image first
  • format - the format of the output ImageSource
  • size - size of the merged image, if None the size of the first image is used
Returns: ImageSource

message_image(message, size, format='png', bgcolor='#ffffff', transparent=False)

source code 

Creates an image with text (message). This can be used to create in_image exceptions.

For dark bgcolor the font color is white, otherwise black.

Parameters:
  • message - the message to put in the image
  • size - the size of the output image
  • format - the output format of the image
  • bgcolor - the background color of the image
  • transparent - if True and the format supports it, return a transparent image
Returns: ImageSource

attribution_image(message, size, format='png', transparent=False, inverse=False)

source code 
Creates an image with text attribution (message).
Parameters:
  • message - the message to put in the image
  • size - the size of the output image
  • format - the output format of the image
  • inverse - if true, write white text
  • transparent - if True and the format supports it, return a transparent image
Returns: ImageSource

_luminance(color)

source code 
Returns the luminance of a RGB tuple. Uses ITU-R 601-2 luma transform.

is_single_color_image(image)

source code 
Checks if the image contains only one color. Returns False if it contains more than one color, else the color-tuple of the single color.