{"_id":"svg-cleaner","_rev":"14-e987ed79411c0d25197c5271d1303a44","name":"svg-cleaner","description":"Cleaning SVG Files - A partial port of Scour to JavaScript.","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.1":{"name":"svg-cleaner","version":"0.0.1","description":"Cleaning SVG Files - A partial port of Scour to JavaScript.","keywords":["svg","assets","cleaner"],"homepage":"http://github.com/preciousforever/SVG-Cleaner","author":{"name":"Michael Schieben","email":"michael@precious-forever.com","url":"http://precious-forever.com"},"repository":{"type":"git","url":"http://github.com/preciousforever/SVG-Cleaner"},"engines":{"node":"0.6.x"},"dependencies":{"commander":"1.0.x","cssom":"0.2.x","underscore":"x.x.x","cheerio":"0.9.x"},"devDependencies":{"mocha":"*","expect.js":"*"},"scripts":{"test":"make test"},"bin":{"svg-cleaner":"./bin/svg-cleaner"},"bugs":"http://github.com/preciousforever/SVG-Cleaner/issues","_id":"svg-cleaner@0.0.1","dist":{"shasum":"3f259e432fe758f36a5ac01eb94c41f746929dbd","tarball":"https://registry.npmjs.org/svg-cleaner/-/svg-cleaner-0.0.1.tgz","integrity":"sha512-XIZ4KXM3DpTtGoLq4rJYaFXB2sOAm32zbYmee4vJFi8A9b4zA2s9VD5Se0nj/DyQQfc2DYXfggN1ikv6mWnnEg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB8ia1vwSgBLmSUL6PSIRhK+5IIopxsoOozIghpdHOTEAiANweAe2YRF99hmIfNRMWiZ1kX8+Cf65C80gHcfEctfBw=="}]},"maintainers":[{"name":"rockitbaby","email":"babe@rockitbaby.de"}]},"0.0.2":{"name":"svg-cleaner","version":"0.0.2","description":"Cleaning SVG Files - A partial port of Scour to JavaScript.","keywords":["svg","assets","cleaner"],"homepage":"http://github.com/preciousforever/SVG-Cleaner","author":{"name":"Michael Schieben","email":"michael@precious-forever.com","url":"http://precious-forever.com"},"contributors":[{"name":"Joschi Kuphal","email":"joschi@kuphal.net","url":"http://jkphl.is"}],"repository":{"type":"git","url":"http://github.com/preciousforever/SVG-Cleaner"},"engines":{"node":"0.6.x"},"dependencies":{"commander":"1.0.x","cssom":"0.2.x","underscore":"x.x.x","cheerio":"0.9.x"},"devDependencies":{"mocha":"*","expect.js":"*"},"scripts":{"test":"make test"},"bin":{"svg-cleaner":"./bin/svg-cleaner"},"bugs":{"url":"http://github.com/preciousforever/SVG-Cleaner/issues"},"_id":"svg-cleaner@0.0.2","dist":{"shasum":"5917e4d6289b738e45876df73f4b910c090e3f63","tarball":"https://registry.npmjs.org/svg-cleaner/-/svg-cleaner-0.0.2.tgz","integrity":"sha512-1gwJFaQjveqS6uTmw5P0g4IoTA/0omdEWgE5pyQ1zyI/3yM9xE0IK5dvM33yAFvETLDrwhvKO6/B02EwsMW5aQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBlJEBmPzvJw1n2K24QpDmTwBMlObehUzE1E/+Qzz6CnAiEA+jWuooZS3UYYysGhma/fkTt229QKocXwaT07wkhlWVA="}]},"_from":".","_npmVersion":"1.3.6","_npmUser":{"name":"rockitbaby","email":"babe@rockitbaby.de"},"maintainers":[{"name":"rockitbaby","email":"babe@rockitbaby.de"}]},"0.0.3":{"name":"svg-cleaner","version":"0.0.3","description":"Cleaning SVG Files - A partial port of Scour to JavaScript.","keywords":["svg","assets","cleaner"],"homepage":"http://github.com/preciousforever/SVG-Cleaner","author":{"name":"Michael Schieben","email":"michael@precious-forever.com","url":"http://precious-forever.com"},"contributors":[{"name":"Joschi Kuphal","email":"joschi@kuphal.net","url":"http://jkphl.is"}],"repository":{"type":"git","url":"http://github.com/preciousforever/SVG-Cleaner"},"engines":{"node":"0.6.x"},"dependencies":{"commander":"1.0.x","cssom":"0.2.x","underscore":"x.x.x","cheerio":"0.9.x"},"devDependencies":{"mocha":"*","expect.js":"*"},"scripts":{"test":"make test"},"bin":{"svg-cleaner":"./bin/svg-cleaner"},"bugs":{"url":"http://github.com/preciousforever/SVG-Cleaner/issues"},"_id":"svg-cleaner@0.0.3","dist":{"shasum":"9cf38d6d3e14c5435c2ad6ff4424168bbf85391c","tarball":"https://registry.npmjs.org/svg-cleaner/-/svg-cleaner-0.0.3.tgz","integrity":"sha512-ToP3gEpH5Pwv4HRevPiZBNDEA2hUEqIiTzt57JYedjFqJWbPNfY8YyUphvfqbrfv20LfU3HhSB5qCwh5jyrn/w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqWsNx4vvXAZ/6E+rnb9fvybRW374W5Q2e98xfZlpM0wIgWHFohwo8oSDcojs/kksEqJezIpHoshLvMNseSRq1T30="}]},"_from":".","_npmVersion":"1.3.6","_npmUser":{"name":"rockitbaby","email":"babe@rockitbaby.de"},"maintainers":[{"name":"rockitbaby","email":"babe@rockitbaby.de"}]},"0.0.4":{"name":"svg-cleaner","version":"0.0.4","description":"Cleaning SVG Files - A partial port of Scour to JavaScript.","keywords":["svg","assets","cleaner"],"homepage":"http://github.com/preciousforever/SVG-Cleaner","author":{"name":"Michael Schieben","email":"michael@precious-forever.com","url":"http://precious-forever.com"},"contributors":[{"name":"Joschi Kuphal","email":"joschi@kuphal.net","url":"http://jkphl.is"}],"repository":{"type":"git","url":"http://github.com/preciousforever/SVG-Cleaner"},"engines":{"node":">=0.6.0 <0.12"},"dependencies":{"commander":"1.0.x","cssom":"0.2.x","underscore":"x.x.x","cheerio":"0.9.x"},"devDependencies":{"mocha":"*","expect.js":"*"},"scripts":{"test":"make test"},"bin":{"svg-cleaner":"./bin/svg-cleaner"},"bugs":{"url":"http://github.com/preciousforever/SVG-Cleaner/issues"},"_id":"svg-cleaner@0.0.4","dist":{"shasum":"ef67c6049c6b2d706d6111953c95cd7e76135c3e","tarball":"https://registry.npmjs.org/svg-cleaner/-/svg-cleaner-0.0.4.tgz","integrity":"sha512-bEjWEMMqevCTmowETES7kAh7N34jMFFCpwZinil39cGqE4xS0u4aBwP3r965dvAJddQW7v3aGg1VlMKQN6VL5g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCfP5Y51yjsRc3rdgsSKhCsodKd233/g9RkxZreK+v7yAIgLxugZkEzx7JoDxIF68g+YY/tBuc3cfUJCVJG7yNQ/y8="}]},"_from":".","_npmVersion":"1.4.6","_npmUser":{"name":"rockitbaby","email":"babe@rockitbaby.de"},"maintainers":[{"name":"rockitbaby","email":"babe@rockitbaby.de"}]}},"readme":"SVG Cleaner\n===========\n\nA tool for cleaning SVG Files - partial port of Scour to JavaScript.\n\nVisit the original [Scour - an SVG scrubber, http://codedread.com/scour/](http://codedread.com/scour/)\n\nScour was created by Jeff Schiller.\n\nPlease note that this is a partial port, which means it is not finsihed at all.\nFor thoose who want to clean their SVG files and have them as clean as possible\nas I highly recommend to use the original Scour.py.\n(Please see the list of implemented and missing processing steps below.)\n\nAlternatives\n-----------\n\n*Recommended!* Be sure to check out [SVGO, a Nodejs-based tool for optimizing SVG vector graphics files.](https://github.com/svg/svgo)\n\nInstallation & Usage\n-----------\n\nAs Command Line Tool\n```\nnpm install svg-cleaner -g\nsvg-cleaner INPUT_FILE OUTPUT_FILE\n```\n\nAs module - simple interface:\n```js\nvar cleanedSvgString = require('svg-cleaner').clean(svgString);\n```\n\n```js\nrequire('svg-cleaner').cleanFile(srcFilename, targetFilename);\n```\n\nAs module - chainable interface\n```js\nvar SVGCleaner = require('svg-cleaner');\nvar mySVGCleaner = SVGCleaner.createCleaner();\nmySVGCleaner.load(svgString)\n  .shortenIDs()\n  .removeComments()\n  .svgString();\n\nvar svgStringWithShortIDAndWithoutComments = mySVGCleaner.svgString();\n```\n\nBackground\n--\nI needed a library to work with [SVG-Stacker](http://github.com/preciousforever/SVG-Stacker),\nthat could rename IDs and keep the references inside the SVG document structure intact.\nSVG-Stacker merges different svg files and needs to make sure that the ids from different\nfiles are unique in the merged version. I found that Scour implemented that feature.\n\nThe goal of the port was to bring the power of Scour to the JavaScript world, make it\navailable as commandline tool and usable as module for node.js.\n\nI tried to keep the ideas and way how Scour cleans SVG files. I translated the processing steps\nand copied most of the original comments from scour into the new source code, as they describe\nthe original ideas best. I marked all of these orginial comments by putting 'Scour:' in the first\nline and used the markdown syntax for quotes (>) to indent the original comment. \n\n- Missing processing steps are marked with an comment '@missing'.\n- Changed processing steps are marked with an comment containern '@extended' or '@changed'\n- Some functions and variable names are changed to (hopefully) be more descriptive.\n\nPlease see the [annotated JavaScript Source-Code](http://preciousforever.github.com/SVG-Cleaner/docs/svg-cleaner.html).\n\nTests\n--\nTests are based on [mocha](http://visionmedia.github.com/mocha/), run `make test`.\n\nVisual tests are based on [phantomjs](http://phantomjs.org/). The idea is to render and rasterize\nboth, the original SVG file and cleaned version of that SVG file to compare the rasterized results\nto ensure they are visualy identical.\nMake sure you have installed phantomjs, then run `make visualtest`.\n\nAPI\n--\n```js\nSVGCleaner.createCleaner();\n// creates SVG Cleaner instance\n\nSVGCleaner.load(svgString);\n// loads an SVG String\n\nSVGCleaner.readFileSync(srcFilename);\n// loads an SVG file\n\nSVGCleaner.clean();\n// performs all processing steps\n\nSVGCleaner.svgString();\n// returns SVG as String\n\nSVGCleaner.writeFileSync(targetFilename);\n// writes SVG to file\n```\n\nIt makes sense to use clean(), as processing steps need to be performend in a specific order. To make\nuse of single processing steps, you can call these steps directly.\nSee description below:\n\nImplemented processing steps\n--\n* Removal of namespaced elements\n\n  ```\n  removeNSElements(namespacesToRemove);\n  ```\n  \n  `namespacesToRemove`: array of namespace prefixes, e.g.: ['dc', 'rdf', 'sodipodi', 'cc', 'inkscape']\n* Removal of namespaced attributes\n\n  ```\n  removeNSAttributes(namespacesToRemove);\n  ```\n\n  `namespacesToRemove`: array of namespace prefixes\n* Removal of comments\n  ```\n  removeComments();\n  ```\n* Repairation of styles\n  ```\n  repairStyles();\n  ```\n* Removal of unreferenced elements\n  ```\n  removeUnreferencedElements();\n  ```\n* Removal of empty elements\n* Shortening of id attribute values\n  ```\n  shortenIDs(startNumber)\n  ```\n  `startNumber`: default: 1, optional\n  Shortens the IDs, spreadsheet-style, i.e. from a to z, then from aa to az, ba to bz, etc., until zz.\n* Removal of unreferenced id attributes\n  ```\n  removeUnreferencedIDs()\n  ```\n\nMissing\n--\nProcessing steps in scour, that are not implemented yet:\n\n* remove the xmlns: declarations now\n* ensure namespace for SVG is declared\n* check for redundant SVG namespace declaration\n* convert colors to #RRGGBB format\n* remove <metadata> if the user wants to\n* flattend defs elements into just one defs element\n* removeDuplicateGradientStops();\n* remove gradients that are only referenced by one other gradient\n* remove duplicate gradients\n* createGroupsForCommonAttributes()\n* move common attributes to parent group\n* remove unused attributes from parent\n* moveAttributesToParentGroup\n* remove unnecessary closing point of polygons and scour points\n* scour points of polyline\n* clean path data\n* scour lengths (including coordinates)\n* reducePrecision\n* removeDefaultAttributeValues\n* optimizeTransforms\n* convert rasters references to base64-encoded strings\n* properly size the SVG document\n\nLicense\n--\nSVG-Cleaner is released under the same license as Scour:\n\n[Apache License Version 2.0](SVG-Cleaner/blob/master/LICENSE)\n","maintainers":[{"name":"rockitbaby","email":"babe@rockitbaby.de"}],"time":{"modified":"2022-06-27T02:32:46.586Z","created":"2012-08-21T15:32:18.886Z","0.0.1":"2012-08-21T15:32:21.248Z","0.0.2":"2014-04-03T09:34:56.462Z","0.0.3":"2014-04-03T09:35:30.813Z","0.0.4":"2015-05-12T08:16:35.502Z"},"author":{"name":"Michael Schieben","email":"michael@precious-forever.com","url":"http://precious-forever.com"},"repository":{"type":"git","url":"http://github.com/preciousforever/SVG-Cleaner"},"homepage":"http://github.com/preciousforever/SVG-Cleaner","keywords":["svg","assets","cleaner"],"bugs":{"url":"http://github.com/preciousforever/SVG-Cleaner/issues"},"readmeFilename":"README.md","contributors":[{"name":"Joschi Kuphal","email":"joschi@kuphal.net","url":"http://jkphl.is"}]}