trace and asciiart
please add pbmtoascii function from imagemagick, as well as autotrace delegate for bitmap tracing
Hi @berserk82, what platform are you using? Do you mean to the Windows binary, or to the toolkit menu?
I'm running Debian 8 and windows 10. I mean the pbmtoascii command in imagemagick and the libautotrace delegate for imagemagick
https://rrt2x7.wordpress.com/2013/07/29/text-to-ascii-art-conversion-using-image-magick/ and http://stackoverflow.com/questions/1132601/how-to-convert-a-jpeg-image-into-svg-format-using-imagemagick
I've got autotrace sort-of working as a nip2 menu item, but it's a bit wonky still, I think we'll need an addition to vips for it to work well.
Put this in a file called Autotrace.def in nip2's start directory:
// autotrace as a menu item
// make sure you have the "autotrace" command-line program installed
Autotrace_item = class
Menuaction "_Trace" "convert a bitmap to a SVG file" {
action x = class
_result {
_vislevel = 3;
despeckle = Scale "Despeckle level" 1 20 1;
line = Scale "Line threshold" 1 20 1;
command
= "autotrace %s " ++ join_sep " " [ofmt, ofile, desp, lint]
{
ofmt = "-output-format svg";
ofile = "-output-file %s";
desp = "-despeckle-level " ++ print despeckle.value;
lint = "-line-threshold " ++ print line.value;
}
_result
= Image output
{
[output] = vips_call "system"
[command]
[$in => [x.value],
$in_format => "%s.ppm",
$out => true,
$out_format => "%s.svg"
];
}
}
}
For a 200x200 pixel source image, I see 4 or 5 FPS as I drag the sliders around, which is rather impressive. I've only done controls for a couple of the autotrace options, but it would be easy to add more.
You'll need git master vips and nip2, unfortunately.
Thanks a lot.
Inviato dal mio dispositivo Samsung
-------- Messaggio originale -------- Da: John Cupitt [email protected] Data: 24/02/2016 11:06 (GMT+01:00) A: jcupitt/nip2 [email protected] Cc: berserk82 [email protected] Oggetto: Re: [nip2] trace and asciiart (#55)
I've got autotrace sort-of working as a nip2 menu item, but it's a bit wonky still, I think we'll need an addition to vips for it to work well.
Put this in a file called Autotrace.def in nip2's start directory:
// autotrace as a menu item // make sure you have the "autotrace" command-line program installed
Autotrace_item = class
Menuaction "_Trace" "convert a bitmap to a SVG file" {
action x = class
_result {
_vislevel = 3;
despeckle = Scale "Despeckle level" 1 20 1;
line = Scale "Line threshold" 1 20 1;
command
= "autotrace %s " ++ join_sep " " [ofmt, ofile, desp, lint]
{
ofmt = "-output-format svg";
ofile = "-output-file %s";
desp = "-despeckle-level " ++ print despeckle.value;
lint = "-line-threshold " ++ print line.value;
}
_result
= Image output
{
[output] = vips_call "system"
[command]
[$in => [x.value],
$in_format => "%s.ppm",
$out => true,
$out_format => "%s.svg"
];
}
}
}
For a 200x200 pixel source image, I see 4 or 5 FPS as I drag the sliders around, which is rather impressive. I've only done controls for a couple of the autotrace options, but it would be easy to add more.
You'll need git master vips and nip2, unfortunately.
— Reply to this email directly or view it on GitHub.
What about ASCII Art?
Here's a slightly better Autotrace.def:
// autotrace as a menu item
// make sure you have the "autotrace" command-line program installed
Autotrace_item = class
Menuaction "_Trace" "convert a bitmap to an SVG file" {
action x = class
_result {
_vislevel = 3;
despeckle = Scale "Despeckle level" 1 20 1;
line = Scale "Line threshold" 1 20 1;
center = Toggle "Trace centreline" false;
scale = Scale "SVG scale" 0.1 10 1;
command
= "autotrace %s " ++ join_sep " "
[ofmt, ofile, desp, lint, cent]
{
prog = search_for_error "autotrace";
ofmt = "-output-format svg";
ofile = "-output-file %s";
desp = "-despeckle-level " ++ print despeckle.value;
lint = "-line-threshold " ++ print line.value;
cent = if center then "-centerline " else "";
}
_result
= Image output
{
[output] = vips_call "system"
[command]
[$in => [x.value],
$in_format => "%s.ppm",
$out => true,
$out_format => "%s.svg[scale=" ++ print scale.value
++ "]"
];
}
}
}
It needs nip2 8.3, which should appear very soon.
I had a look at pbmtoascii (it's part of netpbm, not imagemagick, I think), but I'm not sure how well it would work in nip2. There's no easy way to display a text image within nip2, so how would you get feedback on your settings?
I've added this menu item to nip2, I should say, it'll be at the bottom of the Filter menu.
Are you talking about pbmtoascii? In either case, thanks for your work