Batch compression.

    args contains:
     * input - path to input directory
     * output - path to output directory or None
     * apikey - TinyPNG API key
     * overwrite - boolean flag

def _main(args):
    """Batch compression.

    args contains:
     * input - path to input directory
     * output - path to output directory or None
     * apikey - TinyPNG API key
     * overwrite - boolean flag
    """

    if not args.apikey:
        print("\nPlease provide TinyPNG API key")
        print("To obtain key visit https://api.tinypng.com/developers\n")
        sys.exit(1)

    input_dir = realpath(args.input)

    if not args.output:
        output_dir = input_dir + "-output"
    else:
        output_dir = realpath(args.output)

    if input_dir == output_dir:
        print("\nPlease specify different output directory\n")
        sys.exit(1)

    handler = ScreenHandler()

    try:
        process_directory(input_dir, output_dir, args.apikey, handler)
    except KeyboardInterrupt:
        handler.on_finish(output_dir=output_dir)