It is currently Tue Jun 23, 2026 2:13 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Adding a image as a layer, moving layer, and then flattening
PostPosted: Sun Jan 24, 2021 1:03 pm  (#1) 
Offline
New Member

Joined: Jan 24, 2021
Posts: 1
I'd like to ask for help with a problem I'm having issues solving: I'm trying to load an image as a new layer, move that layer to a set of coordinates, and then flatten the image so I can repeat the process.

To clarify, the coordinates in datalist and lines are for a big red X to place over a calendar based on the day. I've already gotten all of that working, but actually importing the X image into the working image and then flattening it is either saving as the default calendar (no Xs), or in this case bringing up an error:
Quote:
GIMP Error
Calling error for procedure 'gimp-image-insert-layer':
Item 'TheX.bmp' (561) has already been added to an image

for x in datelist:
        new_image_layer = pdb.gimp_file_load_layer(image, "C:\\Users\\Bet-C\\Desktop\\TheX.bmp")
        pdb.gimp_image_insert_layer(image, new_image_layer, None, 2)
        pdb.gimp_layer_set_offsets(new_image_layer, int(lines[int(x/7)+2]), int(lines[int(x%7)+8]))
        layer = pdb.gimp_image_flatten(image)
        pdb.gimp_image_insert_layer(image, layer, None, 1)

I'm pretty sure its an easy solution, but I can't seem to parse through the examples online without confusing my own attempts.


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: Adding a image as a layer, moving layer, and then flattening
PostPosted: Mon Jan 25, 2021 12:13 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
I'm pretty sure that the layer you get from pdb.gimp_image_flatten(image) is already added to the image.

Instead of flattening the image, you can use "layer = pdb.gimp_layer_new_from_visible(image, dest_image, name)" and save that layer...

_________________
Image


Top
 Post subject: Re: Adding a image as a layer, moving layer, and then flattening
PostPosted: Mon Jan 25, 2021 10:53 pm  (#3) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 8389
Location: On the other side of your screen
or if it is the 'X; you want to add again, "duplicate" your layer,
Image Duplicate icon with red border
move each layer after you select it then merge all layers instead of flattening to keep the trasparency I did one as shown in the xcf below


Attachments:
February-2021-Calendar.xcf [581.53 KiB]
Downloaded 248 times

_________________
Image
Free Fun Photo Editing & resources
Poems from the Lord
Gimp Newby
Gimp version 3.2.0 and GMIC-Qt 3.7.5 OS :- Windows 10 Home 64
Top
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group