Hello,
I'm new to scripting in Gimp with python, but I've had a lot of success in the past two days. Here's the overview:
I'm using Gimp to mock-up prototypes of card games. (I know I'll be told to use another program, but I like Gimp!) I have tons of text boxes on the cards with some needing rotated 180 degrees, icons, and labels. I have a python script that reads everything it needs from a CSV, populates the text boxes, changes card borders, adjusts icons, and even makes new layer of text and rotates them 180 as needed. It then merges everything down into a new image, saves the image in a directory, deletes the fresh image, and starts the process again for the next card. All fine and good.
However, after rotating the text box, I can't delete the layer. Since I'm making 100 cards with 3 places of rotated text, I figure having 300 new layers adding to the image would cause some bad things to happen.
Specifically, during the process, I create a new text layer, add the necessary text, name it 'rotatedNoun', calculate the center of rotation, and rotate it 180 degrees (using math.pi and radians). After saving the new image, I want to delete the layer 'rotatedNoun' to prevent 300 new layers from stacking up and crashing Gimp.
I have tried the following:
1) pdb.gimp_item_delete(rotatedNoun)
I know this won't work because the description of the function says that the layer can't already be added to the image.
2) pdb.gimp_image_remove_layer(image, 'rotatedNoun')
This method works if I use it in the Python console, but when I try using it in the script, the script will not load when Gimp is started. I know it is this specific line because when I comment it out, the script loads just fine in Gimp. Not sure why it works in the console but not as part of the script?
3) image.remove_layer('rotatedNoun')
Again, this method works in the Python console but not in the script because the script won't load when Gimp is started. The same thing happens in that when I comment out this single line, the script will load fine.
This is the last piece of my crazy puzzle, and I'd appreciate any help that you can offer. Thank you!