https://stackoverflow.com/questions/923885/capture-html-canvas-as-gif-jpg-png-pdf
https://stackoverflow.com/questions/19395649/python-pil-create-and-save-image-from-data-uri
from binascii import a2b_base64
data = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUUEhQUFRUXGBcVFxgXFxUXGBQYGBYXGBQWFRUYHCggGB0lHBQXITIhJSkrLi4uFyAzODMsNygtLisBCgoKDg0OGxAQGywkICQsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLP/AABEIANcA6gMBEQACEQEDEQH/xAAbAAACAgMBAAAAAAAAAAAAAAAEBQMGAAIHAf/EAEEQAAIBAgQDBQQIBQMDBQEAAAECAwARBBIhMQVBUQYTImFxMoGRoQcUI0JSscHwYnKi0eFDgpIksvEVM1PC4nP/xAAaAQACAwEBAAAAAAAAAAAAAAADBAABAgUG/8QANhEAAgIBBAADBQcEAgMBAQAAAQIAAxEEEiExE0FRBSJhcZEUMoGhsdHhI0LB8FLxBhUzgmL/2gAMAwEAAhEDEQA/ANJMYZXA5Velq3uJL7Nqy08NWwFegI4wJxM5MIxM3SsjibAgZxBrW3MwTgyeFzUC47mS2YYl6wZIXFQTLxJ7ViYxPLVJYgePS6mjVHBmjEGFBD++jueYRBxLVhj4RSb9yESYGsS1mb1OowqyeNKA/JhwMCbstWIMwV96JjiZDcyS2lAHEI3MDxCXFNVPFrFipE1pxsYi44k/dUITZM9bDg1rfiBMIhW1DY5lTdmqgJYkEhogmwJtCtZYy8QpaEZgzaqlTKkkyrknOuzXDSfE3Oq0dGxdxj2quycCWeTQWFPRJYPfWhecPnibRxXNFBxAPGMMIobMZkCFCPShbpoGbqKyZsyWszBmVJQkcqXrSnE3EcsNnpk8jM2h8o6wTaUvYOZZk43oci/ekyismOLJ1OlCI5myeJ4zVYEAWg0hoomM8z0vpQWWGDSBmolYgrDAVXxU4TxFR3JgaHCSS1VBkTn3aniGJixOIa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