Created
May 9, 2019 08:41
-
-
Save sleepless-se/3674830cbb53b9e04b03b18f2b47815e to your computer and use it in GitHub Desktop.
PIL image convert to byte array
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
from PIL import Image | |
import io | |
def image_to_byte_array(image:Image) | |
imgByteArr = io.BytesIO() | |
image.save(imgByteArr, format=image.format) | |
imgByteArr = imgByteArr.getvalue() | |
return imgByteArr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment