Manipuler des tuiles avec PIL

Manipuler des tuiles avec PIL #

import requests
from PIL import Image
import io
url = "https://tile.openweathermap.org/map/temp/5/{x}/{y}.png?appid=cc632d052631a2d2e590f930e6873b6e"
# url2 = "https://tile.openstreetmap.org/map/temp/5/{x}/{y}.png"
liste = [url.format(x=x, y=y) for x in range(15, 17) for y in range(15, 17)]
# liste2 = [url2.format(x=x, y=y) for x in range(15, 17) for y in range(15, 17)]

liste_im = []
for l in liste:
    r = requests.get(l)
    i = Image.open(io.BytesIO(r.content))
    liste_im.append(i)

w, h = liste_im[0].size

new_im = Image.new('RGB', (w * 2, h * 2))
new_im.paste(liste_im[0], (0,0))
new_im.paste(liste_im[1], (0,h))
new_im.paste(liste_im[2], (w,0))
new_im.paste(liste_im[3], (w,h))

new_im.show()