Last active
August 27, 2018 10:59
-
-
Save 1c7/64eb0372840cbf5cf3bfb1e007cef651 to your computer and use it in GitHub Desktop.
HTML <img src="data:image/jpeg;base64"> to Image file using Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 3 | |
import base64 | |
# Fill in this | |
base64_string = 'data:image/jpeg;base64, ...etc..' | |
array = url.split('data:image/jpeg;base64,') | |
base64_naked = array[1] | |
imgdata = base64.b64decode(base64_naked) | |
with open('haha.jpg', 'wb') as f: | |
f.write(imgdata) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What this code does
This code snippet help you turn
<img src='data:image/jpeg;base64, ...etc..'>
into Image file.
all you have to do is fill in
base64_string
variable