155elkhorn commited on
Commit
709534d
·
1 Parent(s): 7ac0eca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -68,21 +68,22 @@ def resize_and_overlay_image(input_image, reduction_percentage, shift_percentage
68
  # Overlay the resized image on the background image
69
  background_img[y:y + resized_height, x:x + resized_width] = resized_img
70
 
 
 
 
71
  # Create the Gradio interface
72
  iface = gr.Interface(
73
  fn=resize_and_overlay_image,
74
  inputs=[
75
  gr.inputs.Image(type="pil", label="Input Image"),
76
  gr.inputs.Slider(minimum=0, maximum=100, step=10, default=80, label="Percentage of Original"),
77
- gr.inputs.Slider(minimum=-50, maximum=50, step=10, default=0, label="Shift Left / Right (%)"),
78
- gr.inputs.Slider(minimum=-50, maximum=50, step=10, default=0, label="Shift Up / Down (%)"),
79
  gr.inputs.Textbox(default="#ffffff", label="Background Color (Hex Code)"),
80
- gr.inputs.Slider(minimum=0, maximum=100, step=10, default=0, label="Crop Top (%)"),
81
- gr.inputs.Slider(minimum=0, maximum=100, step=10, default=0, label="Crop Bottom (%)")
82
- ],
83
- outputs=[
84
- gr.outputs.Image(type="numpy", label="Result")
85
  ],
 
86
  title="Image Resizer",
87
  description="Crop the input image, overlay it on a new background of the specified color, start centered, and shift it as a percentage without stretching."
88
  )
 
68
  # Overlay the resized image on the background image
69
  background_img[y:y + resized_height, x:x + resized_width] = resized_img
70
 
71
+ # Return the resulting image as a NumPy array
72
+ return background_img
73
+
74
  # Create the Gradio interface
75
  iface = gr.Interface(
76
  fn=resize_and_overlay_image,
77
  inputs=[
78
  gr.inputs.Image(type="pil", label="Input Image"),
79
  gr.inputs.Slider(minimum=0, maximum=100, step=10, default=80, label="Percentage of Original"),
80
+ gr.inputs.Slider(minimum=-20, maximum=20, step=1, default=0, label="Shift Left / Right (%)"),
81
+ gr.inputs.Slider(minimum=-20, maximum=20, step=1, default=0, label="Shift Up / Down (%)"),
82
  gr.inputs.Textbox(default="#ffffff", label="Background Color (Hex Code)"),
83
+ gr.inputs.Slider(minimum=0, maximum=25, step=1, default=0, label="Crop Top (%)"),
84
+ gr.inputs.Slider(minimum=0, maximum=25, step=1, default=0, label="Crop Bottom (%)")
 
 
 
85
  ],
86
+ outputs=gr.outputs.Image(type="numpy", label="Result"),
87
  title="Image Resizer",
88
  description="Crop the input image, overlay it on a new background of the specified color, start centered, and shift it as a percentage without stretching."
89
  )