Skip to content

Instantly share code, notes, and snippets.

@sleepless-se
Created May 9, 2019 08:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sleepless-se/3674830cbb53b9e04b03b18f2b47815e to your computer and use it in GitHub Desktop.
Save sleepless-se/3674830cbb53b9e04b03b18f2b47815e to your computer and use it in GitHub Desktop.
PIL image convert to byte array
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