Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from PIL import Image
- def concat_folder(folder_path):
- print('Folder:', folder_path)
- file_paths = []
- for folder,subfolders,files in os.walk(folder_path):
- for f in files:
- file_paths = file_paths + [os.path.join(folder,f)]
- file_paths.sort(
- key = lambda f: os.path.getsize(f),
- reverse = True)
- file_paths = sorted([f for f in file_paths if f.lower().endswith(('.png','.jpeg','.jpg','.gif', '.webp'))])
- images = [Image.open(fp) for fp in file_paths]
- output_size = (
- max([i.width for i in images]),
- sum([i.height for i in images]),
- )
- print('output_size:', output_size)
- output_image = Image.new('RGB', output_size)
- output_image_path = os.path.join(folder_path)+'.png'
- print('output_image_path:', output_image_path)
- y = 0
- for i in images:
- output_image.paste(i, (0,y))
- y = y + i.height
- output_image.save(output_image_path)
- paths = '''
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 01
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 02
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 03
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 04
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 05
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 06
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 07
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 08
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 09
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 10
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 11
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 12
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 13
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 14
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 15
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 16
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 17
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 18
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 19
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 20
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 21
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 22
- /home/hellerick/Documents/Akiba/Manga/Q/TF. Gisou Furin/Ch 23
- '''
- if __name__ == '__main__':
- paths = [p for p in paths.split('\n') if p!='']
- print(paths)
- for p in paths:
- concat_folder(p)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement