I couldn´t find any solution to open an image from an indirect URL. The URL is like this: https://mytestsitexyz.de/image.php/image/test?namespace=mytest&x=4711
This will give me a random png image.
Please inform how I can open a PIL image from such an URL. Thanks.I checked How do I read image data from a URL in Python? but it doesn´t solve the problem.
I tried following:
First try:
fd = urllib.urlopen(url)
image_file = io.BytesIO(fd.read())
img = Image.open(image_file)
Error: TypeError: cannot serialize '_io.BufferedReader' object
Second try:
img = Image.open(requests.get(url, stream=True).raw)
Error: <class 'OSError'> cannot identify image file <_io.BytesIO object at 0xb3ba28d0>
third try:
response = requests.get(url)
img = Image.open(BytesIO(response.content))
error: <class 'OSError'> cannot identify image file <_io.BytesIO object at 0xb2e2ae70>
I think the problem is the URL. It isn´t an URL for a direct image file, but it is a PHP that provids an image.
Thanks for helping.