primitive icon indicating copy to clipboard operation
primitive copied to clipboard

allow saving an svg to file

Open catdad opened this issue 6 years ago • 1 comments

Currently, SVG output is supported, though not by providing output in options, the same way that jpg, png, and gif are supported. Here's a repro (though it's quite obvious):

primitive({
  input: 'in.jpg',
  numSteps: 2,
  output: 'out.svg'
}).then(() => {
  console.log('done?');
}).catch(err => {
  console.error(err);
  process.exitCode = 1;
});
1) { time: '7s', candidates: 786, score: 0.1721898251231621 }
2) { time: '4s', candidates: 618, score: 0.1389077911406503 }
Error: Unsupported file type: svg
    at savePixels (D:\Git\primitive\node_modules\save-pixels\save-pixels.js:139:23)
    at Object.saveImage (D:\Git\primitive\lib\context.js:58:18)
    at default (D:\Git\primitive\module.js:124:21)
    at <anonymous>

All the support for SVG already exists (and in fact is documented). This PR just adds the save functionality.

catdad avatar Oct 25 '18 01:10 catdad

Thanks for this pr! Super helpful 😄 hope it gets merged soon

To install the pull request, run

npm i git+https://github.com/catdad-experiments/primitive.git\#save-svg

To install a version without the console.log, run

npm i git+https://github.com/jlarmstrongiv/primitive.git\#patch-1

jlarmstrongiv avatar Feb 06 '21 18:02 jlarmstrongiv