It is currently Sun Jul 21, 2024 10:35 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Scriptfu selection to path
PostPosted: Wed Jul 11, 2018 3:22 pm  (#1) 
Offline
New Member

Joined: Jul 11, 2018
Posts: 4
Hello!

I'm learning script-fu, to do some large batch edits with gimp. I have black-and-white png files with irregular, solid splotches in them that need to be outlined:

Attachment:
test_spots3.png
test_spots3.png [ 10 KiB | Viewed 3756 times ]


These outlines need to be exported in the form of an svg (png conversion shown), no fill necessary:

Attachment:
test_spot.png
test_spot.png [ 61.12 KiB | Viewed 3756 times ]


When button-pushing on the gui, I do the following:

0) Select all solid black shapes in image/layer at once using the "Select by color" function

1) convert the selection to a path

2) find this path in the paths dialogue,

3) Right click to export the path as an svg

I am able to accomplish Task #0 (color selection) just fine in the console.

With scriptfu I cannot find a procedure for converting selections to paths, though I do find the opposite ("gimp-path-to-selection") is available.

Any help with this (step 1 in scriptfu) is appreciated.


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: Scriptfu selection to path
PostPosted: Wed Jul 11, 2018 4:47 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Aug 08, 2016
Posts: 2081
Location: East Midlands of England
In the procedure browser look for plug-in-sel2path. I think that will be the solution to your problem.

_________________
Image

"Let no one steal your dreams."
Paul Cookson


Latest plug-in update: Selection Highlights v.0.1
Custom Font Links
Tools
Character Paths
White Bases


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Thu Jul 12, 2018 1:12 am  (#3) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
0) gimp_by_color_select or gimp_by_color_select_full
1) plug_in_sel2path or plug_in_sel2path_advanced
2) that will be the "active_vectors" of the image (image.active_vectors)
3) gimp_vectors_export_to_file

This is 2018. Use Python instead of scriptfu. Much easier to work with, much more powerful.
Doc is here: http://www.gimp.org/docs/python/index.html
Examples here: http://sourceforge.net/projects/gimp-to ... s/scripts/ and http://sourceforge.net/projects/gimp-pa ... s/scripts/

For both script-fu and python-fu, Filters>{script/python-fu}/console, hit the "Browse" button and you have all the doc (found the way to export to SVG by just entering "export" in the search field.

_________________
Image


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Thu Jul 12, 2018 4:29 pm  (#4) 
Offline
New Member

Joined: Jul 11, 2018
Posts: 4
@Skinnyhouse, thanks, I think that's what I was looking for.

@ofnuts, is it 2018 already? Time flies. Yeah, I love me some python. I tried to use the modules in the examples when I first started on this. I had trouble finding the modules on pypi and didn't think to look around on sourceforge/github or dig them out of the gimp install.

Then I had trouble using my python3 interpreter and or running scripts from BASH anyway with what I could find, unless I used the interpreter within gimp - and all I could find was python2 stuff (speaking of 2018). Is this what is available, or are python3 gimp modules/package available, that can be run outside of the gimp environmont?


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Fri Jul 13, 2018 1:36 am  (#5) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
danchurch wrote:
@Skinnyhouse, thanks, I think that's what I was looking for.

@ofnuts, is it 2018 already? Time flies. Yeah, I love me some python. I tried to use the modules in the examples when I first started on this. I had trouble finding the modules on pypi and didn't think to look around on sourceforge/github or dig them out of the gimp install.

Then I had trouble using my python3 interpreter and or running scripts from BASH anyway with what I could find, unless I used the interpreter within gimp - and all I could find was python2 stuff (speaking of 2018). Is this what is available, or are python3 gimp modules/package available, that can be run outside of the gimp environmont?


All Linuxen still use scripts in Python v2. In any case, to use script-fu or python-fu you have to be in the Gimp environment, and Pythonv2 is still fare more usable than script-fu. Even if you are on Windows, you can add python modules to the interpreter used by Gimp.

If you want to run Gimp scripts from a command line, see this (that one is mostly focused on Windows, but 95% of it applies for Linux, and the changes for Linux are mentioned at the end).

_________________
Image


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Fri Jul 13, 2018 12:04 pm  (#6) 
Offline
New Member

Joined: Jul 11, 2018
Posts: 4
Okay, got it. Python2 is fine, I just assumed I was missing something.

Thanks for the advice, it'll save me some headaches in the long run, sounds like.


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Sat Jul 14, 2018 12:37 am  (#7) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4039
Location: Canada
Also whenever I ran into something I needed to know something to use in Python I can look it up quickly no matter how simple/complex.
With scheme I always had problems looking up things since it's I have never used scheme anywhere but in GIMP so I guess there are less resources to look for help.

_________________
TinT


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Sun Jul 15, 2018 4:44 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: Aug 08, 2016
Posts: 2081
Location: East Midlands of England
Hi DanChurch:

Just in case you were going to pursue your interest in scripting I thought it might help you, to look at these two versions of GnuTux's excellent GT Bevel filter,in deciding whether to go down the Scheme or Python route. Both versions are for Gimp 2.10 only.

Attachment:
ScriptFu_and_PythonFu_GT_Bevel.zip [5.91 KiB]
Downloaded 163 times


I am no programmer but I am interested in coding and have taught myself enough to get by in Gimp scripting - providing the math is not too demanding. Looking at other people's scripts is by far the best way to pick things up and the people here are very generous when you ask for help.

I find Python far easier to follow than Scheme which is a variant of LISP, I think. I have converted GnuTux's work into Python-Fu as faithfully as possible so that you can open both versions up in a text editor, such as Notepad++, and see how they differ from one another. Obviously Python-Fu does have its little peculiarities but don't we all.

Best of luck in your endeavours.

_________________
Image

"Let no one steal your dreams."
Paul Cookson


Latest plug-in update: Selection Highlights v.0.1
Custom Font Links
Tools
Character Paths
White Bases


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Mon Jul 16, 2018 1:30 am  (#9) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
About your code: the GPL licence requires that you put yourself clearly as the author, and in this case, this means the registration info (which doesn't mean that you cannot state your sources in a comment). I don't think that Gnutux is willing to fix problems in your version.

_________________
Image


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Mon Jul 16, 2018 2:31 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: Aug 08, 2016
Posts: 2081
Location: East Midlands of England
Ooops - dropped a clanger there then.

Of course there is no real point to having the Python version of GT Bevel since it only does exactly what the Scheme version does.

_________________
Image

"Let no one steal your dreams."
Paul Cookson


Latest plug-in update: Selection Highlights v.0.1
Custom Font Links
Tools
Character Paths
White Bases


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Mon Jul 16, 2018 12:02 pm  (#11) 
Offline
New Member

Joined: Jul 11, 2018
Posts: 4
@Skinnyhouse, is this to give me a quick comparison of the syntax of scriptfu vs. pythonfu? Much appreciated. I'm a lot more comfortable using python syntax than any variety of lisp, so you and @ofnuts @trandoductin have definitely sold me.

We're doing a lot of analysis down stream of those vector graphics, it will probably come in handy to have some basic reshaping of image data into arrays out of the way, etc for scipy work - numpy, pandas, etc. Scripting in python2 will make this way less painful.

So I'm grateful, because gimp is more intuitive for me for this vectorization step than the image kit for scipy. I do wish there was a python3 version, though. I guess someday we'll all have to start on making that a reality. Or are folks already working on this?


Top
 Post subject: Re: Scriptfu selection to path
PostPosted: Mon Jul 16, 2018 12:45 pm  (#12) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
For several examples of code handling paths: http://sourceforge.net/projects/gimp-pa ... s/scripts/

For an exemple of using numpy from Gimp: https://www.gimp-forum.net/Thread-Gimp-python-and-numpy

The popular GMIC plugin is an execution environment for image processing algorithms. The "filters" you write for it can also be executed directly in the command line.

_________________
Image


Top
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) ofn-text-path-selection

14

No new posts Attachment(s) selection path help GIMP 2.10

3

No new posts Selection of a path component

1

No new posts Can ScriptFu or anything in Gimp automate the creation of layer groups

7

No new posts Attachment(s) stroke selection/stroke path

2



* Login  



Powered by phpBB3 © phpBB Group