im save to a bytes io python 1

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')

Here is what the above code is Doing:
1. Create a new image with the given mode and size.
2. Create a draw instance.
3. Draw the text.
4. Save the image to a file-like object.

Similar Posts