Gimp: Select and vertically swap a pair of horizontal segments

I need to easily select and swap full-width horizontal sections of an image, e.g.

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccccccc
ddddddddddddddddddddddddddddd

after swapping sections ‘b’ and ‘c’ becomes

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
ccccccccccccccccccccccccccccc
bbbbbbbbbbbbbbbbbbbbbbbbbbbbb
ddddddddddddddddddddddddddddd

I realize that this can be done by selecting ‘b’, cutting it, selecting ‘c’, cutting and moving it up, then pasting ‘b’ below it, but that’s really tedious and error-prone. Is there a better way? FWIW, the images I’m working with are B&W scans of musical scores.

EDIT: (More context and clarification)
The scores I’m working with are part extractions created with the online tool at partifi.org. Partifi has a very well-designed interface that

  1. makes intelligent guesses about where to place the separations, and
  2. provides a nice UI for rapidly adjusting/creating/deleting them.

The problem I’m trying to solve arises with choral scores. One of the ways music publishers reduce the page count is by combining parts (e.g. Tenor and Bass) onto a single stave and placing the lyrics above rather than below the stave. Large scores often switch frequently between that representation and the conventional format with one voice per stave with lyrics underneath.

Singers are used to that sort of thing in the context of a complete score but it becomes distracting and hard to follow in the context of single stave extraction.

Partifi doesn’t have a way to deal with that. Hence my interest in using Gimp for post-processing.

What I’m looking for:

A fast way to fix the places where the lyrics are above instead of below the staves. Ideally this would consist of

  1. Three mouse clicks to place separator lines to define the regions to be swapped.
  2. The possibility to drag the lines vertically for fine adjustment.
  3. A keyboard shortcut to trigger the swap.

I suspect this may require a custom script. If that’s the case, I would accept an answer that points me to a public domain Python script that is close enough to what I want to be easily adapted. I’m trying to avoid having to study Gimp’s scripting API in enough depth to do it from scratch.

Answer

See if ofn-swap-strips could help. Basically you indicate a vertical strip using the selection (only the vertical bounds are used):

before

And the script swaps it with the strip of same height immediately below it:

after

Alternate option, use the ofn-guillotine-layer script with guides to quickly slice your score into strips that you can move around. If you have multiple score pages to work with and the lines are at fairly constant places, you can even use the ofn-preset-guides to create a preset for the guides. To abutt the layers quickly see the arrange-layers script.

Edit: seen your edit. Can’t tell if ofn-swap-strips does the job, but if it doesn’t it would be a good start.

Edit#2: Updated ofn-swap-strips to work with guides:

Using guides

Attribution
Source : Link , Question Author : Mike Ellis , Answer Author : xenoid

Leave a Comment