#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from gimpfu import *
# orientation: ORIENTATION_HORIZONTAL(0), ORIENTATION_VERTICAL(1)
# diff: 参考线之间的间隔
def add_multi_guides(orientation, diff):
imgs = gimp.image_list()
if len(imgs) == 0:
return
img = imgs[0]
w, h = img.width, img.height
endposition = None
add_guide = None
if orientation == ORIENTATION_HORIZONTAL:
assert diff < h, ‘diff too big‘
endposition = h
add_guide = pdb.gimp_image_add_hguide
elif orientation == ORIENTATION_VERTICAL:
assert diff < w, ‘diff too big‘
endposition = w
add_guide = pdb.gimp_image_add_vguide
else:
raise ValueError((‘orientation not valid: {0}‘).format(orientation))
# 清空原来的参考线
guide = pdb.gimp_image_find_next_guide(img, 0)
while guide != 0:
if orientation == pdb.gimp_image_get_guide_orientation(img, guide):
pdb.gimp_image_delete_guide(img, guide)
guide = 0
guide = pdb.gimp_image_find_next_guide(img, guide)
position = diff
while position < endposition:
add_guide(img, position)
position = position + diff
register(
"add_multi_guides",
# table snippet means a small piece of HTML code here
"Add fucking guides",
"long description",
"hangj",
"hangj",
"2020",
"Add Multi Guides...",
"",
[
(PF_OPTION, "orientation", "orientation", 0, ("HORIZONTAL", "VERTICAL")),
(PF_INT, "diff", "pixcels between guides", 1000)
],
[],
add_multi_guides,
menu="<Image>/Image/Guides"
)
main()
把脚本保存,放到 plug-ins 目录下,然后chmod +x filename
,重启 GIMP
原文:https://www.cnblogs.com/hangj/p/13338502.html