conversordpi / app.py
rmayormartins's picture
Subindo arquivos
9d3a36f
raw
history blame
784 Bytes
import gradio as gr
from PIL import Image
import io
import numpy as np
import tempfile
def muda_dpi(input_image, dpi):
dpi_tuple = (dpi, dpi)
image = Image.fromarray(input_image.astype('uint8'), 'RGB')
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.png')
image.save(temp_file, format='PNG', dpi=dpi_tuple)
temp_file.close()
return temp_file.name
# Configurar a interface Gradio
iface = gr.Interface(
fn=muda_dpi,
inputs=[
gr.Image(label="Upload"),
gr.Number(label="Ajusta DPI", value=300)
],
outputs=gr.File(label="Download"),
title="Conversor DPI",
description="Faça o upload da imagem (.jpg, .png), ajuste o DPI e submeta",
examples=["example1.jpg"]
)
iface.launch(debug=True)