How to copy guide lines in The Gimp?
Question
Is it possible to copy guide lines from one image to another?
I need this because I have several images that need exactly the same composition, so I want to use the guide lines for this.
There's no option to select & copy a guide line, so I must add them manually.
It would be nice, if there's a little script-fu script.
Okay, there are some interesting functions I found:
(gimp-image-find-next-guide image index)
(gimp_image_add_hguide image xposition)
(gimp_image_add_vguide image yposition)
(gimp_image_get_guide_orientation image guide)
(gimp_image_get_guide_position image guide)
Thanks in advance!
Solution
I'd really like to help you but I'm not sure I understand what you are trying to do. Could you edit the question to provide more details?
At a guess (pending more information) are you looking for something like this?
guide = 0
while guide = gimp_image_find_next_guide (image_1,guide) != 0
position = gimp_image_get_guide_position (image_1,guide)
if gimp_image_get_guide_orientation (image_1,guide) == 0
gimp_image_add_hguide (image_2,position)
else
gimp_image_add_vguide (image_2,position)
Note that this is pseudo-code, since the functions you mentioned seem to be part of an API that is using a syntax other than scheme-ish script fu.
But the first question is what are you trying to accomplish? -- after that we can worry about the details of how.
OTHER TIPS
Having been wanting to learn Gimp Scripts (PythonFu) for a while and requiring this functionality I used the Pseudo code provided by MarkusQ and this handy tutorial https://jacksonbates.wordpress.com/python-fu-gimp-scripting-tutorial-pages/ to create a script to copy guidelines from one image to another.
#!/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()
You'll need to copy this in to a CopyGuidelines.py file and put it your Gimp's plugin directory (See Preferences > Folders ) and restart Gimp to see the CopyGuideline option under Tools. Then open up the two images, select the one with the Guidelines and select CopyGuidelines to run the script.