def compress_pdf(filepath, output_path, ghostscript_binary):
if not filepath.endswith(PDF_EXTENSION):<EOL><INDENT>raise ValueError("<STR_LIT>" % filepath)<EOL><DEDENT>try:<EOL><INDENT>file_size = os.stat(filepath).st_size<EOL>if file_size < FILE_SIZE_LOWER_LIMIT:<EOL><INDENT>LOGGER.info(NOT_COMPRESSING.format(filepath, file_size, FILE_SIZE_LOWER_LIMIT))<EOL>process = subprocess.Popen(['<STR_LIT>', filepath, output_path])<EOL><DEDENT>else:<EOL><INDENT>LOGGER.info(COMPRESSING.format(filepath))<EOL>process = subprocess.Popen(<EOL>[ghostscript_binary, "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>", "<STR_LIT>", "<STR_LIT>",<EOL>"<STR_LIT>" % output_path, filepath]<EOL>)<EOL><DEDENT><DEDENT>except FileNotFoundError:<EOL><INDENT>msg = GS_NOT_INSTALLED.format(ghostscript_binary)<EOL>raise FileNotFoundError(msg)<EOL><DEDENT>process.communicate()<EOL>LOGGER.info(FILE_DONE.format(output_path))<EOL>
Compress a single PDF file.

    Args:
        filepath (str): Path to the PDF file.
        output_path (str): Output path.
        ghostscript_binary (str): Name/alias of the Ghostscript binary.

    Raises:
        ValueError
        FileNotFoundError