swappy icon indicating copy to clipboard operation
swappy copied to clipboard

Cut/Crop Image

Open tkna91 opened this issue 2 years ago • 2 comments

When I want to take a screenshot of a menu in the menu bar, for example, I often use the following command to quickly take a full-screen screenshot because the menu disappears when I make a range selection in the screen, but I don't always want a full-screen screenshot.

grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused == true).name') - | swappy -f - -o - | pngquant - -o $file

I thought it would be useful to be able to cut/crop such images by selecting a range with swappy.

https://github.com/jtheoof/swappy/assets/102382754/06bb3f7f-76f4-47db-8f20-5a9a65e89f81

tkna91 avatar Oct 30 '23 21:10 tkna91

I noticed that I can display a full screen screenshot as shown below and then take a screenshot by selecting a range for it.

tmpfile=$(mktemp --suffix=.png)
file=~/tmp/$(date "+%Y%m%d-%H%M%S")_screenshot.png
grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused == true).name') - |
imv -f -w imv-tmp-full - &
grim -l 0 -g "$(slurp)" $tmpfile
swaymsg [title=imv-tmp-full] kill
swappy -f $tmpfile -o - | pngquant - -o $file
rm $tmpfile

Close it as you like.

tkna91 avatar Nov 02 '23 02:11 tkna91

That solution is lossy as the image is re-encoded. I'd love to be able to crop in swappy , please keep this open!

rpdelaney avatar May 03 '24 20:05 rpdelaney