예제 #1
0
def display_interface():
    #"Takes Resizer objects."
    resizer = Resizer()
    __clear()

    choice = " "
    exit_menu = False
    __print_intro()
    while not exit_menu:
        __print_menu()
        choice = raw_input("Choice:  ")
        print

        # Set source path
        if choice == '1':
            path = raw_input(
                "Please enter the path for the file(s) you would like to resize:  "
            )
            resizer.set_imgpath(path)
            print resizer.img_path()
            raw_input()

        # Set destination path
        elif choice == '2':
            dest = raw_input(
                "Please enter the path where you would like your resized file(s) to go:  "
            )
            resizer.set_destination(dest)

        # Set file suffix
        elif choice == '3':
            suffix = raw_input(
                "Please enter the what suffix you would like your resized file(s) to have:  "
            )
            resizer.set_suffix(suffix)

        # Set max file size
        elif choice == '4':
            max_size = raw_input(
                "Please enter the maximum file size you would like your resized file(s) to have (in Kilobytes [KB]):  "
            )
            resizer.set_max_size(max_size)

        #  Set resolution
        elif choice == '5':
            res = raw_input(
                "Please enter the [horizontal] resolution you would like your resized file(s) to have:  "
            )
            resizer.set_resolution(res)

        # Upload
        elif choice == '6':
            raw_input("This feature has not yet been implemented.")

        # Resize
        elif choice == '7':
            if not resizer.img_path():
                print "ERROR: Please provide a Source for the Image(s) in option 1 before proceeding."
            else:
                resizer.resize()
                exit_menu = True

        # Help
        elif choice == '8':
            __print_help()

        # Exit
        elif choice == '9':
            print "Goodbye!"
            exit_menu = True

        else:
            print "ERROR: Please enter a number between 1 and 9."
예제 #2
0
	def test_invalid_height(self):
		resizer = Resizer()
		with self.assertRaises(AssertionError) as context:
			resizer.process_images_in_dir(input_dir="images", width=32, height=-1, overwrite=True)

			self.assertTrue('Throws exception on invalid width.' in context.exception)
예제 #3
0
	def test_overwrite(self):
		resizer = Resizer()
		resizer.process_images_in_dir(input_dir="images", width=32, height=32, overwrite=True)
예제 #4
0
	def test_invalid_dir(self):
		resizer = Resizer()
		with self.assertRaises(AssertionError) as context:
			resizer.process_images_in_dir(input_dir="does_not_exist", width=32, height=32, overwrite=True)

			self.assertTrue('Throws exception on invalid directory.' in context.exception)