jtheoof / swappy

A Wayland native snapshot editing tool, inspired by Snappy on macOS
MIT License
1k stars 40 forks source link

Cut/Crop Image #155

Open tkna91 opened 10 months ago

tkna91 commented 10 months ago

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 commented 10 months ago

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.

rpdelaney commented 4 months ago

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