title: GIMP Python, selection based on path not the same as menu item "From Path"
body: <p>I've created an image in GIMP 2.8 with several paths using <code>Select -&gt; To Path</code>. Now I want to create a Python script that will loop through all these paths, make a selection based on each path, cut out the selection to a new image, do some additional stuff,
  and save each cut-out to a separate PNG image.</p>
  
  <p>So far I've got this Python script, which I can start from <code>Filters -&gt; Paths</code> as a menu item:</p>
  
  <pre><code>#!/usr/bin/env python
  # coding: utf-8
  
  from gimpfu import *
  import os
  
  def export_paths_to_pngs(img, layer, path, vis):
  
      # get all paths (internally called "vectors")
      cnt, vectors = pdb.gimp_image_get_vectors(img)
      if (cnt &gt; 0):
          # iterate all paths
          for n in vectors:
              v = gimp.Vectors.from_id(n)
              # only visible paths
              if (v.visible):
                  st = v.strokes
                  sufix = 0
                  # iterate all strokes in vector
                  for ss in st:
                      type, num_pnts, cntrlpnts, closed = pdb.gimp_vectors_stroke_get_points(v, ss.ID)
                      pdb.gimp_image_select_polygon(img, CHANNEL_OP_REPLACE, len(cntrlpnts), cntrlpnts)
  
  # tell gimp about our plugin
  register(
      "python_fu_export_paths_to_png",
      "Export paths as png files",
      "Export paths as png files",
      "BdR",
      "BdR",
      "2017",
      "&lt;Image&gt;/Filters/Paths/Export paths to png", # menu path
      "",   # Create a new image, don't work on an existing one
      [
          (PF_DIRNAME, "export_directory", "Export destination directory", "/tmp"),
          (PF_TOGGLE, "p2",   "TOGGLE:", 1)       
      ],
      [],
      export_paths_to_pngs
  )
  
  main()
  </code></pre>
  
  <p>However, the problem is that the python function <code>gimp_image_select_polygon</code> doesn't make a selection as intended. 
  The selection seems to have some differences in the bezier curves (or something like that) which is not exactly the same as the path it's based on.
  On the other hand, the menu item <code>From Path</code> does work correctly, it makes a perfect selection based on the path. See image below:</p>
  
  <p><a href="https://i.stack.imgur.com/Ywiqv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ywiqv.png" alt="enter image description here"></a></p>
  
  <p>So my questions are:</p>
  
  <ol>
  <li>What is the difference between the menu item <code>Select -&gt; From Path</code> and the GimpPython function <code>gimp_image_select_polygon</code></li>
  <li>Am I using the function <code>gimp_image_select_polygon</code> incorrectly, or is there another function I should use?</li>
  <li>Failing all that, is there a way to somehow call the menu item <code>From Path</code> directly from Python?</li>
  </ol>