Spaces:
Sleeping
Sleeping
Download app.py from Ichlee/PDFConversor: direct link, hf CLI and curl.
- Browser
- Download file 732 Bytes
-
https://huggingface.co/spaces/Ichlee/PDFConversor/resolve/main/app.py
- Command line
-
hf download hf://spaces/Ichlee/PDFConversor/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Ichlee/PDFConversor/resolve/main/app.py
732 Bytes
| # Importação de biblioteca | |
| import gradio as gr | |
| from PIL import Image | |
| import os | |
| def converter_imagem(imagem): | |
| try: | |
| if imagem.mode != 'RGB': | |
| imagem = imagem.convert('RGB') | |
| caminho_pdf = "resultado.pdf" | |
| imagem.save(caminho_pdf, "PDF", resolution=100.0) | |
| return caminho_pdf | |
| except Exception as e: | |
| return (f"Um erro ocorreu: {e}") | |
| # Configuração da interface | |
| interface = gr.Interface( | |
| fn=converter_imagem, | |
| inputs=gr.Image(type="pil"), # Recebe o arquivo e trata como objeto PIL | |
| outputs=gr.File(label="Baixe seu PDF aqui"), | |
| title="Conversor de JPG para PDF", | |
| description="Suba sua imagem e aguarde o processamento." | |
| ) | |
| # Iniciar o app | |
| interface.launch(share=True) |