Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @staticmethod
- def save_image_png(image):
- miss_pad = len(image) % 4 # add missing padding
- if miss_pad != 0:
- image += '=' * (4 - miss_pad)
- image = image.split('base64,')[1]
- img_data = b64decode(image)
- filename = '%s.png' % hash(image)
- image = ContentFile(img_data, filename)
- new_img = DivToPng(image=image)
- new_img.save()
- return new_img.image.path
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement