def _optimize_with_progs(format_module, filename, image_format):
    """
    Use the correct optimizing functions in sequence.

    And report back statistics.
    """
    filesize_in = os.stat(filename).st_size
    report_stats = None

    for func in format_module.PROGRAMS:
        if not getattr(Settings, func.__name__):
            continue
        report_stats = _optimize_image_external(
            filename, func, image_format, format_module.OUT_EXT)
        filename = report_stats.final_filename
        if format_module.BEST_ONLY:
            break

    if report_stats is not None:
        report_stats.bytes_in = filesize_in
    else:
        report_stats = stats.skip(image_format, filename)

    return report_stats
def _optimize_with_progs ( format_module , filename , image_format ) : filesize_in = os . stat ( filename ) . st_size report_stats = None for func in format_module . PROGRAMS : if not getattr ( Settings , func . __name__ ) : continue report_stats = _optimize_image_external ( filename , func , image_format , format_module . OUT_EXT ) filename = report_stats . final_filename if format_module . BEST_ONLY : break if report_stats is not None : report_stats . bytes_in = filesize_in else : report_stats = stats . skip ( image_format , filename ) return report_stats
Use the correct optimizing functions in sequence.

    And report back statistics.