Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions staticmap/staticmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from math import sqrt, log, tan, pi, cos, ceil, floor, atan, sinh

import requests
from PIL import Image, ImageDraw
from PIL import Image, ImageDraw, ImageColor
from concurrent.futures import ThreadPoolExecutor


Expand Down Expand Up @@ -274,7 +274,9 @@ def render(self, zoom=None, center=None):
self.x_center = _lon_to_x(lon_center, self.zoom)
self.y_center = _lat_to_y(lat_center, self.zoom)

image = Image.new('RGB', (self.width, self.height), self.background_color)
rgba = ImageColor.getrgb(self.background_color)
image_mode = 'RGB' if len(rgba) < 4 else 'RGBA'
image = Image.new(image_mode, (self.width, self.height), self.background_color)

self._draw_base_layer(image)
self._draw_features(image)
Expand Down