It is currently Thu Jul 04, 2024 5:02 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: solved] How to mimic File > Open as Layers from within a python script
PostPosted: Tue Jun 20, 2017 6:10 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Dec 26, 2014
Posts: 199
Inside my python script these four lines of code open two .xcf files which are displayed in seperate windows, how do i code it so as to open both images into a single stack in the same window (as in File > Open as Layers)

image_1 = pdb.gimp_xcf_load(0,"C:\\Users\\SteveMi\\.gimp-2.8\\plug-ins\\red.xcf", "red.xcf")
display = pdb.gimp_display_new(image_1)

image_2 = pdb.gimp_xcf_load(0,"C:\\Users\\SteveMi\\.gimp-2.8\\plug-ins\\green.xcf", "green.xcf")
display = pdb.gimp_display_new(image_2)

TIA

steve


Last edited by Steve on Wed Jun 21, 2017 6:15 am, edited 1 time in total.

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: How to mimic, File > Open as Layers from within a python script
PostPosted: Tue Jun 20, 2017 6:45 am  (#2) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
The procedure browser is your friend:
Attachment:
Untitled.png
Untitled.png [ 37.94 KiB | Viewed 3579 times ]


Top
 Post subject: Re: How to mimic, File > Open as Layers from within a python script
PostPosted: Tue Jun 20, 2017 6:53 am  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
You can also copy the layers between opened images, something like:

for layer in reversed(image2.layers):
    layerCopy=pdb.gimp_layer_new_from_drawable(layer,image1)
    image1.add_layer(layerCopy,0);


Useful if you don't intend to keep all the layers, or if you reposition them.

_________________
Image


Top
 Post subject: Re: How to mimic, File > Open as Layers from within a python script
PostPosted: Tue Jun 20, 2017 8:25 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Dec 26, 2014
Posts: 199
Thanks paynekj, this puts me on the right track. I do use the PB but sometimes am unsure which of the similar procedures to use

Thanks ofnuts, this is great and helps a lot, though you do drop a point for the missing underscores ;) , first run nothing happened but its ok now

steve


Top
 Post subject: Re: How to mimic, File > Open as Layers from within a python script
PostPosted: Tue Jun 20, 2017 9:35 am  (#5) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
Which missing underscores? Copy/pasted from my editor, and copy/pasted to Gimp's Python console to check.

_________________
Image


Top
 Post subject: Re: How to mimic, File > Open as Layers from within a python script
PostPosted: Tue Jun 20, 2017 9:58 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Dec 26, 2014
Posts: 199
ofnuts wrote:
Which missing underscores? Copy/pasted from my editor, and copy/pasted to Gimp's Python console to check.

Ah I see, my bad :oops: , sorry. I copied your code straight into my python script and ran it, after nothing happened I noticed you had used image2 whereas I had used image_2

steve


Top
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) GIMP Unable to open .xcf file

13

No new posts Can't open files 'Unknown file type'

7

No new posts Attachment(s) Trying to open as layers 3 til files Red, Green, Blue, Filter images

2

No new posts Performance of adjusting layers and exporting with Python Fu

5

No new posts Load As Layers Wire Initialization Error With Python

6



* Login  



Powered by phpBB3 © phpBB Group