o
odin.langpkg.dev
packages / library / sarp

sarp

a6e434dlibrary

Select A Region in a Picture

MIT · updated 8 months ago

SARP

Select A Region in a Picture

I got annoyed by the fact that to crop a video I need to either use a full-fledged video editor or extract a frame from it and open it in some image editing program to use ffmpeg to crop it. So I made this tool to be a simple region selector to be used in scripts.

See ffcrop.sh for usage example.

Building

$ odin build . -o:speed

Note for Wayland users

As of October 2025 the Odin programming language ships with Raylib compiled only with X11 support. To get the Wayland support you need to build Raylib with Wayland enabled and replace the library files in your Odin installation. After that everything should work smoothly.

Or you can just use XWayland :)

Usage

$ sarp --help
SARP - Select a region in a picture
The tool spawns a window in which you can select a region. Once
you do that - the selected region will be printed to the STDOUT
in a specified format.
Arguments: sarp [parameters] <filepath>
Parameters:
  --help       Print this
  --format XXX Specity output format.
    Available format specifiers:
      %w - width
      %h - height
      %x - x coordinate from the top left
      %y - y coordinate from the top left
    Default format: "%wx%h+%x+%y"
Usage:
  Hold LMB and drag it to select a region. Once you let go of the button the
  window will close and the region will be printed out to STDOUT.
  If you wish to cancel selection - press RMB and you can start selection again
  after you start holding the LMB again.
  You can also hold the middle button to move the image around.
  To quit without selecting anything press either ESCAPE or Q.

$ sarp pic.png
69x420+100+0