def main():

    effectsList = [False] * 6

    inFile = input("What is the file you want to read in (.ppm): ")

    outFile = input("What is the name of the file you want to output (.ppm): ")

    filterUse = input(
        "Here is a list of filters:"
        + "\n"
        + "0 is object_filter \n"
        + "1 is shades_of_gray \n"
        + "2 is negate_red \n"
        + "3 is negate_green \n"
        + "4 is negate_blue \n"
        + "5 is mirror \n"
        + "Which filter would you like (only choose 1 filter): "
    )

    effectsList[int(filterUse)] = True

    extraFileList = []
    ask = True

    if effectsList[0] == True:
        while ask == True:
            wantExtraFile = input("Any other files you want to add (y/n): ")
            if wantExtraFile == "y":
                extraFile = input("What is the name of the file you want to " + "add (.ppm): ")
                extraFileList.append(extraFile)
            else:
                ask = False

    effects.apply_effects(inFile, outFile, effectsList, *extraFileList)
def main():

    effectsList = [False] * 6

    inFile = input("What is the file you want to read in (.ppm): ")

    outFile = input("What is the name of the file you want to output (.ppm): ")

    filterUse = input("Here is a list of filters:" + "\n" +
                      "0 is object_filter \n" + "1 is shades_of_gray \n" +
                      "2 is negate_red \n" + "3 is negate_green \n" +
                      "4 is negate_blue \n" + "5 is mirror \n" +
                      "Which filter would you like (only choose 1 filter): ")

    effectsList[int(filterUse)] = True

    extraFileList = []
    ask = True

    if effectsList[0] == True:
        while ask == True:
            wantExtraFile = input("Any other files you want to add (y/n): ")
            if wantExtraFile == 'y':
                extraFile = input("What is the name of the file you want to " +
                                  "add (.ppm): ")
                extraFileList.append(extraFile)
            else:
                ask = False

    effects.apply_effects(inFile, outFile, effectsList, *extraFileList)
Exemple #3
0
def main():
    print('\nPortable Pixmap (PPM) Image Editor!\n')
    print('Choose the effect you would like to try\n')
    print('Please enter one effect at a time and press enter\n')
    
    # warns the user that specs must be met for program to work
    print('All files given must be of the same size and exist in directory')
    print('All effects entered must be as numbers between 1 and 6')
    
    print('1) object_filter\n2) shades_of_gray\n3) negate_red')
    print('4) negate_green\n5) negate_blue\n6) mirror\n')
    
    # initializes the effects list to all zeros
    x = [0] * 6
    file_filter_list = []
    
    # asks for and records effects chosen by user as well as file names
    effect_num = int(input('Enter a number: \n')) - 1
    x[effect_num] = 1 
    in_filename = input('Enter an input file name: \n')
    if effect_num == 0:
        more = 'y'
        while more.lower().strip() == 'y':
            add_file = input('Please input your next adittional file: ')
            file_filter_list.append(add_file)
                
            more = input('Do you wish to add another file to filter? y/n')
    out_filename = input('Enter an output file name: \n')
    
    # continues to ask for effects until the user is done
    state = input('Do you wish to choose another effect? y/n')
    while state.lower().strip() == 'y':
        effect_num = int(input('Enter a number: \n')) - 1
        x[effect_num] = 1 
        if effect_num == 0:
            more = 'y'
            while more.lower().strip() == 'y':
                add_file = input('Please input your next adittional file: ')
                file_filter_list.append(add_file)
                
                more = input('Do you wish to add another file to filter? y/n')
    
        state = input('Do you wish to choose another effect? y/n ')
    
    # calls the appy_effects function in effects module, supplying user data
    effects.apply_effects(in_filename, out_filename, x, file_filter_list)
    
    # inicates all effects completed
    print(out_filename, ' created.') 
def main():
    '''main function that takes the user option of manipulate an image.'''

    print("Portable Pixmap (PPM) Image Editor!")
    print("Choose the effect you would like to try:")
    print("1) object_filter")
    print("2) shades_of_gray")
    print("3) negate_red")
    print("4) negate_green")
    print("5) negate_blue")

    option = input("Enter your the list of effects ie. (1,2,3): ")
    input_filename = input("Enter an input file name: ")
    output_filename = input("Enter name of output file: ")
    kind = input("Kind is the file? (t for text or b for binary): ")

    effects_list = option.split(',')

    if kind == '':
        kind = 't'

    if input_filename == '':
        input_filename = 'tetons1.ppm'

    if output_filename == '':
        output_filename = 'test_output.ppm'

    file2 = ''
    file3 = ''
    if "1" in effects_list:
        file2 = input("Enter an second file name: ")
        file3 = input("Enter an third file name: ")

        # test purposes
        if file2 == '' or file3 == '':
            file2 = 'tetons2_bmp.bmp'
            file3 = 'tetons3_bmp.bmp'

    # start time  to calculate only the image processing time
    start_time = time.time()

    effects.apply_effects(input_filename, output_filename, kind, effects_list,
                          file2, file3)

    print("--- %s seconds ---" % (time.time() - start_time))
def main():
    """Prompt the user to input image files and preferred effects""" 
    #Create the directory if it is not existent
    if not os.path.exists("D://pythonHW"):
        os.makedirs("D://pythonHW")
    
    print ("Please choose what effects you want to have on your picture")
    print ('1) object_filter')
    print ('2) shades_of_gray')
    print ('3) negate_red')
    print ('4) negate_green')
    print ('5) negate_blue')
    print ('6) mirror')
   
    effect_num = input("Please enter a number")
    effects_list = [False]*6
    effects_list[int(effect_num)-1] = True #Change the value to be True for selected index
    
    #Prompt the user to input primary file name
    in_file_name = input("Enter the primary input file name")
    in_file = "D://pythonHW//" + in_file_name +".PPM"
    
    if "1" in effect_num:
        #Prompt the user to input additional file names
        filter_file_name1 = input("Enter one more input file name for filter")
        filter_file_name2 = input("Please enter one more input file name for filter")

        filter_file1 = "D://pythonHW//" + filter_file_name1+".PPM"
        filter_file2 = "D://pythonHW//" + filter_file_name2+".PPM"
        
        #Prompt the user to input out file name
        out_file_name = input("Enter name of output file")
        out_file = "D://pythonHW//" + out_file_name +".PPM"
        #Apply the effect
        effects.apply_effects(in_file, out_file, effects_list,\
                              filter_file1, filter_file2)
                
    else:
        #Prompt the user to input out file name
        out_file_name = input("Enter name of output file")
        out_file = "D://pythonHW//" + out_file_name +".PPM"
        #Apply the effect
        effects.apply_effects(in_file, out_file, effects_list)
        
    print ("{:s} now created". format(out_file_name))
Exemple #6
0
def main():
    print('Portable Pixmap (PPM) Image Editor!\n'
          'Choose the effect you would like to try:\n'
          '1) object_filter\n'
          '2) shades_of_gray\n'
          '3) negate_red\n'
          '4) negate_green\n'
          '5) negate_blue\n'
          '6) flip_horizontal\n\n')

    toUse = []
    knd = input('Enter b for bmp files and t for ppm files (b/t): ')
    use_object_filter = input('Would you like to use object_filter (y/n): ')
    images = []
    if use_object_filter == 'y':
        toUse.append(True)
        moreImages = 'y'
        while moreImages == 'y':  # gets the images to filter
            nextImg = input('Enter an input file name: ')
            if path.exists(nextImg):  # checks that the images exist
                images.append(nextImg)
            else:
                print('Image not found.')
            response = input('Would you like to input another image (y/n): ')  # asks if you'd like to add more
            moreImages = response
        otherEffects = input('Would you like to apply any other effects to your image (y/n): ')
    elif use_object_filter == 'n':
        images.append(input('Enter an input file name: '))
        otherEffects = 'y'
        toUse.append(False)
    if otherEffects == 'y':
        effectNos = list(input('Enter the numbers (2-6) of the effects you would like to use (for example if you wanted'
                               '\nto use shades_of_gray and then negate_red you would enter 23): '))
        for i in range(2, 7):
            if str(i) in effectNos:
                toUse.append(True)
            elif str(i) not in effectNos:
                toUse.append(False)
    out = input('Enter an output file name: ')
    other_images = images[1:]
    effects.apply_effects(images[0], out, knd, toUse, *other_images)
    if path.exists(out):
        print(out + ' created.')
    return
def main():
    ''' Prompts user for input and tests the apply_effects function '''
    
    in_filename = input('What is the name of the ppm file you want to alter? ')
    out_filename = input('What is the name of the new ppm file? ')
    
    print('You can choose among the following effects:')
    print('1) filter images')
    print('2) gray scale')
    print('3) negate red value') 
    print('4) negate green value')
    print('5) negate blue value')
    print('6) horizontally mirror the image')
    effects_str = input('In that order, enter 1 if you want to apply that '+
        'effect, 0 otherwise. Separate the numbers by commas. ')
        
    effects_list = [int(x) for x in effects_str.split(',')]
    if(len(effects_list) != 6):
        raise ValueError('Illegal input! It has to be a sequence of 6 numbers!')
    for eff in effects_list:
        if(eff != 0 and eff != 1):
            raise ValueError('Illegal input! Only 1s and 0s!')
            
    filter_files = []
    if(effects_list[0]):
        stop = False
        while(not stop):
            f_file = input('Enter the name of the other files to filter '+
            'the image, write "stop" when finished. ')
            if(f_file != 'stop'):
                filter_files.append(f_file)
            else:
                stop = True

    e.apply_effects(in_filename, out_filename, effects_list, *filter_files)
    # If the output file was not created, the porogram failed
    if (exists(out_filename)):
        print('The new image has bee successfully created! ')
    else:
        print('An error has occurred. Program failed. ')
def main(
    include_tokens: Optional[bool] = False, generate_decklists: Optional[bool] = False
) -> None:
    console = Console()
    extractor = TokenExtractor()

    # card_stores = [
    #     UniqueStore("unique cards"),
    #     MaximalStore("maximal cards"),
    #     MaximalStore("maximal affected cards", after_effects),
    # ]

    # token_stores = [
    #     UniqueStore("unique tokens"),
    #     MaximalStore("maximal tokens"),
    #     MaximalStore("maximal affected tokens", after_effects),
    # ]

    unique_card_store = UniqueStore("unique cards")
    maximal_card_store = MaximalStore("maximal cards")
    maximal_affected_card_store = MaximalStore("maximal affected cards")
    unique_power_toughness_card_store = UniquePowerToughnessStore("unique PT cards")

    card_stores = [
        unique_card_store,
        maximal_card_store,
        maximal_affected_card_store,
        unique_power_toughness_card_store,
    ]

    unique_token_store = UniqueStore("unique tokens")
    maximal_token_store = MaximalStore("maximal tokens")
    maximal_affected_token_store = MaximalStore("maximal affected tokens")
    unique_power_toughness_token_store = UniquePowerToughnessStore("unique PT tokens")

    token_stores = [
        unique_token_store,
        maximal_token_store,
        maximal_affected_token_store,
        unique_power_toughness_token_store,
    ]

    cached_sort_keys: dict[str, SortKey] = {}

    with Progress(transient=True, console=console) as progress:
        task = progress.add_task("Processing cards...", start=False)
        mtgjsondata = MtgjsonData()
        cards = list(mtgjsondata.load_cards(filterfunc=legal_card_filter))
        progress.update(task, total=len(cards))
        progress.start_task(task)

        for card in cards:
            # If we've already seen an older version of the same card, bail out
            if (
                card.name in cached_sort_keys
                and card.sort_key > cached_sort_keys[card.name]
            ):
                progress.advance(task)
                continue

            cached_sort_keys[card.name] = card.sort_key

            objects_to_evaluate = (
                [card] + global_variations[card.name](card)
                if card.name in global_variations
                else [card]
            )

            if include_tokens:
                try:
                    extracted_tokens = extractor.extract_from_card(card)
                    objects_to_evaluate.extend(extracted_tokens)
                except Exception as err:
                    progress.console.print(
                        f"Exception: [bold cyan]{card.name} [red]{err}"
                    )

            for obj in objects_to_evaluate:
                if obj.object_type == "token" and include_tokens:
                    for store in token_stores:
                        store.evaluate(obj)

                if obj.object_type == "card":
                    for store in card_stores:
                        store.evaluate(obj)

                for affected_obj in apply_effects(obj):
                    # apply_effects could return cards and tokens

                    if affected_obj.object_type == "token" and include_tokens:
                        maximal_affected_token_store.evaluate(affected_obj)

                    if affected_obj.object_type == "card":
                        maximal_affected_card_store.evaluate(affected_obj)

            progress.advance(task)

    generate_output(
        card_stores + token_stores if include_tokens else card_stores,
        console,
        generate_decklists,
    )