From 2641507b34aca0287fd4c537f974628cb9d19960 Mon Sep 17 00:00:00 2001 From: autumn-2-net <109412646+autumn-2-net@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:52:19 +0800 Subject: [PATCH] Update auto_pack_img.py --- auto_pack_img.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/auto_pack_img.py b/auto_pack_img.py index fed8abf..109a078 100755 --- a/auto_pack_img.py +++ b/auto_pack_img.py @@ -114,6 +114,16 @@ def load_images_from_folder(folder,max_height=768,max_width=768): # img = cv2.resize(img, (min(img.shape[1], max_width), min(img.shape[0], max_height))) images.append(img) random.shuffle(images) + scc=[] + for i in images: + w=i.shape[1] + h=i.shape[0] + sizezz=w*h + scc.append((sizezz,i)) + scc.sort(key=lambda x: x[0], reverse=True) + images=[] + for i in scc: + images.append(i[1]) return images @@ -124,7 +134,7 @@ images = load_images_from_folder(folder) stitched_image = stitch_images_bin_packing(images) -cv2.imwrite('images/auto_img_zh_cn.png', stitched_image) +cv2.imwrite('auto_img_zh_cn.png', stitched_image) folder = 'en' @@ -133,4 +143,4 @@ images = load_images_from_folder(folder) stitched_image = stitch_images_bin_packing(images) -cv2.imwrite('images/auto_img_en.png', stitched_image) +cv2.imwrite('auto_img_en.png', stitched_image)