Grouping : smaller groups, but be smarter

annotating : fix sorting for good
This commit is contained in:
2026-01-18 15:26:32 +01:00
parent 78d4a61eb2
commit 3c84e33770
2 changed files with 65 additions and 57 deletions
+2 -35
View File
@@ -381,6 +381,8 @@ def concat_display_image(subdir):
if not images:
return
images.sort(key=lambda f: [int(n) for n in re.findall(r'\d+', str(f))])
# Load images
opened_imgs = [Image.open(img) for img in images]
@@ -402,41 +404,6 @@ def concat_display_image(subdir):
print(f"Saved: {save_path}")
# subprocess.call(('xdg-open', save_path))
def concat_anot_images(directory):
root = Path(directory)
for subdir in root.iterdir():
if subdir.is_dir() and subdir.name.startswith("Anot"):
# Find valid images, excluding previous concatenations
images = sorted([
f for f in subdir.glob("*.jpg")
if f.name != "Concat.jpg"
])
images.sort(key=lambda f: [int(n) for n in re.findall(r'\d+', f)])
if not images:
continue
# Load images
opened_imgs = [Image.open(img) for img in images]
# Calculate dimensions (max width, sum of heights)
max_w = max(i.width for i in opened_imgs)
total_h = sum(i.height for i in opened_imgs)
# Create canvas and paste vertically
canvas = Image.new('RGB', (max_w, total_h))
current_y = 0
for img in opened_imgs:
canvas.paste(img, (0, current_y))
current_y += img.height
# Save
save_path = subdir / "Concat.jpg"
canvas.save(save_path)
print(f"Saved: {save_path}")
subprocess.call(('xdg-open', save_path))
if len(sys.argv) < 2: