jtheoof/swappy

Cut/Crop Image

tkna91 opened this issue · 2 comments

tkna91 commented

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.

20231031-065136_screencast.mp4
tkna91 commented

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.

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