Python/PIL: создание и сохранение изображения из данных uri

У меня такой URL-адрес

data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUUEhQUFRUXGBcVFxgXFxUXGBQYGBYXGBQWFRUYHCggGB0lHBQXITIhJSkrLi4uFyAzODMsNygtLisBCgoKDg0OGxAQGywkICQsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLP/AABEIANcA6gMBEQACEQEDEQH/xAAbAAACAgMBAAAAAAAAAAAAAAAEBQMGAAIHAf/EAEEQAAIBAgQDBQQIBQMDBQEAAAECAwARBBIhMQVBUQYTImFxMoGRoQcUI0JSscHwYnKi0eFDgpIksvEVM1PC4nP/xAAaAQACAwEBAAAAAAAAAAAAAAADBAABAgUG/8QANhEAAgIBBAADBQcEAgMBAQAAAQIAAxEEEiExE0FRBSJhcZEUMoGhsdHhI0LB8FLxBhUzgmL/2gAMAwEAAhEDEQA/ANJMYZXA5Velq3uJL7Nqy08NWwFegI4wJxM5MIxM3SsjibAgZxBrW3MwTgyeFzUC47mS2YYl6wZIXFQTLxJ7ViYxPLVJYgePS6mjVHBmjEGFBD++jueYRBxLVhj4RSb9yESYGsS1mb1OowqyeNKA/JhwMCbstWIMwV96JjiZDcyS2lAHEI3MDxCXFNVPFrFipE1pxsYi44k/dUITZM9bDg1rfiBMIhW1DY5lTdmqgJYkEhogmwJtCtZYy8QpaEZgzaqlTKkkyrknOuzXDSfE3Oq0dGxdxj2quycCWeTQWFPRJYPfWhecPnibRxXNFBxAPGMMIobMZkCFCPShbpoGbqKyZsyWszBmVJQkcqXrSnE3EcsNnpk8jM2h8o6wTaUvYOZZk43oci/ekyismOLJ1OlCI5myeJ4zVYEAWg0hoomM8z0vpQWWGDSBmolYgrDAVXxU4TxFR3JgaHCSS1VBkTn3aniGJixOIaB8pRYJ8pAIeJFySAjmM0lztopNxauddbYljbfLB/DznQoSt6lDD1H4y48H4iuIgjmXQ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BEfG/oukS7YV+8G+RyFf0DaK39NCs0pHKmNV6pW+8JTr4nBy3tJBILrsVax3tm3HnSbKRw0ZUg9Q7hPHZElaRJ5EkkBVyQrB829xYVg5xNcQKHj+KRVQSGygKN9gLD8qJ4annEsXOB3MikoJEuGxGsy5OpqSQmKsmSGRGtZ4kEa4SbUCnNNawYIYC5FK7o4geuupnPZYi4ibzikrT/WEaQf05Y8Ovs11FnOeGtje7kAW5d1GUEnLfUDTYba+lcnXK7XBFPf0jukKrUWYdfWTYzhnfgd8sV9CSgIb/mdbUI6GwfdYSxraz2DD+GYKOEWjjVeupJPqbXNEr0+oQY3jHygrdRQ3JU/WTTYQOQXubA5QLgC4sW82tseXKmkBXs5irWj+wYg+C4NllDAju1vkTW6FlQNblY5SfVj1rl+0/uhQOM5nR0LbssTz1FeC4oRLOLGySMN/P8A81ydm5ROhgkxpg5TOM20fzfrfoPKvTUpitc+g4nH1Fgrche/M+nyjEC21FiExhpViSQCNyGyAFgCQGNgTyBI2rN1y1LuaH09BtbAiTsRhHVpidGeS7JclUbM+YKTysVoXheFSSezkn5xt3D3qAOB18pZcS57xgfKw6ULSHgyteB7pivtFxuLB4d55b5VtoouWY6Ko6XPM6U0TgZiKIXYKPOVvhHZl8W/1vidnZ1+ywwN4sOjbX5O5HP/ABagvm3/AF/v/UM1orGyv8T5n+IeuBxOBu2FYTwAEth5W8SqP/hmPIfhbTzFBfSgndXwfy/iHq1mRtsnvZftjHjZJEVctspTfVSNQehBB8qzTqM8P3Jfo8e8kstNRDqRstaBhK28pFjMBFMmSaNJF6OoYDzF9j5issAe4fkcgznfbD6NFy95gVOa/iiLi2W28Zfn5M1K2aYYykLTrOcWfWcnxELo7K2hUlSLjQg2I0oPht6RvcDP/9k=

Как создать сохранение в качестве обычного изображения?

Ответ 1

Предполагаю, что у вас есть только часть base64, сохраненная в переменной с именем data. Вы хотите использовать модуль Python binascii.

from binascii import a2b_base64

data = 'MY BASE64-ENCODED STRING'
binary_data = a2b_base64(data)

fd = open('image.png', 'wb')
fd.write(binary_data)
fd.close()

Нет необходимости в PIL! (слава богу!:)

Ответ 2

Нет ничего в stdlib для анализа data: URI за вытеснение path. Но это не сложно самостоятельно разобрать остальное. Например:

import urllib.parse

up = urllib.parse.urlparse(url)
head, data = up.path.split(',', 1)
bits = head.split(';')
mime_type = bits[0] if bits[0] else 'text/plain'
charset, b64 = 'ASCII', False
for bit in bits:
    if bit.startswith('charset='):
        charset = bit[8:]
    elif bit == 'base64':
        b64 = True

# Do something smart with charset and b64 instead of assuming
plaindata = data.decode("base64")

# Do something smart with mime_type
with open('spam.jpg', 'wb') as f:
    f.write(plaindata)

(Для Python 2.x просто измените urllib.parse на urlparse.)

Обратите внимание, что я вообще не использовал PIL. Вы не нуждаетесь в PIL для сохранения необработанных данных изображения в файл. Если вы хотите сначала сделать объект Image из него, например, сделать некоторую пост-обработку, конечно, вы можете, но это не относится к вашему вопросу.

Ответ 3

Чтобы расширить комментарий Стивена Эмсли, в Python 3 это работает, и это меньше кода:

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