Skip to content

Instantly share code, notes, and snippets.

@christippett
Last active February 3, 2024 01:13
Show Gist options
  • Save christippett/42b3addd349cc30dba879d2e2cd701ce to your computer and use it in GitHub Desktop.
Save christippett/42b3addd349cc30dba879d2e2cd701ce to your computer and use it in GitHub Desktop.
Split Midjourney image grid into individual images
#!/bin/sh
set -e
ext=".$(basename "$1" | rev | cut -d'.' -f1 | rev)"
fname="$(basename "$1" "$ext")"
width="$(identify -format "%w" "$1")"
height="$(identify -format "%h" "$1")"
w="$((width / 2))"
h="$((height / 2))"
magick "$1" -crop "$w"x"$h"+0+0 "${fname}-1${ext}"
magick "$1" -crop "$w"x"$h"+"$w"+0 "${fname}-2${ext}"
magick "$1" -crop "$w"x"$h"+0+"$h" "${fname}-3${ext}"
magick "$1" -crop "$w"x"$h"+"$w"+"$h" "${fname}-4${ext}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment