def __init__(self, image, coordinates, *args, **kwargs): """Construct a Mapviz object :param coordinates: property to determine image coordinates (UL, UR, LR, LL). EX. [[-80.425, 46.437], [-71.516, 46.437], [-71.516, 37.936], [-80.425, 37.936]] :param image: url, local path or a numpy ndarray """ super(ImageViz, self).__init__(None, *args, **kwargs) if type(image) is numpy.ndarray: image = img_encode(image) self.template = 'image' self.image = image self.coordinates = coordinates
def test_img_encode(): image_path = os.path.join(os.path.dirname(__file__), 'mosaic.png') image = imread(image_path) assert img_encode(image).startswith('data:image/png;base64')