File size: 739 Bytes
7f09351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3d8bca6
7f09351
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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

#teste
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"
)


iface.launch(debug=True)