We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f2452f2 commit 75e3fdbCopy full SHA for 75e3fdb
README.md
@@ -198,6 +198,20 @@ import matplotlib
198
matplotlib.use('Agg')
199
import matplotlib.pyplot as plt
200
201
+def resize_short_edge(image, target_size=2048):
202
+ if isinstance(image, str):
203
+ image = Image.open(image)
204
+ width, height = image.size
205
+ short_edge = min(width, height)
206
+
207
+ if short_edge >= target_size:
208
+ return image
209
+ scale = target_size / short_edge
210
+ new_width = int(width * scale)
211
+ new_height = int(height * scale)
212
+ resized_image = image.resize((new_width, new_height))
213
+ return resized_image
214
215
216
img_root = "cat_dfclor.jpg"
217
image = Image.open(img_root).convert("RGB")
0 commit comments