Skip to content

Instantly share code, notes, and snippets.

@colemickens
Created March 27, 2020 09:03
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 colemickens/a61d39206e91523e6cd3378dd0b2360b to your computer and use it in GitHub Desktop.
Save colemickens/a61d39206e91523e6cd3378dd0b2360b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -x
set -euo pipefail
grim /tmp/output.png
imv -f /tmp/output.png &
p="$!"
g="$(slurp)"
kill "${p}"
offset="$(echo "${g}" | cut -d' ' -f1)"
left="$(echo "${offset}" | cut -d',' -f1)"
top="$(echo "${offset}" | cut -d',' -f2)"
dimensions="$(echo "${g}" | cut -d' ' -f2)"
convert "/tmp/output.png" -crop "${dimensions}+${left}+${top}" "/tmp/output2.png"
imv /tmp/output2.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment