一直想学习 Gimp Scripts (PythonFu) 并需要这个功能,我使用了 MarkusQ 提供的伪代码和这个方便的教程https://jacksonbates.wordpress.com/python-fu-gimp-scripting-tutorial-pages /创建一个脚本以将指南从一个图像复制到另一个图像。
#!/usr/bin/env python
from gimpfu import *
def CopyGuidelines(image_1, drawable, image_2):
guide = pdb.gimp_image_find_next_guide(image_1, 0)
while guide != 0 :
position = pdb.gimp_image_get_guide_position (image_1,guide)
if pdb.gimp_image_get_guide_orientation (image_1,guide) == 0:
pdb.gimp_image_add_hguide (image_2,position)
else:
pdb.gimp_image_add_vguide (image_2,position)
guide = pdb.gimp_image_find_next_guide (image_1,guide)
register(
"python-fu-CopyGuidelines",
"Copy Guidelines",
"Copy Guidelines from one image to another",
"Anthony", "JustAGuyCoding", "2017",
"Copy Guidelines",
"", # type of image it works on (*, RGB, RGB*, RGBA, GRAY etc...)
[
(PF_IMAGE, "image_1", "takes current image", None),
(PF_DRAWABLE, "drawable", "Input layer", None),
(PF_IMAGE, "image_2", "takes other image", None)
],
[],
CopyGuidelines, menu="<Image>/Tools")
main()
您需要将其复制到 CopyGuidelines.py 文件中,并将其放入 Gimp 的插件目录(请参阅 Preferences > Folders )并重新启动 Gimp 以查看 Tools 下的 CopyGuideline 选项。然后打开两张图片,选择带有指南的一张并选择 CopyGuidelines 以运行脚本。