Skip to content

Instantly share code, notes, and snippets.

@bperel
Created February 22, 2021 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bperel/9be18da1215b44c389f2bc3f3fbfe296 to your computer and use it in GitHub Desktop.
Save bperel/9be18da1215b44c389f2bc3f3fbfe296 to your computer and use it in GitHub Desktop.
Split multi-edge drawing
#!/bin/bash
image=/var/www/html/DucksManager-old/edges/se/elements/KAP.Fond-169-195.png
doubles=(181 188 194)
start=169
end=195
width=$(identify -format '%w' $image)
height=$(identify -format '%h' $image)
crop_size_single=$(echo "scale=3;$width/(${#doubles[@]}+1+$end-$start)" | bc)
echo $crop_size_single
dir=${image%/*}
i=$start
crop_x=0
for ((i=start; i<=end; i++)); do
echo "Generating $i"
# shellcheck disable=SC2199
if [[ ${doubles[@]} =~ ${i} ]]; then
crop_size=$(echo "scale=2;$crop_size_single*2" | bc)
else
crop_size=$crop_size_single
fi
convert $image -crop "${crop_size}x$height+$crop_x+0" "$dir/KAP.Fond.$i.png"
crop_x=$(echo "scale=3;$crop_x+$crop_size" | bc)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment