Python script query
This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
Python script query | Lorgach | 09 Nov 19:56 |
Python script query | Chris Mohler | 09 Nov 21:15 |
Python script query | Ofnuts | 09 Nov 21:34 |
Python script query | Jernej Simončič | 10 Nov 01:08 |
Python script query | Lorgach | 12 Nov 01:13 |
Python script query | Ofnuts | 12 Nov 02:08 |
Python script query | Grue | 12 Nov 11:53 |
Python script query | Chris Mohler | 12 Nov 17:10 |
Python script query | Lorgach | 12 Nov 23:32 |
Python script query | Grue | 13 Nov 13:29 |
- postings
- 10
Python script query
Hi,
I’m trying to introduce myself to programming in Python for Gimp, however I’m having difficulty in trying to run some scripts and I’m hoping that some of the more knowledgeable members on the Forum will be able to give me some assistance.
In order to cut down on time, and also to gain experience I decided to modify some of the scripts that were written by experienced Python programmers to see what effects I could produce on various images. However, I have found that when I make even minor changes to a script and save the changed script to the ‘plug-ins’ folder under a new name, it will not show up in the Gimp Drop Down Menu specified in the script. I would like to know if anyone else has come across this snag and, if so, what is the cause or if there is a solution. Is there some kind of compiled code associated with a Python script when it has been saved under a ‘Name.py’ or when it has been run in Gimp that prevents it from being capable of being changed or edited.
I am using Gimp 2.8, Windows XP and the Komodo editor to make the changes.
Any help would be appreciated.
Many Thanks
Python script query
On Fri, Nov 9, 2012 at 1:56 PM, Lorgach wrote:
In order to cut down on time, and also to gain experience I decided to modify some of the scripts that were written by experienced Python programmers to see what effects I could produce on various images. However, I have found that when I make even minor changes to a script and save the changed script to the ‘plug-ins’ folder under a new name, it will not show up in the Gimp Drop Down Menu specified in the script. I would like to know if anyone else has come across this snag and, if so, what is the cause or if there is a solution.
You'll need to restart GIMP for it to pick up a new plug-in. Once it appears you can edit it, as long as the menu item hasn't changed.
The "proc_name" must be unique - this is defined in the "register" function.
If there's a syntax error, the plug-in won't load.
Start GIMP in a command terminal to catch start-up errors.
Chris
Python script query
On 11/09/2012 08:56 PM, Lorgach wrote:
Hi,
I’m trying to introduce myself to programming in Python for Gimp, however I’m having difficulty in trying to run some scripts and I’m hoping that some of the more knowledgeable members on the Forum will be able to give me some assistance.
In order to cut down on time, and also to gain experience I decided to modify some of the scripts that were written by experienced Python programmers to see what effects I could produce on various images. However, I have found that when I make even minor changes to a script and save the changed script to the ‘plug-ins’ folder under a new name, it will not show up in the Gimp Drop Down Menu specified in the script. I would like to know if anyone else has come across this snag and, if so, what is the cause or if there is a solution. Is there some kind of compiled code associated with a Python script when it has been saved under a ‘Name.py’ or when it has been run in Gimp that prevents it from being capable of being changed or edited.
I am using Gimp 2.8, Windows XP and the Komodo editor to make the changes.
Any help would be appreciated.
Python is very picky about indentation (tabs are not equivalent to spaces) so editing of working code by newcomers usually elicits syntax errors, and these errors make the plugin registration fail. They can be displayed using gimp-console but there is an even faster way: in a commant prompt, outside of Gimp, execute:
python the_plugin.py
The worst syntax errors will be displayed then. If you go as far as getting:
from gimpfu import * ImportError: No module named gimpfu
then the syntax is somewhat correct and you can expect the script to run enough to register.
Python script query
On Fri, 9 Nov 2012 15:15:45 -0600, Chris Mohler wrote:
Start GIMP in a command terminal to catch start-up errors.
That doesn't work on Windows, but modifying the shortcut to pass --verbose to gimp-2.8.exe will bring up a console.
- postings
- 10
Python script query
Thanks a lot for the sugestions guys, I'll probably keep pluging away at trying to get some working code as time permits as I'm interested in learning Python. I was hoping that I'd be able to easily modify some script so that I could maybe build two working plug-ins that would speed up the editing of Gifs for me. Ofnuts ... I use your 'Mirror Layers' plug-in and find it a great help. It was this script that I was hoping to be able to modify so that I could build both a 'Delete Every 2nd Layer' and also a 'Delete All Layers from a specific one' plug-ins which would give me a nice editing suite along with the 'Mirror Layers' for editing Gifs that are processed from videos as there's usually a lot more frames downloaded than are necessary. I have tried out the 'AnimStack' plugin but found that it dosen't perform the Delete functions very well or else I'm just not using it correctly.
Thanks again for your help. Jim
Python script query
On 11/12/2012 02:13 AM, Lorgach wrote:
Thanks a lot for the sugestions guys, I'll probably keep pluging away at trying to get some working code as time permits as I'm interested in learning Python. I was hoping that I'd be able to easily modify some script so that I could maybe build two working plug-ins that would speed up the editing of Gifs for me. Ofnuts ... I use your 'Mirror Layers' plug-in and find it a great help. It was this script that I was hoping to be able to modify so that I could build both a 'Delete Every 2nd Layer' and also a 'Delete All Layers from a specific one' plug-ins which would give me a nice editing suite along with the 'Mirror Layers' for editing Gifs that are processed from videos as there's usually a lot more frames downloaded than are necessary.
Contact me directly (I'm on Gimforums/Gimptalk/Gimpchat) if you need help adapting my scripts (or explain me more in detail what you need).
- postings
- 9
Python script query
I have tried out the 'AnimStack' plugin but found that it dosen't perform the Delete functions very well or else I'm just not using it correctly.
Hi, the author of AnimStack here. I would wager the latter option is correct, since it clearly does perform the delete functions, and people other than myself are using it for this specific purpose (i.e. https://sites.google.com/site/taumox/making-animated-gif-image-from-a-video-scene)
Have you watched the video tutorial for this feature? http://www.youtube.com/watch?v=49FGgONSduM&t=7m40s
P.S. Consider learning Scheme/Script-Fu as it's much easier to develop/debug GIMP scripts in it.
Python script query
On Sun, Nov 11, 2012 at 7:13 PM, Lorgach wrote:
Thanks a lot for the sugestions guys, I'll probably keep pluging away at trying to get some working code as time permits as I'm interested in learning Python.
With one image open, try:
Filters->Python-Fu->Console
Enter:
my_img = gimp.image_list()[0]
Then:
dir(my_img)
Also:
dir(gimp)
I usually have the console open before or during writing a plug-in so I can mess around first. The other window I have open is Help->Procedure Browser.
HTH,
Chris
- postings
- 10
Python script query
Hi All,
Thanks again for all the assistance.
I tried out a few variations of the [delete] tags in AnimStack and managed to get the desired results for editing my Gifs.
I had difficulty getting the [delete] tag to work properly... it deletes the first two layers and then every second layer after that. I found that by inserting a duplicate layer of Layer 1 and then changing the name of this to [delete] and then running 'Process AnimStack Tags' I got the desired result of leaving the first one and then deleting every second layer in the list after that.
In order to delete all the layers, starting at a particular one, I just change the name of the layer I want to delete from to [delete:2:2] and then run 'Process AnimStack Tags' this deletes all the layers from that one right to the end.
To delete all the layers from the first one up to a particular one I change the name of the first one to [delete:1:1:n] and this will delete all the layers up to ‘n + 1’ one. . . eg. [delete:1:1:20] will delete all the layers from the first one up to and including layer 21.
Using AnimStack in this way will enable me to edit my Gifs more efficiently.
- postings
- 9
Python script query
I had difficulty getting the [delete] tag to work properly... it deletes the first two layers and then every second layer after that.
This is because every layer that has an animstack action tag on it is deleted after processing, this is not something unique to [delete] tag. This is because tagged layers are basically commands, and after being executed they are not needed anymore.
I found that by inserting a duplicate layer of Layer 1 and then changing the name of this to [delete] and then running 'Process AnimStack Tags' I got the desired result of leaving the first one and then deleting every second layer in the list after that.
The intended use-case was that a new empty layer is created tagged with [delete] and placed right before the first layer that is supposed to be deleted. But your way is fine too.