serhii.net

In the middle of the desert you can say anything you want

22 Dec 2024

Centerline tracing

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)

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus