Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- original = Image.open("puppy.bmp")
- original_width, original_height = original.size
- rotated_width, rotated_height = original_height, original_width # i.e. swap them over
- rotated_clock = Image.new("RGB", (rotated_width, rotated_height))
- rotated_aclock = Image.new("RGB", (rotated_width, rotated_height))
- rotated_full = Image.new("RGB", (original_width, original_height))
- for y_pixel in range(original_height):
- for x_pixel in range(original_width):
- pixel = original.getpixel( (x_pixel, y_pixel) )
- rotated_clock.putpixel((rotated_width - 1 - y_pixel, x_pixel), pixel)
- rotated_aclock.putpixel((y_pixel, rotated_height - 1 - x_pixel), pixel)
- rotated_full.putpixel((original_width - 1 - x_pixel, original_height - 1 - y_pixel), pixel)
- rotated_clock.save('90rotated_puppy.jpg', 'JPEG')
- rotated_aclock.save('a90rotated_puppy.jpg', 'JPEG')
- rotated_full.save('fullrotated_puppy.jpg', 'JPEG')
- rotated_clock.show()
- rotated_aclock.show()
- rotated_full.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement