{"id":20114186,"url":"https://github.com/iconify/tools","last_synced_at":"2025-04-09T06:11:50.510Z","repository":{"id":38710110,"uuid":"88663330","full_name":"iconify/tools","owner":"iconify","description":"Library for working with SVG: importing, validating, parsing, exporting.","archived":false,"fork":false,"pushed_at":"2024-09-26T17:41:08.000Z","size":5136,"stargazers_count":77,"open_issues_count":2,"forks_count":20,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-24T17:53:12.691Z","etag":null,"topics":["nodejs","optimization","svg","svgo"],"latest_commit_sha":null,"homepage":"https://iconify.design/docs/libraries/tools/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iconify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"iconify","github":["cyberalien"]}},"created_at":"2017-04-18T19:37:29.000Z","updated_at":"2024-10-14T13:53:59.000Z","dependencies_parsed_at":"2023-11-10T20:23:34.732Z","dependency_job_id":"56c32056-64e3-4e73-99ec-799393b03662","html_url":"https://github.com/iconify/tools","commit_stats":{"total_commits":260,"total_committers":3,"mean_commits":86.66666666666667,"dds":"0.011538461538461497","last_synced_commit":"41eae4591bf41b37546f9c1b12da22fa4e0ce0be"},"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconify%2Ftools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconify%2Ftools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconify%2Ftools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iconify%2Ftools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iconify","download_url":"https://codeload.github.com/iconify/tools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nodejs","optimization","svg","svgo"],"created_at":"2024-11-13T18:28:35.373Z","updated_at":"2025-04-09T06:11:50.485Z","avatar_url":"https://github.com/iconify.png","language":"TypeScript","funding_links":["https://opencollective.com/iconify","https://github.com/sponsors/cyberalien"],"categories":[],"sub_categories":[],"readme":"# Iconify Tools\n\nThis library is a collection of tools for importing, exporting and processing SVG images.\n\nIts main purpose is to convert icon sets and fonts to Iconify JSON collections, but it can be used for other purposes.\n\n## Installation\n\nFirst install it by running this command:\n\n```\nnpm install @iconify/tools --save\n```\n\n## Functions\n\nFunctions incuded in Iconify Tools:\n\n-   Download packages from git repository, GitHub API, GitLab API, NPM repository.\n-   Import SVGs from directory (and downloaded package), Figma API.\n-   Clean up, optimise, validate icons.\n-   Parse or change icon palette.\n-   Export icon sets in various formats.\n\nSee [Iconify Tools documentation](https://iconify.design/docs/libraries/tools/).\n\n### Limitations\n\nThis library is optinionated.\n\nIt does not allow the following content in icons:\n\n-   Scripts and event listeners.\n-   Any remote resources: images, fonts, links, etc...\n-   Raster images. They do not belong in scalable icons.\n-   Text. Text is rendered differently in various operating systems, so it should not be used in SVG. Convert text to shapes.\n-   All tags and attributes that are not approved are removed, including all XML namespaces.\n\nAll limitations listed above are by design.\n\nIconify Tools library is designed to export icons that are safe to use in any environment and render identically for all users.\n\n## Example\n\nThe following code example does the following:\n\n-   Imports set of SVG from directory.\n-   Cleans up all icons.\n-   Changes colors in all icons to `currentColor`.\n-   Optimises icons.\n-   Exports icons as `IconifyJSON` icon set.\n\n```js\nimport { promises as fs } from 'fs';\nimport { importDirectory } from '@iconify/tools/lib/import/directory';\nimport { cleanupSVG } from '@iconify/tools/lib/svg/cleanup';\nimport { runSVGO } from '@iconify/tools/lib/optimise/svgo';\nimport { parseColors, isEmptyColor } from '@iconify/tools/lib/colors/parse';\n\n(async () =\u003e {\n\t// Import icons\n\tconst iconSet = await importDirectory('svg/test', {\n\t\tprefix: 'test',\n\t});\n\n\t// Validate, clean up, fix palette and optimise\n\ticonSet.forEachSync((name, type) =\u003e {\n\t\tif (type !== 'icon') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst svg = iconSet.toSVG(name);\n\t\tif (!svg) {\n\t\t\t// Invalid icon\n\t\t\ticonSet.remove(name);\n\t\t\treturn;\n\t\t}\n\n\t\t// Clean up and optimise icons\n\t\ttry {\n\t\t\tcleanupSVG(svg);\n\t\t\tparseColors(svg, {\n\t\t\t\tdefaultColor: 'currentColor',\n\t\t\t\tcallback: (attr, colorStr, color) =\u003e {\n\t\t\t\t\treturn !color || isEmptyColor(color)\n\t\t\t\t\t\t? colorStr\n\t\t\t\t\t\t: 'currentColor';\n\t\t\t\t},\n\t\t\t});\n\t\t\trunSVGO(svg);\n\t\t} catch (err) {\n\t\t\t// Invalid icon\n\t\t\tconsole.error(`Error parsing ${name}:`, err);\n\t\t\ticonSet.remove(name);\n\t\t\treturn;\n\t\t}\n\n\t\t// Update icon\n\t\ticonSet.fromSVG(name, svg);\n\t});\n\n\t// Export as IconifyJSON\n\tconst exported = JSON.stringify(iconSet.export(), null, '\\t') + '\\n';\n\n\t// Save to file\n\tawait fs.writeFile(`output/${iconSet.prefix}.json`, exported, 'utf8');\n})();\n```\n\n## Documentation\n\nFull documentation is too big for simple README file. See [Iconify Tools documentation](https://iconify.design/docs/libraries/tools/) for detailed documentation with code samples.\n\n## Sponsors\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/sponsors/cyberalien\"\u003e\n    \u003cimg src='https://cyberalien.github.io/static/sponsors.svg'/\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## License\n\nLibrary is released with MIT license.\n\n© 2021-PRESENT Vjacheslav Trushkin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficonify%2Ftools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficonify%2Ftools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficonify%2Ftools/lists"}