Skip to content

Instantly share code, notes, and snippets.

@isalgueiro
Created September 22, 2025 10:12
Show Gist options
  • Select an option

  • Save isalgueiro/b3f7fd74ac3092068d295dba994f49b1 to your computer and use it in GitHub Desktop.

Select an option

Save isalgueiro/b3f7fd74ac3092068d295dba994f49b1 to your computer and use it in GitHub Desktop.
Combine images, four by four, into a new A4 sized image
mkdir -p out && i=1 && \
while read A B C D; do \
montage "$A" "$B" "$C" "$D" \
-tile 2x2 \
-geometry 1754x1240+20+20 \
-background white \
-density 300 miff:- \
| convert miff:- \
-background white \
-gravity center \
-extent 3508x2480 \
out/page_"$i".jpg && \
i=$((i+1)); \
done < <(ls *.jpg | xargs -n4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment