Skip to content

Commit 26b1fac

Browse files
committed
add autotrace
add a menu item for autotrace see #55
1 parent 6699ae8 commit 26b1fac

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

share/nip2/start/Filter.def

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,3 +1651,41 @@ Filter_paint_text_item = class
16511651
}
16521652
}
16531653
}
1654+
1655+
Autotrace_item = class
1656+
Menuaction "_Trace" "convert a bitmap to an SVG file" {
1657+
action x = class
1658+
_result {
1659+
_vislevel = 3;
1660+
1661+
despeckle = Scale "Despeckle level" 1 20 1;
1662+
line = Scale "Line threshold" 1 20 1;
1663+
center = Toggle "Trace centreline" false;
1664+
scale = Scale "SVG scale" 0.1 10 1;
1665+
1666+
command
1667+
= "autotrace %s " ++ join_sep " "
1668+
[ofmt, ofile, desp, lint, cent]
1669+
{
1670+
prog = search_for_error "autotrace";
1671+
ofmt = "-output-format svg";
1672+
ofile = "-output-file %s";
1673+
desp = "-despeckle-level " ++ print despeckle.value;
1674+
lint = "-line-threshold " ++ print line.value;
1675+
cent = if center then "-centerline " else "";
1676+
}
1677+
1678+
_result
1679+
= Image output
1680+
{
1681+
[output] = vips_call "system"
1682+
[command]
1683+
[$in => [x.value],
1684+
$in_format => "%s.ppm",
1685+
$out => true,
1686+
$out_format => "%s.svg[scale=" ++ print scale.value ++ "]"
1687+
];
1688+
}
1689+
}
1690+
}
1691+

0 commit comments

Comments
 (0)