Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image #Import the Image module from the PIL library
- def clarendon2(values):
- new_values = []
- if max(values) < 128: #darks darker
- modify = 0.9
- for colour in range(3):
- new_values.append(int( max(0, values[colour] * modify)))
- else: #lights lighter
- modify = 1.1
- for colour in range(3):
- new_values.append(int( min(255, values[colour] * modify)))
- new_values[2] = int(min(255, new_values[2]*1.1)) #blue tint
- return tuple(new_values)
- image = Image.open('image.png') #Create a path to the image file
- rgb_image = image.convert('RGB') #Convert the image to RGB
- width, height = image.size #Assign the image's width and height to variables
- new_image2 = Image.new('RGB', (width,height)) #Create a grid for the output image
- #Set up loops to modify each pixel within the image
- for row in range(height):
- for col in range(width):
- rgb = rgb_image.getpixel((col, row))
- new_image2.putpixel((col, row), clarendon2(rgb))
- image.show()
- new_image2.show()
Add Comment
Please, Sign In to add comment