From d903f6ac885f15db69d6c0ca7cd36d0a6b906a7f Mon Sep 17 00:00:00 2001 From: Allan Martins Date: Thu, 27 Dec 2018 15:39:23 +0100 Subject: [PATCH] Added the option to pass the Image object into IconMaker. This is needed if you want to put 1000's images in the map. PIL will complain about too many open files. With this option. You create one copy of the image object and pass the same reference. --- staticmap/staticmap.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/staticmap/staticmap.py b/staticmap/staticmap.py index 15ed5a2..50e63ed 100644 --- a/staticmap/staticmap.py +++ b/staticmap/staticmap.py @@ -62,19 +62,19 @@ def extent_px(self): class IconMarker: - def __init__(self, coord, file_path, offset_x, offset_y): + def __init__(self, coord, file_path_or_img , offset_x, offset_y): """ :param coord: a lon-lat pair, eg (175.0, 0.0) :type coord: tuple :param file_path: path to icon - :type file_path: str + :type file_path_or_img: str / Image :param offset_x: x position of the tip of the icon. relative to left bottom, in pixel :type offset_x: int :param offset_y: y position of the tip of the icon. relative to left bottom, in pixel :type offset_y: int """ self.coord = coord - self.img = Image.open(file_path, 'r') + self.img = Image.open(file_path_or_img, 'r') if type(file_path_or_img) == type("") else file_path_or_img self.offset = (offset_x, offset_y) @property