Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from graphics import *
- import sys
- def inverted_color(picture):
- Width = picture.getWidth()
- Height = picture.getHeight()
- for x in range(Width):
- colours = x.getPixel()
- colourstring = color_rgb(225 - colours[RED], 225 - colours[GREEN], 225 - colours[BLUE])
- picture.setPixel(colourstring, colourstring, colourstring)
- #for y in range(Height):
- def Sepia():
- pass
- def Shuffle():
- pass
- def main():
- image = input('Please enter a filename ')
- try:
- img = Image(Point(0,0), image)
- except tk.TclError:
- print('Not a valid file type!')
- sys.exit()
- area = img.getWidth() * img.getHeight()
- if area == 0:
- print('Not a valid image!!')
- sys.exit()
- cloned_img = img.clone()
- loop = 0
- while loop == 0:
- print('a. Invert image colors')
- print('b. Convert image to sepia.')
- print('c. Shuffle the image.')
- choice = input('What would you like to do? ')
- choice = choice.lower()
- if choice == 'a':
- inverted_color(cloned_img)
- loop = loop + 1
- if choice == 'b':
- colors = img.getPixel(0,0)
- loop = loop + 1
- if choice == 'c':
- colors = img.getPixel(0,0)
- loop = loop + 1
- newfilename = input('What do you want to call the file? ')
- try:
- img.save(newfilename)
- except tk.TclError:
- print('That is not a valid file!')
- main()
Advertisement
Add Comment
Please, Sign In to add comment