将图层移动到 Gimp 中的特定 X、Y 位置

Sco*_*ott 70 gimp

如何将图层移动到 Gimp 画布内的特定 XY 位置?

目前,我能找到的唯一方法就是用指南和/或鼠标位置注视它。我想指定确切的 X 和 Y 坐标。

tot*_*ico 35

恐怕 Gimp 不包括它,因为它很乏味。在设计时,这根本不是对齐元素的适当方式,尽管我认识到有时它作为捷径很有用。无论如何,最好(正确)的方法是使用指南:


A) 第 1 步 - 创建指南

  1. 转到图像->指南->新指南
  2. 指定是否需要水平或垂直指南
  3. 指定像素数
  4. 对另一个水平或垂直参考线重复此过程(您也可以做更多参考线来指定宽度和高度)

或者,您也可以创建从标尺拖动的参考线:

  1. 向下拖动(从顶部标尺开始)指向所需 Y 坐标的参考线。
  2. 向下拖动(从左侧标尺开始)指向所需 X 坐标的参考线。

B) 第 2 步 - 移动画布

您可以使用移动工具。

  1. 选择您的图层
  2. 转到工具 -> 转换工具 -> 移动
  3. 将图层拖动到参考线。Gimp 将为您提供精确像素的帮助。

设计原则之一是您应该在整个项目中保持一致。减少对齐(参考线)的数量有助于您获得更简洁的设计。我认为这就是 gimp 不包含指定精确坐标的工具的原因。如果要遵循这个设计原则,一个一个地指定精确坐标就变得很乏味了。


Dav*_*vid 27

  1. 挑选 在此处输入图片说明 (对齐工具)。
  2. 让它Relative to Image
  3. 单击您的图层(在画布中)。
  4. Offset字段中输入 X。
  5. 点击Distribute/在此处输入图片说明 (左箭头)。
  6. Offset字段中输入 Y。
  7. 点击Distribute/在此处输入图片说明 (向上箭头)。

就是这样!


小智 20

有一个脚本可以执行此操作,可以从 GIMP 插件注册表下载。它被称为:

将图层移至(下载)

安装:

  1. 将脚本移动到%USERPROFILE\.gimp-2.8\scriptsWindows、~/Library/Application Support/GIMP/2.8/scriptsOS X 或~/.gimp-2.8/scriptsLinux上的目录。(官方说明

  2. 点击Filters-> Script-Fu-> Refresh scripts

  3. 新菜单项将出现在Layer菜单底部Move to

  • 您需要下载该 .scm 文件并将其放入 Windows 上的 `%USERPROFILE%\.gimp-2.8\scripts` 中,然后执行 `Filters`->`Script-Fu`->`Refresh Scripts` 即可使用作为最底部的项目`Layer`->`Move To` (4认同)
  • Davids 的回答无需脚本即可完成工作。 (3认同)

小智 12

我正在使用 GIMP 2.6.11。

使用 Python 的这些行,活动层可以从 Python 控制台移动到绝对位置,如 (32, 64):

>>> x_new = 32
>>> y_new = 64
>>> img = gimp.image_list()[0]
>>> layer = img.layers[0]
>>> x_off, y_off = layer.offsets
>>> pdb.gimp_layer_translate(layer, x_new - x_off, y_new - y_off)
Run Code Online (Sandbox Code Playgroud)

或者你可以更简单地使用gimp_layer_set_offsets像:

pdb.gimp_layer_set_offsets(layer, x_new, y_new)
Run Code Online (Sandbox Code Playgroud)

或者,如果您只想移动图层的内容:

右键单击,图层 -> 变换 -> 偏移

Shift+ Ctrl+ O

  • 你的第三行代码应该是`img=gimp.image_list()[0]`。_ 对我不起作用。 (3认同)

dan*_*tra 6

自 Gimp v.2.10 以来,有一种非常方便的方法可以做到这一点:

  1. 双击要移动的图层(或右键单击它并选择“编辑图层属性”)

  2. 将显示“编辑图层属性”对话框,您可以在那里根据需要更改 X/Y 偏移

就这么简单!:)

编辑图层 X/Y 偏移属性

编辑:

正如@Michael 在对我的回答的评论中询问的那样,我正在添加一个脚本,该脚本将按指定的 x,y 偏移量移动所有图像层。

要使其工作,您需要在 Gimp 脚本文件夹中创建一个文件(如果需要,请参考: 这里 或者 这里) 具有以下内容:

; 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/")
Run Code Online (Sandbox Code Playgroud)

如果你做对了,你会在“图层”菜单中找到一个名为“移动所有图层...”的新命令,启动它,会出现一个对话框,让你决定 X 和 Y 偏移。就是这样。