We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 75e3fdb commit 2205809Copy full SHA for 2205809
README_en.md
@@ -195,6 +195,19 @@ import matplotlib
195
matplotlib.use('Agg')
196
import matplotlib.pyplot as plt
197
198
+def resize_short_edge(image, target_size=2048):
199
+ if isinstance(image, str):
200
+ image = Image.open(image)
201
+ width, height = image.size
202
+ short_edge = min(width, height)
203
+
204
+ if short_edge >= target_size:
205
+ return image
206
+ scale = target_size / short_edge
207
+ new_width = int(width * scale)
208
+ new_height = int(height * scale)
209
+ resized_image = image.resize((new_width, new_height))
210
+ return resized_image
211
212
img_root = "cat_dfclor.jpg"
213
image = Image.open(img_root).convert("RGB")
0 commit comments