Python / PIL: Create and save image from data uri

To expand on the comment from Stephen Emslie, in Python 3 this works and is less code:

data="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUAAAhwAAAFoCAYAAAA......."
response = urllib.request.urlopen(data)
with open('image.jpg', 'wb') as f:
    f.write(response.file.read())

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)