def get_image_from_url(url): #Open image from url img_url = urllib.request.urlopen(url) img = BytesIO(img_url.read()) img = Image.open(img) mode = img.mode size = img.size data = img.tostring() assert mode in "RGB", "RGBA" #Convert image url to pygame surface surface = pygame.image.fromstring(data, size, mode) return surface