GRADIO / app.py
Nycolass's picture
Update app.py
a9d05a2 verified
Raw History Blame
631 Bytes
import gradio as gr
import os
def compress_pdf(input_pdf):
output_pdf = f"{os.path.splitext(input_pdf.name)[0]}_comprimido.pdf"
gs_command = f"gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile={output_pdf} {input_pdf.name}"
os.system(gs_command)
return output_pdf
# Interface do Gradio
interface = gr.Interface(
fn=compress_pdf,
inputs=gr.inputs.File(label="Upload your PDF"),
outputs=gr.outputs.File(label="Download compressed PDF"),
title="PDF Compressor",
description="Compress your PDF files using Ghostscript"
)
interface.launch()