Spaces:
Running
Running
| import gradio as gr | |
| from PIL import Image | |
| def resize_image(image, width, height): | |
| image = Image.open(image) | |
| image = image.resize((width, height)) | |
| return image | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# 🖼️ Image Scaler") | |
| with gr.Row(): | |
| image_input = gr.File(label="Upload Image") | |
| width_input = gr.Number(label="New Width", value=512) | |
| height_input = gr.Number(label="New Height", value=512) | |
| output = gr.Image(label="Resized Image") | |
| btn = gr.Button("Resize Image") | |
| btn.click(fn=resize_image, inputs=[image_input, width_input, height_input], outputs=output) | |
| demo.launch() | |