: 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
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
makes intelligent guesses about where to place the separations, and
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
Three mouse clicks to place separator lines to define the regions to be swapped.
The possibility to drag the lines vertically for fine adjustment.
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.
More posts by @Becky351
3 Comments
Sorted by latest first Latest Oldest Best
(After reading your update) Yeap - you will need a script. Marking the regions to be swapped can be done by using GIMP's built-in image-guides. Unfortunately scriptting API does not allow one to interact with the image itself within the script context - the script has to consume whatever you can build witht he program UI.
Fortunatelly, I think guides are close enough to what you want - check if placing 3 guides for start, end, target position of the regions to be swapped is fast enough for you. If so, we can put together a script that will:
Read the position of all horizontal guides,
Make a rectangular selection from the top-most to the second one, with image width
edit->cut, paste as new layer (tmplayer)
make a rectangular selection, same height, on the third guide
edit->cut, past on original layer, position at first guide, anchor
position (tmplayer) on third guide, merge down
clean up .
SO,it is a non trivial script - I can help you futher, but will have to do so later on.
See if ofn-swap-strips could help. Basically you indicate a vertical strip using the selection (only the vertical bounds are used):
And the script swaps it with the strip of same height immediately below it:
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:
Cut the score line by line into the clipboard. Paste every clipped line back as new layer.
No need to clip those lines that stay in their original places.
The layers can be shuffled freely back and forth. No need to switch between layers, any loose parts can be moved by the moving tool.
Lock those layers that must not move any more.
From the beginning rename the layers with line or bar numbers. If there are a lot of edits, use texts from your edit plan. Otherwise you can get lost.
A small score:
Line 1 and line 3 swapped, took about 40 seconds:
ADDENDUM: The question has evolved. Other answers cover the new requirements better. The questioner especially wants to avoid placing the snippets manually.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.