def All_images_filter(path, dstpath, blur, iteration, log_file):
    """
    Applique les filtres {GrayScale.gray_filter}, {BlurryImage.blur_filter()}, {DilatedImage.dilated_image()},{FilterZeTeam.text_filter()} à toutes les images d'un dossier
    :param path: folder where to collect images
    :param dstpath: folder where to put the modified images
    :param blur: desired blur intensity
    :param iteration: number of times the pixels should dilate
    """

    try:
        makedirs(dstpath)

    except:
        print("Directory already exist, images will be written in  " +
              dstpath + " folder")

    # Folder won't used
    files = os.listdir(path)

    for image in files:
        try:
            img = cv2.imread(os.path.join(path, image))
            img = GrayScale.gray_filter(img)
            img = BlurryImage.blur_filter(img, blur)
            img = DilatedImage.dilated_image(img, iteration)
            img = FilterZeTeam.text_filter(img)
            cv2.imwrite(os.path.join(dstpath, image), img)
        except cv2.error as e:
            print(e)
    logger.log('All filters are applied', log_file)
    print('All filters are applied')
def All_images_filter_text_gray(path, dstpath, log_file):
    """
    Applique les filtres {GrayScale.gray_filter},{FilterZeTeam.text_filter()} à toutes les images d'un dossier
    :param path: folder where to collect images
    :param dstpath: folder where to put the modified images
    """

    try:
        makedirs(dstpath)

    except:
        print("Directory already exist, images will be written in  " +
              dstpath + " folder")

    # Folder won't used
    files = os.listdir(path)

    for image in files:
        try:
            img = cv2.imread(os.path.join(path, image))
            img = GrayScale.gray_filter(img)
            img = FilterZeTeam.text_filter(img)
            cv2.imwrite(os.path.join(dstpath, image), img)
        except cv2.error as e:
            print(e)
    logger.log('Filters text and grayscale are applied', log_file)
    print('Filters text and grayscale are applied')
# Check if directory are there
if path == None:
    print('No initialized directory')
    sys.exit()

if dstpath == None:
    dstpath = 'default_directory'

    # Check for all the filters that the user want to be use
    # Text or grayscale or blur or dilata
if (iteration == None) & (blur == None) & (grayscale == None) & (text == ''):
    FilterZeTeam.All_images_filter_text_filter(path, dstpath, log_file)
elif (iteration == None) and (blur == None) and (grayscale == '') and (text == ''):
    All_images.All_images_filter_text_gray(path, dstpath, log_file)
elif (iteration == None) and (blur == None) and (grayscale == '') and (text == None):
    GrayScale.All_images_filter_grey_scale(path, dstpath, log_file)
elif (iteration == None) and (grayscale == None) and (blur != None) and (text == None):
    blur = int(blur)
    if ((blur % 2) == 0) or (blur < 0):
        print('The blur need to be positive and odd')
    else:
        BlurryImage.All_images_filter_blurry(path, dstpath, blur, log_file)
elif (iteration == None) and (grayscale == None) and (blur != None) and (text == ''):
    blur = int(blur)
    if ((blur % 2) == 0) or (blur < 0):
        print('The blur need to be positive and odd')
    else:
        All_images.All_images_filter_text_blurry(path, dstpath, blur, log_file)
elif (iteration != None) and (grayscale == None) and (blur == None) and (text == None):
    iteration = int(iteration)
    DilatedImage.All_images_filter_dilated(path, dstpath, iteration, log_file)