Skip to content

Instantly share code, notes, and snippets.

@r6m
Last active May 8, 2022 03:48
Show Gist options
  • Save r6m/190d86a91b712cffd652a0fe9af780a7 to your computer and use it in GitHub Desktop.
Save r6m/190d86a91b712cffd652a0fe9af780a7 to your computer and use it in GitHub Desktop.
split image by width using imagemagic
function slice() {
local slice_width="${SLICEW:-1080}"
local width=$(identify -format "%[w]" $1)
local slices=$(($width/$slice_width))
local name="${1%.*}"
echo -e "slice ($slices x $slice_width) for image $1"
convert -crop "${slices}x1@" $1 "${name}-%d.png"
}
# this will split image into slices:
$ slice solid.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment