Gimp-Forum.net
Editing Plug-in "ofn-export-layers-combinations" - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+--- Thread: Editing Plug-in "ofn-export-layers-combinations" (/Thread-Editing-Plug-in-ofn-export-layers-combinations)



Editing Plug-in "ofn-export-layers-combinations" - joedana - 05-20-2024

Hello, 

I am hoping that i could get some guidance regarding an edit i am trying to do to the .py file "ofn-export-layers-combinations" authored by 'Ofnuts'. 

I want to be able to export images that doesnt alternate in combination but in parallel. Here is what i mean:

image.layers:

Layer A (linked)

       Group Layer B (linked)

                Layer B1 (visible)

                Layer B2 (visible)

                Layer B3 (visible)

Layer C (linked)

      Group Layer D (linked)

                Layer D1 (visible)

                Layer D2 (visible)
                Layer D3 (visible)
Layer E (linked)

Id want Layer A, Layer C, and Layer E to always remain visible and present in the image. Group B and Group D would fluctuate in parallel, meaning B1 and D1 would be stored in a list together, visible on the image, and exported. Second export will contain [B2, D2]. Third Export will contain [B3,D3]. 

These are the steps i have taken so far:

Swapped out line 84: "for i,layers in enumerate(product(*combinableLayers)):" to "for i,layers in enumerate(zip_longest(*combinableLayers)):". And the plug-in isnt coming up anymore meaning I need to make other changes for the code to work. What other changes do I need to implement for this to work? Are we even allowed to edit plug-ins? Guidance would be appreciated.


RE: Editing Plug-in "ofn-export-layers-combinations" - Ofnuts - 05-20-2024

(05-20-2024, 03:49 PM)joedana Wrote: Hello, 

I am hoping that i could get some guidance regarding an edit i am trying to do to the .py file "ofn-export-layers-combinations" authored by 'Ofnuts'. 

I want to be able to export images that doesnt alternate in combination but in parallel. Here is what i mean:

image.layers:

Layer A (linked)

       Group Layer B (linked)

                Layer B1 (visible)

                Layer B2 (visible)

                Layer B3 (visible)

Layer C (linked)

      Group Layer D (linked)

                Layer D1 (visible)

                Layer D2 (visible)
                Layer D3 (visible)
Layer E (linked)

Id want Layer A, Layer C, and Layer E to always remain visible and present in the image. Group B and Group D would fluctuate in parallel, meaning B1 and D1 would be stored in a list together, visible on the image, and exported. Second export will contain [B2, D2]. Third Export will contain [B3,D3]. 

These are the steps i have taken so far:

Swapped out line 84: "for i,layers in enumerate(product(*combinableLayers)):" to "for i,layers in enumerate(zip_longest(*combinableLayers)):". And the plug-in isnt coming up anymore meaning I need to make other changes for the code to work. What other changes do I need to implement for this to work? Are we even allowed to edit plug-ins? Guidance would be appreciated.

The plugin is distributed with a GPL licence so you can do anything with it but if you redistribute your version you must distribute the source with it. The license also mandates that you make it clear that this is your code and no longer mine (but you can acknowledge the borrowing...): header, and the two fields in the registration. A recommended first change its to 1) rename the file (the ofn prefix is my signature and the edited file is fully yours) and 2) rename the "atom" (line 123) using your own signature/prefix (to avoid clashes with my plugin)

If the plugin doesn't appear in the menu you probably have a syntax error somewhere that makes it crash before it can run (a typical error is a bad indentation). See Debugging python-fu scripts in Windows for several hints to debug such problems (on windows and elsewhere).

Finally, your output being a subset of the combinations generated by the script, and since the script names the outputs using the included layer names, a lazy way to achieve your goal is to run the original script and erase the extra files.

PS: You got me thinking and I could add a product/parallel option in the script, but give me couple of days to figure out the consequences (I have to do a lot more testing a cover more corner cases than you have to).