2. Image copy
2.1. Copy
Use the
Image.copy()
method to copy an image. Use this method if you wish to paste things into an image, but still retain the original.The code below first copies an image so the copy can be converted to greyscale.
from PIL import Image
def get_greyscale(img):
imgd = img.copy()
return imgd.convert('L')
with Image.open("test_images/crosses.png") as im:
im1g = get_greyscale(im)
im1g.save("image/copy.png")