9. ImageChops duplicate
See: Image.copy()
9.1. Duplicate
Alias for
Image.copy()
.Use the
ImageChops.duplicate(image)
method to copy an image.The code below first duplciates an image so a copy can be converted to greyscale.
from PIL import Image, ImageChops
def get_greyscale(img):
imgd = ImageChops.duplicate(img)
return imgd.convert('L')
with Image.open("test_images/crosses.png") as im1:
im1g = get_greyscale(im1)
im1g.save("chops/duplicate.png")