npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

autotrace

v0.0.2

Published

A simple interface for converting raster images into vector graphics using AutoTrace.

Downloads

33

Readme

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
autotrace('/path/to/image.png', {
	outputFile: '/tmp/out.svg'
}, function(err, buffer) {
	if (!err) console.log('done');
});

// options and a callback
autotrace({
	inputFile: '/path/to/image.png'
	, outputFile: '/tmp/out.eps'
}, function(err, buffer) {
	if (!err) console.log('done');
});

// chaining
autotrace()
	.inputFile('/path/to/image.png')
	.outputFile('/tmp/out.pdf')
	.exec(function(err, buffer) {
		if (!err) console.log('done');
	});

Streams

// stream output to a WriteableStream
autotrace('/path/to/image.png')
	.outputFormat('svg')
	.stream(function(err, stdout, stderr) {
		var writeStream = fs.createWriteStream('/tmp/out.svg');
  		stdout.pipe(writeStream);
	});
	
// without a callback, .stream() returns a stream
// this is just a convenience wrapper for above.
var writeStream = fs.createWriteStream('/tmp/out.pdf');
autotrace('/path/to/image.png', {outputFormat: 'pdf'})
	.stream()
	.pipe(writeStream);

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.