Tools
- path-dump
- unclose-path
- path-mirror
- reverse-strokes
- delete-strokes
- decompose-strokes
- path-shift
- golden-spiral
- path-spread
- ribbon-path
- path-csv
- text-along-path
- path-inbetweener
path-dump
This is a very simple-minded dump of the contents of a given path. The dump goes to the console, so this requires:
- on Linux, to have started Gimp from a terminal
- on Windows, to have started Gimp using gimp-console
This script can prove very useful to explain the strange behavior of some of its sibling scripts on some pathological paths.
unclose-path
This script fixes a incorrect behavior in
Gimp. When using "stroke"
fonts (such as those available
here) Gimp "closes" all the strokes (perhaps to be able to "fill"
the characters), producing extra line segments. Unfortunately the
strokes remain
closed even in a "Path from text
":
This script "uncloses" the strokes to restore a usable path:
This script bluntly re-opens all strokes. So far this does not appear to have any ill effects since in all the fonts encountered, even the strokes that should remain closed ("O", for instance) do not rely on the closure to draw the last segment. If you come across a counter-example, I will be glad to fix the script.
path-mirror
This script mirrors all strokes in a path across a specified vertical or horizontal axis. When used with the "merge" option, the resulting path contains the strokes from the source path and their mirrored versions. Furthermore, if the start or end point of an open stroke remain the same, the source and mirrored strokes are connected into one single stroke. If both start and end remain the same, the resulting stroke is closed. The possible options are:
Orientation
The orientation of the mirroring. For consistency with other Gimp tools, "horizontal" means that the X coordinate changes while the Y one remains the same (the path is mirrored across a vertical axis)
Axis
The position of the axis.
Merge with source
If "yes", the resulting path contains strokes from both source path and mirrored path, connected when necessary.
reverse-strokes
This script swaps all the strokes in the path end for end. The result is invisible until you use the path with something that may involve direction such as stroking with a color gradient.
Stroke selection
- If there is an active selection in the image, only the strokes that have at least one end point in the selection are reversed.
- Otherwise, all strokes are reversed.
Note: this script strives to preserve the order of the strokes in the path. Contact the author if you find cases where it doesn't.
Reversed strokes can be identified using the path-dump script above
delete-strokes
This script deletes strokes in a path.
Stroke selection
- This script deletes only the strokesthat have at least one end point in the selection (nothing is deleted if there is no selection).
decompose-strokes
This script decomposes a path into its constituent strokes, creating one path per stroke in the original path.
Stroke selection
- If there is an active selection in the image, only the strokes that have at least one end point in the selection will be extracted.
- Otherwise, all strokes are extracted.
path-shift
This script creates a copy of the path shifted by the specified amounts along the X and Y axes.
Sub-pixel shift values are possible but may not lead to visible results.
There are other (and usually easier) ways to move a path in Gimp. This script is useful only when you require subpixel precision.
golden-spiral
This script generates a "golden spiral" with the rectangle that bounds the selection. It is intended mostly as a substitute for a golden-spiral guide when cropping photographs.
Usage
Unlike most scripts here, the menu entry for this script is in the "<Image>/Select" menu (at the bottom).
The golden spiral is generated with the following rules:
- The external limit of the spiral starts on the selection bounds rectangle.
- The spiral is drawn inside a golden rectangle whose smallest side is the smallest side of the selection bounds
To avoid clutter in the Paths list, a new golden spiral path will replace the previous one (rename the previous one if you need to keep it).
The script dialog allow one to specify:
- The position of the spiral center in the rectangle
- The optional rendering of the enclosing golden rectangle.
path-spread
This script is a path-directed equivalent to
the "spread" noise
filter. It travels the path, and swaps a pixel at a random distance on
a perpendicular to the right of the path with another pixel on the same
perpendicular, on the left.
Unlike other filters here, it works on a layer, and so is in <Image>/Noise
.
The path used is the current path.
The possible options are:
Width
The maximum distance from the path at which pixels are swapped.
Density
The density of the exchange. A density of 100 means that half the pixels on a perpendicular are swapped.
Spread
When "linear", the probability to swap a pixel is independent of its distance to the path. When "quadratic" the probability is higher for pixels close to the path.
Symmetrical
When "no", the distance of both pixels on each side of the path is drawn randomly. When "yes", the pixels swapped are at the same distance from the path.
The output of the filter is a new layer. The filter can be run several times in a row until the required density is achieved (running the filter 5 times at density 20 and merging the results gives equivalent results to one run at density 100).
Here is an exemple of different runs of the script (Width=30, Density=50) with Linear, Quadratric, and Linear/Symmetrical options, where the path is following the black/white limit:
ribbon-path
This script creates a path that delineates ribbons: the strokes in the original path become the sides of as many ribbons). When a stroke is closed, the script creates another stroke inside or outside the original one. When a stroke is open, the script creates a stroke parallel to the original one, and then connects their extremities to close the ribbon.
Options
The possible options are:
Width
The width of the ribbon, in pixels. This width can be less than a pixel and still produce valid ribbons that can be used for selections and filled.
Side
The side of the strokes where the ribbon should be created.
Note: Gimp paths have no orientation, so you cannot predict where the ribbon will show up. If you have a path with many strokes (typically from a "Path from text"), you may find than not all ribbons are produced on the expected side. You can use the "path-dump" script to identify them (or to confirm their orientation), and the "reverse-strokes" one to correct the troublesome strokes.
path-csv
This script imports and exports path as CSV files, that are an easy interface to spreadsheet programs such as Excel or OpenOffice Calc. On import, it can import several paths form a single file. On export, it will export the current path.
Quirks, gotchas and caveats
- There is no provision for country-specific decimal formats, in particular thousands and decimal separators.
- The script is available in the Paths right-click menu. However, it is disabled if there is not at least one path there (the author will gladly accept all indications to register this script so that it works without an existing path). So, to import your path, you may have to create a dummy one beforehand.
- The files used for import and export must exist. This makes sense for import, but for export, this means you must first create an empty file that you can select (it will be overwritten).
CSV file format
Please refer to the FAQ for a basic understanding of paths.
The CSV file must contain data in the first 8 columns (ie, A to H in the spread sheet):
- (A) The name of the path (repeated on every row).
- (B) The stroke identifier (repeated on every row).
- (C) The X coordinate of the backward handle
- (D) The Y coordinate of the backward handle
- (E) The X coordinate of the anchor point
- (F) The Y coordinate of the anchor point
- (G) The X coordinate of the forward handle
- (H) The Y coordinate of the forward handle
A new path is started whenever a new name appears in column 1.
A new stroke is started whenever a new identifier appears in column 2.
It is an error to reuse a path name.
It is an error to reuse a stroke label within the same pathName.
A "closed" stroke is implied if the first row of the stroke is stricly identical to the last. In this case the last row is not used to create a point in the Gimp stroke and the Gimp stroke is marked closed instead. Conversely, for export, closed strokes are designated by ending them with a copy of their first triplet.
Rows with empty columns 1 or 2 or with non-numeric data in columns 3-8 are ignored, so they can be used for headers, separators, or comments.
See the samples section in the download area for some example files.
text-along-path
This tool attempts to improve on the "Text along path" button in Gimp's Text tool. The improvements are:
- Character shapes are not distorted: while Gimp's tool works by remapping the text path control points using the guide path, this script rotates and moves each character path without distortion.
- Text can left-justified, right-justified, centered, or filled on the path.
- The vertical position with respect to the guide path can be specified
- The path of individual characters can be obtained
- Some more frivolous options may appeal to the artist or the ransom note writer.
Like the Gimp's native version, it produces a path.
This script is called either:
- From the Layers list dialog, by right-clicking on the text layer to be used as text soource
- From the Paths list dialog, by right-clicking on the path used as a guide for the text, It appears in the "Tools" submenu. This mode requires more parameters to specify, text, font, etc...
Options
The options are:
Guide path (called from Layers only)
The path on which the text is laid.
Text (called from Paths only)
The text.
Font name (called from Paths only)
The font to use.
Font size (called from Paths only)
The font size (in pixels).
Layout (called from Paths only)
How the text is laid out on
the path stroke. The
orientation of the stroke is important, see the reverse-strokes
tool to solve orientation problems. The origin and end of closed
strokes (full circles, for instance) may be hard to determine. Origin
and end can be reset by just cutting a sub-pixel segment off the stroke.
Height reference
How the text is positioned vertically with respect to the guide path. The "box" in the choices is the text layer that would hold the characters in the Text tool.
Use kerning (called from Paths only)
Whether font kerning is used or not.
Extra spacing (called from Paths only)
Extra space inserted between all characters, to widen the text. Partial pixel values are allowed. This field is ignored for the "filled" layout.
Vertical adjust
Height adjustment, added to the "height reference" above. Partial pixel values are allowed.
Keep character paths
When this is true
, individual paths for
each character are made available (in addition to the complete path,
which is always produced).
Keep upright
When this is true
, characters are not
tilted to follow the guide path.
Lateral wiggle
The maximum value for a random lateral displacement for each character. It is expressed as a percent of the average character width.
Vertical wiggle
The maximum value for a random vertical displacement for each character. It is expressed as a percent of the height of the character "box".
Tilt wiggle
The maximum value for a random additional tilt for
each character, in degrees.
path-inbetweener
This tool interpolates more paths between
the current path and an
end path.
Options
The options are:
End path
The end path (the start path is the current one)
Total steps
The number of steps to
generate, including a copy of
the begin and end paths.
Quirks, gotchas and caveats
- The script interpolates the control points of the paths, so it must match control points in the first path with control points in the second.
- The matching algorithm is simplistic: the Nth point in the stroke from path 1 is matched with the Nth point in the corresponding stroke in path 2, and the strokes themselves are matched by the order in which they appear in each path.
- Hence both paths should have the same number of strokes, and the strokes, taken in the same order, should have the same number of points. Working with single-stroke paths is therefore recommended.
- When working with closed strokes, some operations may change the starting point of the stroke. Cutting the stroke again between the required begin and end point and joinging thelm again may fix it.
- See the other tools to fix minor problems (path-dump, reverse-strokes)
- When done, both source paths are made
invisible, while the
generated paths are made visible (so you are one click away from "Merge
visible paths" if needed). Keep in mind that in Gimp 2.6, an even number
of identical paths cancel out each other on the display. Not seeing
anything could be normal.