Mon Oct 04, 2021 10:50 am
Mon Oct 04, 2021 12:06 pm
Mon Oct 04, 2021 12:09 pm
layer = pdb.gimp_layer_new(image, width, height, type, name, opacity, mode) #Give the layer another name other than drawable
Mon Oct 04, 2021 12:55 pm
ofnuts wrote:The file-*-save procedure do not save the image, they save a layer. What happened in your case is likely that the initial layer is no more. If you merged things (gimp_image_flatten(), gimp_image_merge_down() and a few others) the result is a new layer, but the call returns the layer created. So you just have to keep that returned value.
If your image still has several layers at the end, instead of flattening you can also use gimp_layer_new_from_visible() and save the returned layer.
Mon Oct 04, 2021 2:23 pm
layer = pdb.gimp_image_get_layer_by_name(image, name)
Mon Oct 04, 2021 3:01 pm
Pocholo wrote:to get the layer again that you merged. Are you using GIMP's PPB or PDB? The procedure Browser is your best friend!
- Code:
layer = pdb.gimp_image_get_layer_by_name(image, name)
Mon Oct 04, 2021 3:53 pm
ecs1749 wrote:Pocholo wrote:to get the layer again that you merged. Are you using GIMP's PPB or PDB? The procedure Browser is your best friend!
- Code:
layer = pdb.gimp_image_get_layer_by_name(image, name)
I have the new_layer returned by several procedures I tried. That's not the problem.
What do I do with it? pdb.file_jpeg_save doesn't accept layer as a parameter.
pdb.gimp_image_flatten(image) #returns the layer object which is the result of the flattening and can be used for the save.
Mon Oct 04, 2021 4:12 pm
Pocholo wrote:ecs1749 wrote:Pocholo wrote:to get the layer again that you merged. Are you using GIMP's PPB or PDB? The procedure Browser is your best friend!
- Code:
layer = pdb.gimp_image_get_layer_by_name(image, name)
I have the new_layer returned by several procedures I tried. That's not the problem.
What do I do with it? pdb.file_jpeg_save doesn't accept layer as a parameter.
- Code:
pdb.gimp_image_flatten(image) #returns the layer object which is the result of the flattening and can be used for the save.
Mon Oct 04, 2021 6:59 pm
ecs1749 wrote:ofnuts wrote:The file-*-save procedure do not save the image, they save a layer. What happened in your case is likely that the initial layer is no more. If you merged things (gimp_image_flatten(), gimp_image_merge_down() and a few others) the result is a new layer, but the call returns the layer created. So you just have to keep that returned value.
If your image still has several layers at the end, instead of flattening you can also use gimp_layer_new_from_visible() and save the returned layer.
Thank you for the response.
I guessed that much. In fact, after the post, I did a pdb.gimp_image_merge_down to get a new layer but pdb.file_jpeg_save doesn't take layers as a parameter.
pdb.file_jpeg_save(image, drawable, filename, raw_filename, quality, smoothing, optimize, progressive, comment, subsmp, baseline, restart, dct)
I tried
pdb.gimp_image_set_active_layer(image, newLayer)
and that doesn't do anything.
So what do I do with the returned layer?
Mon Oct 04, 2021 7:17 pm
Mon Oct 04, 2021 7:49 pm
ofnuts wrote:ecs1749 wrote:ofnuts wrote:The file-*-save procedure do not save the image, they save a layer. What happened in your case is likely that the initial layer is no more. If you merged things (gimp_image_flatten(), gimp_image_merge_down() and a few others) the result is a new layer, but the call returns the layer created. So you just have to keep that returned value.
If your image still has several layers at the end, instead of flattening you can also use gimp_layer_new_from_visible() and save the returned layer.
Thank you for the response.
I guessed that much. In fact, after the post, I did a pdb.gimp_image_merge_down to get a new layer but pdb.file_jpeg_save doesn't take layers as a parameter.
pdb.file_jpeg_save(image, drawable, filename, raw_filename, quality, smoothing, optimize, progressive, comment, subsmp, baseline, restart, dct)
I tried
pdb.gimp_image_set_active_layer(image, newLayer)
and that doesn't do anything.
So what do I do with the returned layer?
Of course it does. A layer is a drawable (a drawable is a layer, a channel or a mask), so the "drawable" parameter should be the layer returned by pdb.gimp_image_merge_down().
Tue Oct 05, 2021 2:24 am
ecs1749 wrote:I am very comfortable with Python.
Tue Oct 05, 2021 2:54 pm
ofnuts wrote:ecs1749 wrote:I am very comfortable with Python.
Then you should have found this:
>>> layer=gimp.image_list()[0].active_layer
>>> layer.__class__.__mro__
(<type 'gimp.Layer'>, <type 'gimp.Drawable'>, <type 'gimp.Item'>, <type 'object'>)
Tue Oct 05, 2021 3:59 pm
Wed Oct 06, 2021 6:50 am
ecs1749 wrote:ofnuts wrote:ecs1749 wrote:I am very comfortable with Python.
Then you should have found this:
>>> layer=gimp.image_list()[0].active_layer
>>> layer.__class__.__mro__
(<type 'gimp.Layer'>, <type 'gimp.Drawable'>, <type 'gimp.Item'>, <type 'object'>)
Alright. You got me stumped. I know syntactically what these statements are but how would they have helped me realize "Drawable" means I can pass the "layer" to it?
For me as a newbie, I thought it's a typo for "Drawtable"!!!