import re
import io
from PIL import Image
image_data = re.sub('^data:image/.+;base64,', '', data['img']).decode('base64')
image = Image.open(io.StringIO(image_data))
Decoding base64 from POST to use in PIL