RSS/Atom feed Twitter
Site is read-only, email is disabled

[Script-fu] How to convert a path to a selection?

This discussion is connected to the gimp-developer-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.

5 of 5 messages available
Toggle history

Please log in to manage your subscriptions.

[Script-fu] How to convert a path to a selection? grafxuser 01 Mar 06:01
  [Script-fu] How to convert a path to a selection? Kevin Cozens 01 Mar 19:32
[Script-fu] How to convert a path to a selection? bootch@nc.rr.com 01 Mar 12:07
[Script-fu] How to convert a path to a selection? grafxuser 01 Mar 17:49
[Script-fu] How to convert a path to a selection? grafxuser 03 Mar 09:16
grafxuser
2012-03-01 06:01:41 UTC (almost 13 years ago)

[Script-fu] How to convert a path to a selection?

---
- ! "Hi,\n\nin GIMP 2.6.12 I tried to make a selection from a path for further use.\n\nTo achieve this I used the following code snippet\n(let * ((v (gimp-vectors-import-from-file image filename FALSE \nscale-to-imagesize))\n(gimp-vectors-to-selection v 2 TRUE FALSE 0 0)\n)\nThis snippet should\n1. import a path from a file, without merging all the paths in the file,\nand scaling it up to image size, if the user wants this\n2. make a selection out of the imported path\n\nAll my attempts using the variable v directly or with various \ncombinations of car and cdr went wrong. Usually \ngimp-vectors-to-selection gave the error 'Invalid type for argument 1 to \ngimp-vectors-to-selection'. After all my attempts I'm clueless now.\n\nI already searched within the scripts that are shipped with GIMP and \nwith Google, too. But I found nothing that helped me.\n\nCan anybody tell me how to call gimp-vectors-to-selection properly and \ngive me a working example, please?\n\nBTW, can I use the whole scheme language in Script-fu or are there any \nrestrictions?\n\nThanks in advance!\n\ngrafxuser\n"

bootch@nc.rr.com
2012-03-01 12:07:56 UTC (almost 13 years ago)

[Script-fu] How to convert a path to a selection?

---
- ! 'Here is a workaround, in Python. This is a fragment you can enter in the GIMP Python console. It should translate to Scheme.

image = gimp.image_list()[0]

pdb.gimp_vectors_import_from_file(image, "foo/test.svg", True, False)

# prints: (1, (3,))

# 3 is the ID of the newly imported path

activeVectors = pdb.gimp_get_active_vectors(image)

print activeVectors

# prints:

pdb.gimp_vectors_to_selection(activeVectors, 2, True, False, 0, 0)

This is sufficient if you assume that the imported vector becomes "active".

There does seem to be some confusion in the API, between ID''s and objects.

Since May 2011 there is a Vectors.from_id() method in GIMP Python, which would also solve this problem, at least in Python. Note the GIMP Python documentation doesn''t document the Vectors class.

'

grafxuser
2012-03-01 17:49:00 UTC (almost 13 years ago)

[Script-fu] How to convert a path to a selection?

---
- ! "Thanks, bootch, for your answer. Unfortunately Python doesn't work well \nhere, but thanks anyway!\nI decided to postpone this issue to a time when the next GIMP version \nwas released. In GIMPs gitlog today I saw a commit from Mitch to bug \n#658477, which lets me assume that there will be some changes in the \nPDB-API, right?\nAll I wanted to do is to iterate through some vector paths, resize them \neasily and make selections of them for further bitmap based processing. \nWill this be possible in an easy way in version 2.8 or do I have to \nwrite a C plugin then?\n\ngrafxuser\n"

Kevin Cozens
2012-03-01 19:32:31 UTC (almost 13 years ago)

[Script-fu] How to convert a path to a selection?

---
- ! "On 12-03-01 01:01 AM, grafxuser wrote:\n> To achieve this I used the following code snippet\n> (let * ((v (gimp-vectors-import-from-file image filename FALSE\n> scale-to-imagesize))\n> (gimp-vectors-to-selection v 2 TRUE FALSE 0 0)\n> )\n[snip]\n> All my attempts using the variable v directly or with various combinations\n> of car and cdr went wrong. Usually gimp-vectors-to-selection gave the error\n> 'Invalid type for argument 1 to gimp-vectors-to-selection'. After all my\n> attempts I'm clueless now.\n\nThere is something strange going on here. One time when I tried it it worked \nwhen I changed the \"v\" reference in gimp-vectors-to-selection to \"(car v)\". \nIt stopped working after a few tries.\n\nPlease bugzilla this so I can be reminded to investigate this further.\n\n> BTW, can I use the whole scheme language in Script-fu or are there any\n> restrictions?\n\nThere are some. Script-Fu mostly follows R4RS/R5RS. It doesn't support use \nof radix in number->string and string->number, or any of bignums, complex \nnumbers, or any of the functions with *syntax* in the name (ie. syntax-rules \nor define-syntax) or other functions related to that. There are probably \nsome other features not supported, or not fully compliant with the Scheme \nstandard but I've already mentioned the main ones.\n\n-- \nCheers!\n\nKevin.\n\nhttp://www.ve3syb.ca/ \ |\"Nerds make the shiny things that distract\nOwner of Elecraft K2 #2172 \ | the mouth-breathers, and that's why we're\n | powerful!\"\n#include | --Chris Hardwick\n"

grafxuser
2012-03-03 09:16:03 UTC (almost 13 years ago)

[Script-fu] How to convert a path to a selection?

Thanks, Kevin. I opened bug #671248 for this.

grafxuser