Day 2183
Using inkscape CLI
Using the Command Line - Inkscape Wiki
-
inkscape action-list
shows all available actions -
man inkscape
is the latest and best -
inkscape AMPERSAND.png --export-type="svg" --export-area-page --batch-process
works but asks me about import options
inkscape --shell
, man page gives examples:
file-open:file1.svg; export-type:pdf; export-do; export-type:png; export-do
file-open:file2.svg; export-id:rect2; export-id-only; export-filename:rect_only.svg; export-do
OK this works for no questions about how to import it:
> file-open:AMPERSAND.png
> export-filename:AM.svg
> export-do
Centerline tracing
- Goal: centerline trace pngs
- Inscape
- Script, extension, now part of Inkscape: inkscape-centerline-trace/centerline-trace.py at master · fablabnbg/inkscape-centerline-trace
- Inkscape as a purely command line tool : r/Inkscape reddit on using the CLI and running the extension standalone and how it doesn’t really work
- Can’t get it to work using CLI either, there’s just
bitmap-trace
that has no centerline option
- Not inkscape
Autotrace is awesome!
This alone works really nicely:
autotrace -centerline AMPERSAND.png -output-file AMPERSAND.svg
Fish script for batch processing, courtesy of ChatGPT:
#!/usr/bin/fish
# Check if autotrace is installed
if not type -q autotrace
echo "autotrace is not installed. Please install it first."
exit 1
end
# Loop through each .png file provided as an argument
for file in $argv
# Check if the file extension is .png
if string match -r '\.png$' $file
# Set the output filename by replacing .png with .svg
set output_file (string replace -r '\.png$' '.svg' $file)
# Execute autotrace with centerline option
autotrace -centerline $file -output-file $output_file
# Confirmation message
echo "Processed $file to $output_file"
else
echo "Skipping $file: not a .png file"
end
end
And a more simple one:
#!/usr/bin/fish
for file in $argv
autotrace -centerline $file -output-file "$file.svg"
end
Options
ChatGPT says this:
autotrace -centerline -input-format png -output-format svg -output-file traced_dejavu.svg -dpi 300 -error-threshold 0.5 -corner-threshold 85 -filter-iterations 2 -noise-removal 0.99 -line-threshold 0.5 -corner-surround 3
(et 1 is best)