File size: 1,217 Bytes
020d426
f1ff90b
e449e4a
9f7b2a3
 
e449e4a
020d426
 
d1d63c6
020d426
 
0aba839
020d426
9f7b2a3
 
 
 
 
 
 
 
 
 
d1d63c6
b6aff6e
5de2687
e1d7680
9f7b2a3
020d426
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
import gradio as gr
from overlay import txt_on_trans as tt 

def process(txt,font_size,font_x,font_y,font_col,bg_col,bg_op,im_size_x,im_size_y):
    return tt(txt,font_size,font_x,font_y,font_col,bg_col,bg_op,im_size_x,im_size_y)


with gr.Blocks() as app:
    
    with gr.Row():
        with gr.Column():
            inp = gr.Textbox(lines = 6,min_width=100)
            btn = gr.Button()
            with gr.Row():
                f_x=gr.Slider(label='Text X', maximum=512, step=1, value=0)
                f_y=gr.Slider(label='Text Y', maximum=512, step=1, value=0)
            with gr.Row():
                f_size=gr.Number(label='Font Size',precision=0, value=32)
                b_x=gr.Number(label='Image Width',precision=0, value=512)
                b_y=gr.Number(label='Image Height',precision=0, value=256)
                
            with gr.Row():
                f_col=gr.ColorPicker(label='Text Color')
                b_col=gr.ColorPicker(label='Background Color', value = '#FFFFFF')
                b_op=gr.Slider(label='Background Opacity', maximum=255, step=1, value=255)
            
        outp = gr.Pil()
    btn.click(process,[inp,f_size,f_x,f_y,f_col,b_col,b_op,b_x,b_y],outp)
app.launch()