autotrace
A simple interface for converting raster images into vector graphics using AutoTrace.
More details about AutoTrace can be found here.
Requirements
Installation
$ npm install -g autotrace
Output Formats
Typical output formats include EPS, AI, SVG, DXF, PDF, MIF and Cairo. All supported output formats can be found by running;
autotrace --help
Basic Usage
Convert a PNG to SVG.
// input file, options and a callback; // options and a callback; // chaining ;
Streams
// stream output to a WriteableStream ; // without a callback, .stream() returns a stream// this is just a convenience wrapper for above.var writeStream = fs; ;
API
autotrace(inputFile, options, callback)
The first argument can be either a file path or an options object. The only required option is inputFile (when not passing as the first argument); all others are optional. Refer to the above usage section for examples.
Options/Methods - all of AutoTrace's are supported along with some custom ones.
AutoTrace
# Refer to AutoTrace's help for details.
man autotrace
- backgroundColor
- centerline
- colorCount
- cornerAlwaysThreshold
- cornerSurround
- cornerThreshold
- despeckleLevel
- despeckleTightness
- dpi
- errorThreshold
- filterIterations
- inputFormat
- lineReversionThreshold
- lineThreshold
- log
- outputFile
- outputFormat
- preserveWidth
- removeAdjacentCorners
- tangentSurround
- reportProgress
- debugArch
- debugBitmap
- version
- widthWeightFactor
Custom
- inputFile - path to the input file.
- customBin - set a custom path to the AutoTrace binary.
- binArgs - returns an array of the args to be passed to AutoTrace.
- debugExec - returns the full exec + args as a string. Useful for debugging.
Methods
- exec(callback) - start the tracing process. returns (err, buffer).
- stream - stream the results of the tracing. returns (err, stdout, stderr).
If a callback (e.g. autotrace(file, callback)) is provided the exec method is automatically called for you.