Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting help at my new job
#1
So I’ve dabbled in scripting before but am not super well versed in it. However, I just took on a position at my job doing image editing for our online webstore. I’m able to do it easy enough in GIMP, but it’s doing the same edit over and over and I know that there has to be a way to script it so that I can do so more efficiently, I just have been having a hard time trying to understand how to write the script. I have access to Python-fu and Script-fu, but would prefer to use Python. 
So here’s what I do to each image. Once I’ve gone through and manually selected what I need to, I do the same series of actions every time, and this is what I’m trying to script:

1. Layer > Transparency > Add Alpha Channel

2. Edit > Clear (or Hit Delete)

3. Deselect (Not absolutely necessary)

4. Image > Canvas Size > Height: 950 > Width: 950 > Center > Resize

5. File > Export As > ‘file name’.png > Export (Exporting the image and changing it from jpg to png)


And that’s it. I open an image, select the background, and then do those same steps every single time. So I was wondering if anyone could help me figure out the script for doing this every time. It would expedite the process to go so much quicker and I would greatly appreciate it. Thanks!
Reply
#2
Looks like all the regular coders are busy elsewhere, so from another very-very-occasional dabbler.

Your workflow is very similar to a plugin I knocked up for myself years ago, for scaling and saving,  Just a few extra lines needed.

It does need a destination entered initially, that remains for the rest of the session. I suppose that could be written into the script, up to you.
The file name is taken from the layer name, that might be a problem.

Registers in the tools menu.


Attached Files
.zip   png-it.py.zip (Size: 640 bytes / Downloads: 159)
Reply
#3
(10-25-2020, 08:18 AM)rich2005 Wrote: Looks like all the regular coders are busy elsewhere, so from another very-very-occasional dabbler.

Your workflow is very similar to a plugin I knocked up for myself years ago, for scaling and saving,  Just a few extra lines needed.

It does need a destination entered initially, that remains for the rest of the session. I suppose that could be written into the script, up to you.
The file name is taken from the layer name, that might be a problem.

Registers in the tools menu.

Awesome. Now for the next part of my ignorance. What do I do with that? Haha. What I mean is, I'm not familiar with how plug-ins work on GIMP, so how do I get that to a place where I can execute it? Is it a matter of loading it up in to Python's console, or do I need to drop it in to the GIMP plugins folder? Thanks for the assistance so far!
Reply
#4
Do not say Awsome (IMHO a much overworked term) until you have tried it.

Plugins, a file something.exe + any associated dll's or a python script something.py
goes in your User profile. C:\Users\"yourname"\AppData\Roaming\GIMP\2.10\plug-ins

Note 'Appdata' is a Windows hidden folder, enable in Windows Explorer. https://support.microsoft.com/en-us/help...windows-10

How to use it: It registers in the Tools Menu as pngit. So you can go there to apply. First time you need to set a destination. Next file you process, that destination is already set.

Repeating the plugin? Top of the Filters menu is the entry Repeat Last (ctrl + F) or in Gimp you can assign some other hot-key to it.

Since you have knowledge of python you should be able to modify it to suit or put up some code and hope the resident coders will advise.
Reply
#5
Plenty of examples here: http://sourceforge.net/projects/gimp-too...s/scripts/

Typically, if the first two args in the args list of the register() are, in that order, 1) a PF_IMAGE and 2) a PF_DRAWABLE or a PF_LAYER, they are automatically set o the current image and layer when you call the script via the menu.

You have the Python_fu console to try things... Don't overlook the "Browse" button and the search bar in the window that it opens...
Reply


Forum Jump: