ciover2024 commited on
Commit
948b6ac
·
verified ·
1 Parent(s): 7480e87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -72,10 +72,19 @@ def load_upscaling_model():
72
 
73
  def resize_image(orig_image):
74
  aspect_ratio = orig_image.height / orig_image.width
75
- new_width = int(orig_image.width*1.1)
 
 
76
  new_height = int(new_width * aspect_ratio)
77
  resized_image = orig_image.resize((new_width, new_height), Image.Resampling.LANCZOS)
78
- return resized_image
 
 
 
 
 
 
 
79
 
80
  # Function to resize image (simpler interpolation method for speed)
81
  def resize_to_match(input_image, output_image):
 
72
 
73
  def resize_image(orig_image):
74
  aspect_ratio = orig_image.height / orig_image.width
75
+ old_width = orig_image.width
76
+ new_width = int(orig_image.width*1.2)
77
+ old_height = orig_image.height
78
  new_height = int(new_width * aspect_ratio)
79
  resized_image = orig_image.resize((new_width, new_height), Image.Resampling.LANCZOS)
80
+
81
+ left_crop = int((new_width - old_width)/2)
82
+ right_crop = new_width - int((new_width - old_width) / 2)
83
+ top_crop = int((new_height - old_height)/2)
84
+ bottom_crop = new_height - int((new_height - old_height) / 2)
85
+ cropped_image = resized_image.crop((left, upper,right,lower))
86
+
87
+ return cropped_image
88
 
89
  # Function to resize image (simpler interpolation method for speed)
90
  def resize_to_match(input_image, output_image):