I'm trying to open an image from an URL to then process the image.
The image I'm fetching comes from one raspberry cam through this endpoint
@app.route('/image')
def getImage():
frame = video_camera.get_frame()
return Response((b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n'),
mimetype='multipart/x-mixed-replace; boundary=frame')
Then on another raspberry I'm trying to get the image this way:
r = requests.get('http://'+ip+'/image')
curr_img = Image.open(BytesIO(r.content))
If I open the link in the browser I can see the image, so that part seems to be okay. But I still get this error when using Image.open:
OSError: cannot identify image file <_io.BytesIO object at 0xffff8836dba0>
Any idea?
r.contentto see if it looks like a JPEG.PIL Imageis only going to like that from after the third\r\nonwards, i.e. startingff d8