Gimp-Forum.net
Move Selection by given number of pixels - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: Move Selection by given number of pixels (/Thread-Move-Selection-by-given-number-of-pixels)



Move Selection by given number of pixels - Roy Tuesday - 08-01-2020

I'm using Gimp to do spritesheets, and I'd love a way to move a selection by a given number of pixels along an axis; E.G. 256px to the right on the x-axis. I can't do this visually, because the layers have transparency, the selections I'm working with don't line up the same way with the guides. The resolution is too high to just spam the arrow keys. I haven't found anything obvious in the documentation or the various tool options in Gimp.

My current workaround is to fill a rectangular selection around the sprite with cyan and line it up visually, but that's really clunky. Surely there's a better way?


RE: Move Selection by given number of pixels - Ofnuts - 08-01-2020

When you use the Move tool the move amount in the current mouse drag dis displayed at the bottom However this requires to do everything in a single operation.

But if you use the Unified Transform tool, the total X and Y displacements are available in the transform matrix, even if you do the move as several drags:

[attachment=4704]

Otherwise this is easy to script, and a script for this could already be available.


RE: Move Selection by given number of pixels - tmanni - 08-02-2020

With the 3D Transform Tool, you can specify manually the X and Y offsets at sub-pixels precision.


RE: Move Selection by given number of pixels - rich2005 - 08-02-2020

How about the align tool with an offset.

demo 30 seconds https://i.imgur.com/NEbFb4A.mp4

3D transform is easy, Came in with Gimp 2.10.18 If OP is using macOS then Gimp might be an earlier version.


RE: Move Selection by given number of pixels - programmer_ceds - 08-03-2020

(08-01-2020, 08:13 PM)Roy Tuesday Wrote: I'm using Gimp to do spritesheets, and I'd love a way to move a selection by a given number of pixels along an axis; E.G. 256px to the right on the x-axis. I can't do this visually, because the layers have transparency, the selections I'm working with don't line up the same way with the guides. The resolution is too high to just spam the arrow keys. I haven't found anything obvious in the documentation or the various tool options in Gimp.

My current workaround is to fill a rectangular selection around the sprite with cyan and line it up visually, but that's really clunky. Surely there's a better way?

The function gimp-item-transform-translate was added in GIMP 2.10. This function takes an ITEM and two FLOATs - x offset and y offset. A simple Script-Fu script with two parameters to specify the offset and then call the above function would be one answer.

If the movement was always the same you could set this as the default values of the parameters. If you if you had a defined set of movements you could code them as drop-down values - either for x and y independently or a single box that gave the x/y offsets.


RE: Move Selection by given number of pixels - programmer_ceds - 08-04-2020

The benefit of using a script that calls gimp-item-transform-translate is that it looks as though this function doesn't use interpolation (I haven't checked the source code but the pdb doesn't say that it is affected by the selected interpolation, where other transform functions say that they are affected in this way) - whereas the Unified Transform tool will use interpolation - something that you don't want for a simple move.

If you were using a simple 'step and repeat' process (moving, say, to the right the same number of pixels each time) you could just use Ctrl-F to repeat the script.