5. Image draft


5.1. Draft

Use the Image.draft(mode, size) method modifies the Image object in place to convert a JPEG to the given mode at the given size.
In the code below, a jpg is opened and modified, in place, then saved, then closed.
from PIL import Image

im = Image.open('shapes_jpgs/x.jpg')
im.draft("L", (im.width // 2, im.height // 2))
# im.show()
im.save("shapes_jpgs/x_half_grey.png")
im.close()
../_images/compare_draft.png