59
13
How do I move a layer to a specific XY position within the canvas in Gimp?
Currently, the only way I can find is to just eyeball it with the guides and/or mouse position. I want to specify the exact X and Y coordinates.
59
13
How do I move a layer to a specific XY position within the canvas in Gimp?
Currently, the only way I can find is to just eyeball it with the guides and/or mouse position. I want to specify the exact X and Y coordinates.
32
I am afraid that Gimp doesn't include it because it is tedious. It is simply not the appropriate way of aligning elements when you are designing, though I recognize that sometimes it is useful as a short-cut. Anyway, the best (correct) approach is with guides:
A) Step 1 - Create the guides
Alternatively, you can also create the guides dragging from the rulers:
B) Step 2 - Move the canvas
You can use the moving tool.
One of the design principle is that you should have things align in your whole project. Reducing the number of alignments (guides) helps you getting a cleaner design. I think this is why gimp does not include a tool to specify the exact coordinates. If you want to follow this design principle specifying exact coordinates one by one becomes just a tedious labour.
Exactly what I need - thanks. Use case: creating a wallpaper for dual-head setup from two other wallpapers. :) – smbear – 2013-12-10T11:21:13.643
24
1This work for negative offset. – Loda – 2015-11-02T15:33:15.463
1Note that it seems that you can only select the top visible layer — that is, one has to hide layers on top of the layer to be aligned (gimp 2.8.16). – Skippy le Grand Gourou – 2016-07-22T19:53:16.573
Does this use the unit of pixels? It seems to move my image far more than I would expect. – palswim – 2016-09-07T22:38:43.543
@palswim For me it worked when I clicked the top group of buttons (Align) instead of the bottom group (Distribute). Yes, it's measured in pixels (at least in my configuration). – Rodrigo – 2017-04-09T14:01:15.997
20
There is a script to do this that can be download from the GIMP Plugin registry. It is called:
Move the script to %USERPROFILE\.gimp-2.8\scripts
directory on Windows, ~/Library/Application Support/GIMP/2.8/scripts
on OS X or ~/.gimp-2.8/scripts
on Linux. (Official instructions)
Clicks Filters
-> Script-Fu
-> Refresh scripts
.
The new menu item will appear at the bottom of the Layer
menu Move to
.
Not exactly "move a layer", but related: there is "pastexy.py
-- Paste the clipboard at location X,Y" from the post: Pasting at a specific location - comp.graphics.apps.gimp
3Davids answer does the job without a script. – Michael S. – 2015-10-06T08:41:51.613
1Does NOT work for negative offset. and the UX is poor (don't keep the last value, etc). – Loda – 2015-11-02T15:35:15.170
For some reason this always hangs on gimp-displays-flush
. :/ – haykam – 2017-10-17T02:05:35.470
Nice first answer! – slm – 2013-01-07T04:21:23.847
Almost perfect! Would be nice if the parameter dialog used the layer's current coordinates as the default values. – Oliver Giesen – 2013-01-25T23:39:13.310
4You need to download that .scm file and put it into %USERPROFILE%\.gimp-2.8\scripts
on Windows, then do Filters
->Script-Fu
->Refresh Scripts
and it will be available as the bottom most item Layer
->Move To
– DarkWalker – 2014-01-10T20:00:53.253
11
I'm using GIMP 2.6.11.
With these lines of Python the active layer can be moved to an absolute position, like (32, 64), from the Python console:
>>> x_new = 32
>>> y_new = 64
>>> img = _[0]
>>> layer = img.active_layer
>>> x_off, y_off = layer.offsets
>>> pdb.gimp_layer_translate(layer, x_new - x_off, y_new - y_off)
Alternatively, if you only want to move the content of the layer:
right-click, Layer > Transform > Offset
or Shft+Ctrl+O
1This causes the pixels within the layer to move, rather than the layer itself - I need to move the actual layer. What you suggested may work if the layer is the same size as the canvas, or at least big enough not to clip any non-transparent pixels within the layer. – Scott – 2011-07-07T19:55:17.137
@Scott: I see - sorry I didn't find an easier way, but at least I figured out how to move the layer to an absolute position with some lines of Python. – Nicolas Kaiser – 2011-07-07T21:32:51.820
3Line three of you code should be img=gimp.image_list()[0]
. The _ didnt work for me. – apple16 – 2012-07-23T21:58:30.920
3
There's a very convenient way to do this available since the Gimp v.2.10:
double click on the layer you want to move (or right click on it and select "Edit Layer Attributes")
the "Edit Layer Attributes" dialog will show up and there you can change the X/Y offsets to your needs
Simply easy like that! :)
EDIT:
As @Michael asked about it in its comment to my answer, I'm adding a script that will move ALL image layers by specified x,y offsets.
To make it work you need to create a file in the Gimp script folder (some reference for this if you need it: or
)
with following content:
; This script is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This script is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;; Command is installed in "Layer->Move all layers..."
;;
;; The purpose of this script is to move all image layers by specified x,y offsets
;; X and Y offset parameters must be provided (use integer numbers as values)
;;
(define (dn-move-all-layers orig-image drawable
x-offset y-offset)
(define (get-all-layers img)
(let* (
(all-layers (gimp-image-get-layers img))
(i (car all-layers))
(bottom-to-top ())
)
(set! all-layers (cadr all-layers))
(while (> i 0)
(set! bottom-to-top (append bottom-to-top (cons (aref all-layers (- i 1)) '())))
(set! i (- i 1))
)
bottom-to-top
)
)
(define (move-layer orig-image layer-id offset-x offset-y)
(gimp-layer-set-offsets
layer-id
offset-x
offset-y
)
)
(let* (
(layers nil)
(layerpos 1)
(layer-id "")
(x-os 0)
(y-os 0)
(orig-selection 0)
)
(gimp-image-undo-disable orig-image)
(set! orig-selection (car (gimp-selection-save orig-image)))
(gimp-selection-none orig-image)
(set! x-os x-offset)
(set! y-os y-offset)
(set! layers (get-all-layers orig-image))
(while (pair? layers)
(move-layer orig-image (car layers) x-os y-os)
(set! layers (cdr layers))
(set! layerpos (+ layerpos 1))
)
(gimp-displays-flush)
(gimp-selection-load orig-selection)
(gimp-image-remove-channel orig-image orig-selection)
(gimp-image-undo-enable orig-image)
)
)
(script-fu-register "dn-move-all-layers"
"Move all layers..."
"Move each layer by specified x,y offsets."
"danicotra"
"danicotra"
"08/08/2019"
""
SF-IMAGE "Input image" 0
SF-DRAWABLE "Drawable" 0
SF-VALUE "X offset" "0"
SF-VALUE "Y offset" "0"
)
(script-fu-menu-register "dn-move-all-layers"
"<Image>/Layer/")
If you do it right you will find a new command in the "Layer" menu called "Move all layers...", launch it and a dialog will show up letting you to decide X and Y offsets. That's it.
Any way to make this a bit quicker when you have a lot of layers to move (as in hundreds)? It would be great if this thing could dock so I didn't have to bring it up for every layer! – Michael – 2019-05-05T19:46:58.710
1@Michael : Well, I guess you should go with some scripting in that case, similarly to Nicolas Kaiser suggested solution but looping on image layers... I just edited my answer to show you how, have a look. (I would have made a separate answer for it but the OP asked specifically for moving ONE layer, not all of them. If you ask a new question for this I'd be glad to answer there adding some screenshoots and all the rest ;-D) Cheers – danicotra – 2019-08-08T21:23:47.317
Yes it is possible. Read my answer. – David – 2015-06-18T11:40:16.877
I want to know this too, or how to do it in Photoshop. I made a question for that. http://superuser.com/questions/345669/move-a-layer-to-specific-x-y-position-in-photoshop
– Jonny – 2011-10-12T10:21:05.5931
Does not seem to be (easily) possible in GIMP without using Python code as detailed below: http://graphicdesign.stackexchange.com/a/6813/8841
– SabreWolfy – 2012-12-02T09:00:48.907