It is currently Sun Jun 30, 2024 1:51 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Help with pdb.plug_in_displace when using python-fu
PostPosted: Tue Feb 25, 2020 3:52 am  (#1) 
Offline
New Member

Joined: Feb 25, 2020
Posts: 2
I'm trying to write a plugin for realistically blending tattoos to facial images, but I am unable to get any effect when using pdb.plug_in_displace in version 2.10 of GIMP. Note, that the displacement works if I manually go to Filters -> Map -> Displace and uses the same tattoo image and displacement map.

A sample of my code is given below:

img = gimp.Image(width, height)
pdb.gimp_display_new(img)

# load face and tattoo images
face_layer = open_images_as_layer(img, path_to_facial_image)
tattoo_layer= open_images_as_layer(img, path_to_tattoo_image)

# rescale tattoo layer
pdb.gimp_layer_scale(tattoo_layer, new_width, new_height, False)

# set offset of tattoo_layer
pdb.gimp_layer_set_offsets(tattoo_layer, x_offset, y_offset)

# set the tattoo_layer we want to displace to be the same size as the image
pdb.gimp_layer_resize_to_image_size(tattoo_layer)

# load the displacement map
disp_image = pdb.gimp_file_load(disp_file, disp_file)
disp_drawable = pdb.gimp_image_get_active_layer(disp_image)   

# this line does not seem to do anything no matter how I set the parameters
pdb.plug_in_displace(img, tattoo_layer, 10, 10, True, True, disp_drawable, disp_drawable, 2)


Any suggestions to why the displacement (in the last line of the code above) has no effect - is really appreciated

Thanks!


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Help with pdb.plug_in_displace when using python-fu
PostPosted: Tue Feb 25, 2020 4:43 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2260
Location: Poland
Hi i-regular.

You used the wrong number of parameters - lack: run_mode=......
pdb.plug_in_displace(img, tattoo_layer, 10, 10, True, True, disp_drawable, disp_drawable, 2, run_mode=RUN_NONINTERACTIVE)


Attachments:
displace.png
displace.png [ 22.94 KiB | Viewed 1589 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: Help with pdb.plug_in_displace when using python-fu
PostPosted: Tue Feb 25, 2020 5:04 am  (#3) 
Offline
New Member

Joined: Feb 25, 2020
Posts: 2
Thanks - I forgot to tell that I was running the plugin from within GIMP, so I believe in that case I do not need to specify the run-mode? But, I will need to run it later from batch, so thanks for pointing out!

I found the issue. There seems to be an error in version 2.10.14 of GIMP where the procedure does not work. I just upgraded to version 2.10.18 and now it seems to work also without specifying the run-mode i.e. with no modifications to the code above. Also I tried version 2.8.22 of GIMP where it also works!

Anyhow thanks for the help - I really appreciate it!


Top
 Post subject: Re: Help with pdb.plug_in_displace when using python-fu
PostPosted: Tue Feb 25, 2020 7:47 am  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
MareroQ wrote:
Hi i-regular.

You used the wrong number of parameters - lack: run_mode=......
pdb.plug_in_displace(img, tattoo_layer, 10, 10, True, True, disp_drawable, disp_drawable, 2, run_mode=RUN_NONINTERACTIVE)


You never *need* that run_mode parameter. It's a named parameter because it is optional in the Python API (and defaults to RUN_NONINTERACTIVE, so you typically only use it with RUN_INTERACTIVE). The doc mentions it because the Python doc is built from the Scheme one, but there are mappings between the Python and Scheme.

_________________
Image


Top
 Post subject: Re: Help with pdb.plug_in_displace when using python-fu
PostPosted: Tue Feb 25, 2020 10:07 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2260
Location: Poland
Quote:
... the Python doc is built from the Scheme one, but there are mappings between the Python and Scheme


This is what I understand now why in script-fu this is the first parameter and in python the last - if needed (because erroneously indicated in the Python Procedure Browser also as the first by stupid analogy).

Thanks for the clarification.

_________________
Image

Slava
Ukraini!


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Don't work procedures plug-in-bump-map, plug-in-displace

2

No new posts use in python of plug-in lighting

4

No new posts Attachment(s) GIMP Python-Fu Plug-in template

4

No new posts GIMP 2.10 doesn't install my python plug-ins

1

No new posts Plug-in crashes after OS upgrade: python version mismatch? maybe?

4



* Login  



Powered by phpBB3 © phpBB Group