It is currently 21 Jan 2018, 06:19

GIMP Python Fu ScriptsPancake or Cookie Script Fixed 2.8.16 up to 22 (Showcase | Slideshow)

Share your Python Fu scripts for GIMP here
User avatar
animicule

Script Coder
View: Showcase | Slideshow
Topic Posts: 38/60
Posts: 601
Joined: 10 Jan 2017, 07:25
Cash on hand: 738.85 GLP
Bank: 45,987.00 GLP
Gender: Guy
Location: South Dakota
Operating System: Windows
GIMP Version: 2.9.5
x 168
United States of America

Re: Pancake or Cookie Script V2

Post#22 by animicule » 02 Jun 2017, 07:14


Tin,
What version are your using (GIMP).
I didn't really want to update until the Major change, but
since I have no errors and others do, I suppose that
I may have to.
Something is different.
0 x




Registered members enjoy ads-free content
User avatar
tim
Administrator
View: Showcase | Slideshow
Topic Posts: 14/60
Posts: 2071
Joined: 25 Sep 2016, 17:16
Cash on hand: 7,180.19 GLP
Bank: 42,250.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1106
x 240
Contact:
Canada

Post#23 by tim » 02 Jun 2017, 07:19


I am using GIMP 2.8.22.
0 x



aka Tin
Image gimplearn.net                                              

User avatar
Issabella
Script Tester
View: Showcase | Slideshow
Topic Posts: 4/60
Posts: 1801
Joined: 19 Jan 2017, 03:42
Cash on hand: 14,444.02 GLP
Gender: Gal
Operating System: Windows
x 213
x 466
Spain

Post#24 by Issabella » 02 Jun 2017, 09:37


I'm using Gimp 2.8.18 version, animicule.
I tried it with your version 2.
Attachments
Gimp_2.8.18_Issa.JPG
Gimp_2.8.18_Issa.JPG # (90.68 KiB) Viewed 137 times (Watermarked | Thumbnail)
0 x



Issabella

User avatar
animicule

Script Coder
View: Showcase | Slideshow
Topic Posts: 38/60
Posts: 601
Joined: 10 Jan 2017, 07:25
Cash on hand: 738.85 GLP
Bank: 45,987.00 GLP
Gender: Guy
Location: South Dakota
Operating System: Windows
GIMP Version: 2.9.5
x 168
United States of America

Post#25 by animicule » 02 Jun 2017, 10:36


Sorry Issabella.
I think there is a bug in GIMP above 2.8.16 in layer group.
Something changed.
0 x




User avatar
animicule

Script Coder
View: Showcase | Slideshow
Topic Posts: 38/60
Posts: 601
Joined: 10 Jan 2017, 07:25
Cash on hand: 738.85 GLP
Bank: 45,987.00 GLP
Gender: Guy
Location: South Dakota
Operating System: Windows
GIMP Version: 2.9.5
x 168
United States of America

Post#26 by animicule » 03 Jun 2017, 09:42


I suspected a bug in GIMP 2.8.18 and up.
My unpack function was
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
def unpack_group(iworkLay):
gworkLay = iworkLay
global gworkLay
parent = pdb.gimp_item_get_parent(gworkLay)
totalnum,position = pdb.gimp_item_get_children(parent)
lay = gimp.Item.from_id(position[totalnum-1])
pdb.gimp_image_set_active_layer(img,lay)
drawable = pdb.gimp_image_get_active_drawable(img)
pdb.gimp_edit_copy(drawable)
layer_copy = pdb.gimp_layer_new_from_drawable(drawable,img)
pdb.gimp_image_add_layer(img,layer_copy, -1)
pdb.gimp_image_set_active_layer(img,gworkLay)
drawable = pdb.gimp_image_get_active_drawable(img)
gworkLay = pdb.gimp_layer_new_from_drawable(drawable,img)
pdb.gimp_image_add_layer(img,gworkLay, -1)
pdb.gimp_image_remove_layer(img,parent)

return gworkLay
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
This was working fine in Gimp 2.8.16
But in newer version 2.8.18 and 2.8.22
errors were caused by
pdb.gimp_image_add_layer(img,layer_copy, -1)
So, I thought something wrong with 2.8.18 and above....
After some further inspection, I tried changing
--------------------------------------------------------------------------------
pdb.gimp_image_add_layer(img,layer_copy, -1) and
pdb.gimp_image_add_layer(img,gworkLay, -1)
--------------------------------------------------------------------------------
to
--------------------------------------------------------------------------------
pdb.gimp_image_add_layer(img,layer_copy, 0) and
pdb.gimp_image_add_layer(img,gworkLay, 0)
--------------------------------------------------------------------------------
and to my surprise the layers were still copied out of the layergroup!!

So, now I think maybe something was fixed after 2.8.16
as it didn't seem right to me that either -1 or 0 should both
work with no errors from either.

Then I went to the pdb browser and found
image_add_layer
Deprecated: Use 'gimp_image_insert_layer' instead.

From gimp_image_insert_layer it said:

This procedure adds the specified layer to the image at the given position.
If the specified parent is a valid layer group (See 'gimp-item-is-group' and 'gimp-layer-group-new') then the layer is added inside the group.
If the parent is 0, the layer is added inside the main stack, outside of any group.
The position argument specifies the location of the layer inside the stack (or the group, if a valid parent was supplied), starting from the top (0) and increasing.
If the position is specified as -1 and the parent is specified as 0,
then the layer is inserted above the active layer, or inside the group
if the active layer is a layer group.
The layer type must be compatible with the image base type.
===
I had trouble inserting a new layer outside of the layer group
parameters were
image IMAGE The image
layer LAYER The layer
parent LAYER The parent layer
position INT 32 The layer position
===
so made
-----------------
global oriSUB #(original subject layer which is outside of the group)
-----------------
and replaced the depreciated commands with
--------------------------------------------------------------------------------
parent = pdb.gimp_item_get_parent(oriSUB)
--------------------------------------------------------------------------------
and
--------------------------------------------------------------------------------
pdb.gimp_image_insert_layer(img, layer_copy,oriSUB,0)
--------------------------------------------------------------------------------

Please test the new revision and let me see
what I hope will finally be a nice error-free outcome!
0 x




User avatar
animicule

Script Coder
View: Showcase | Slideshow
Topic Posts: 38/60
Posts: 601
Joined: 10 Jan 2017, 07:25
Cash on hand: 738.85 GLP
Bank: 45,987.00 GLP
Gender: Guy
Location: South Dakota
Operating System: Windows
GIMP Version: 2.9.5
x 168
United States of America

Post#27 by animicule » 03 Jun 2017, 09:46


A new example - with the revision.
Attachments
multi01.png
multi01.png # (471.24 KiB) Viewed 120 times (Watermarked | Thumbnail)
0 x




User avatar
tim
Administrator
View: Showcase | Slideshow
Topic Posts: 14/60
Posts: 2071
Joined: 25 Sep 2016, 17:16
Cash on hand: 7,180.19 GLP
Bank: 42,250.25 GLP
Gender: Guy
Location: Victoria, BC
Website: https://gimplearn.net
Operating System: Windows
GIMP Version: 2.8.22
My Personal Blog
My FineArtAmerica
x 1106
x 240
Contact:
Canada

Post#28 by tim » 03 Jun 2017, 09:47


revision gave me this error:
Traceback (most recent call last):
File "C:\Program Files\GIMP 2\32\lib\gimp\2.0\python\gimpfu.py", line 736, in response
dialog.res = run_script(params)
File "C:\Program Files\GIMP 2\32\lib\gimp\2.0\python\gimpfu.py", line 361, in run_script
return apply(function, params)
File "C:\Users\Tim\.gimp-2.8\plug-ins\BA_Pancake_r1.py", line 191, in BA_PANCAKE_r1
unpack_group(workLay)
File "C:\Users\Tim\.gimp-2.8\plug-ins\BA_Pancake_r1.py", line 38, in unpack_group
totalnum,position = pdb.gimp_item_get_children(parent)
RuntimeError: Procedure 'gimp-item-get-children' has been called with value '-1' for argument 'item' (#1, type GimpItemID). This value is out of range.
0 x



aka Tin
Image gimplearn.net                                              

Post Reply

Last 20 Members Who Visited This Topic

User avatar PhotoMaster (2), User avatar gnerd (13), User avatar tim (2)

  • Similar Topics
    Replies
    Views
    Last post
• Featuring Members' Works (Image Attachments Only) •
1: RJKD
2: tim
3: oldmangrumpy
4: tim
5: tim
6: RJKD
7: gnerd

Who is online

Users browsing this forum: No registered users and 1 guest