Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit 1fa3d1a

Browse files
committed
Adds comments to image merger
1 parent bf0de77 commit 1fa3d1a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎Scripts/Miscellaneous/Merge_Images_Vertically/merge_images_vertically.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,32 @@
66
from os.path import isfile, join
77

88
def merge_pics_vertically(images_list, name):
9+
# Opens all files and stores them in a list
910
imgs = [Image.open(i) for i in images_list]
1011
min_img_width = min(i.width for i in imgs)
1112

13+
# Sums up the total height
1214
total_height = 0
1315
for i, img in enumerate(imgs):
1416
if img.width > min_img_width:
1517
imgs[i] = img.resize((min_img_width, int(img.height / img.width * min_img_width)), Image.ANTIALIAS)
1618
total_height += imgs[i].height
1719

20+
# Pastes all of them together
1821
img_merge = Image.new(imgs[0].mode, (min_img_width, total_height))
1922
y = 0
2023
for img in imgs:
2124
img_merge.paste(img, (0, y))
2225
y += img.height
26+
27+
# Then saves the final image
2328
img_merge.save(name + '.jpg')
2429

2530
def get_files(directory, ext = None):
2631
if ext is None:
2732
ext = [".jpg"]
2833
files = []
34+
# Scans the folder and gets all files with the extension
2935
for f in os.scandir(directory):
3036
if f.is_file():
3137
if os.path.splitext(f.name)[1].lower() in ext:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /