im save to a bytes io python
from io import BytesIO
from PIL import Image, ImageDraw
image = Image.new("RGB", (300, 50))
draw = ImageDraw.Draw(image)
draw.text((0, 0), "This text is drawn on image")
byte_io = BytesIO()
image.save(byte_io, 'PNG')
im save to a bytes io python
from io import BytesIO
from PIL import Image, ImageDraw
image = Image.new("RGB", (300, 50))
draw = ImageDraw.Draw(image)
draw.text((0, 0), "This text is drawn on image")
byte_io = BytesIO()
image.save(byte_io, 'PNG')
Writing Bytes to a File in python
# Pass "wb" to write a new file, or "ab" to append
with open("test.txt", "wb") as binary_file:
# Write text or bytes to the file
binary_file.write("Write text by encodingn".encode('utf8'))
num_bytes_written = binary_file.write(b'xDExADxBExEF')
print("Wrote %d bytes." % num_bytes_written)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us