Grouping : smaller groups, but be smarter
annotating : fix sorting for good
This commit is contained in:
+2
-35
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user