simondlevy / GooMPy

Google Maps in Python
GNU Lesser General Public License v3.0
83 stars 26 forks source link

Conversion of RGBA to RGB #3

Closed mhubrich closed 6 years ago

mhubrich commented 6 years ago

Some of the static maps returned by the Google Maps API are in RGBA mode. These images cannot be saved as .jpg files.

How to replicate this issue:

Code fix:

If PIL images are in mode RGBA, they have to be converted to RGB. This can be done in the goompy/init.py file after line 75:

tile = PIL.Image.open(BytesIO(result))
# Some tiles are in mode `RGBA` and need to be converted
if tile.mode != 'RGB':
        tile = tile.convert('RGB')

I created a pull request.

simondlevy commented 6 years ago

Thanks again!