34 lines
678 B
Python
34 lines
678 B
Python
import PIL.Image
|
|
import os
|
|
|
|
import re
|
|
|
|
import natsort
|
|
|
|
p1 = re.compile("(.+)(\\.|-)(\\d)\\.jpe?g")
|
|
|
|
digits = re.compile("\\d+")
|
|
|
|
mappe = {}
|
|
|
|
everything = []
|
|
|
|
for f in natsort.natsorted(os.listdir(".")):
|
|
if not (f.endswith(".jpeg") or f.endswith(".jpg")):
|
|
continue
|
|
|
|
match = p1.match(f)
|
|
flat = match.group(1)
|
|
|
|
if flat not in mappe:
|
|
mappe[flat] = []
|
|
|
|
img = PIL.Image.open(f)
|
|
mappe[flat].append(img)
|
|
everything.append(img)
|
|
|
|
for flat in mappe:
|
|
mappe[flat][0].save(f"out/{flat}.pdf", save_all=True, append_images=mappe[flat][1:])
|
|
print(flat)
|
|
|
|
everything[0].save("out/everything.pdf", save_all=True, append_images=everything[1:]) |