{"id":20743867,"url":"https://github.com/reiniiriarios/asset-resizer","last_synced_at":"2026-04-16T06:03:04.346Z","repository":{"id":234347199,"uuid":"788179779","full_name":"reiniiriarios/asset-resizer","owner":"reiniiriarios","description":"A minimal package to easily automate image asset resizing as a part of a build process.","archived":false,"fork":false,"pushed_at":"2024-05-01T23:10:14.000Z","size":303,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-25T18:59:19.323Z","etag":null,"topics":["assets","build-process","build-tool","image-processing","image-tools","npm-package"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/asset-resizer","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reiniiriarios.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-04-17T23:36:39.000Z","updated_at":"2024-05-01T23:10:17.000Z","dependencies_parsed_at":"2024-05-01T23:42:27.485Z","dependency_job_id":null,"html_url":"https://github.com/reiniiriarios/asset-resizer","commit_stats":null,"previous_names":["reiniiriarios/asset-resizer"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/reiniiriarios/asset-resizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiniiriarios%2Fasset-resizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiniiriarios%2Fasset-resizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiniiriarios%2Fasset-resizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiniiriarios%2Fasset-resizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reiniiriarios","download_url":"https://codeload.github.com/reiniiriarios/asset-resizer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiniiriarios%2Fasset-resizer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31873607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["assets","build-process","build-tool","image-processing","image-tools","npm-package"],"created_at":"2024-11-17T07:13:20.769Z","updated_at":"2026-04-16T06:03:04.309Z","avatar_url":"https://github.com/reiniiriarios.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asset-resizer\r\n\r\n[![latest version](https://img.shields.io/npm/v/asset-resizer?label=latest)](https://www.npmjs.com/package/asset-resizer)\r\n[![downloads](https://img.shields.io/npm/dt/asset-resizer)](https://www.npmjs.com/package/asset-resizer)\r\n![types: Typescript](https://img.shields.io/badge/types-Typescript-blue)\r\n![build](https://img.shields.io/github/actions/workflow/status/reiniiriarios/asset-resizer/publish.yaml)\r\n\r\nA minimal package to easily automate image asset resizing as a part of a build process. Uses [sharp](https://github.com/lovell/sharp).\r\n\r\n## Getting Started\r\n\r\nInstall `asset-resizer` with:\r\n\r\n```\r\nnpm i asset-resizer --save-dev\r\n```\r\n\r\nThen add `assetresizer.config.js` to your root directory, specifying what assets should be resized and where. Alternatively, you may specify a custom config file.\r\n\r\n[See example config.](examples/assetresizer.config.js)\r\n\r\n```js\r\n// assetresizer.config.js\r\n// alt: module.exports = {\r\nexport default {\r\n  baseUrl: \".\",\r\n  inputDir: \"assets\",\r\n  outputDir: \"build\",\r\n  flatten: true,\r\n  assets: [\r\n    {\r\n      file: \"icon.png\",\r\n      output: [\r\n        {\r\n          file: \"icon512.png\",\r\n          width: 512,\r\n        },\r\n        {\r\n          file: \"icon32.png\",\r\n          width: 32,\r\n        },\r\n        //...\r\n      ],\r\n    },\r\n    //...\r\n  ],\r\n};\r\n```\r\n\r\n### Command Line Usage\r\n\r\nRun:\r\n\r\n```\r\nasset-resizer parse\r\nasset-resizer parse --config=custom.config.js\r\n```\r\n\r\nValidate config file:\r\n\r\n```\r\nasset-resizer config\r\nasset-resizer config --config=custom.config.js\r\n```\r\n\r\nAdd these lines to your `package.json` to integrate into your build workflow.\r\n\r\n### Programmatic Usage\r\n\r\nAlternatively, you can use this package programmatically. [See examples.](examples/programmatic.ts)\r\n\r\n#### TypeScript / ESModule\r\n\r\n```ts\r\nimport { parseAllAssets, AssetResizerConfig } from \"asset-resizer\";\r\n\r\nconst config: AssetResizerConfig = {\r\n  baseUrl: \".\",\r\n  inputDir: \"assets\",\r\n  outputDir: \"build\",\r\n  flatten: true,\r\n  assets: [\r\n    //...\r\n  ],\r\n};\r\n\r\nparseAllAssets(config).then(() =\u003e {\r\n  console.log(\"done\");\r\n});\r\n```\r\n\r\n#### CommonJS\r\n\r\n```js\r\nconst { parseAllAssets } = require(\"asset-resizer\");\r\n\r\nparseAllAssets({\r\n  baseUrl: \".\",\r\n  inputDir: \"assets\",\r\n  outputDir: \"build\",\r\n  flatten: true,\r\n  assets: [\r\n    //...\r\n  ],\r\n}).then(() =\u003e {\r\n  console.log(\"done\");\r\n});\r\n```\r\n\r\n## Configuration Options\r\n\r\n### `AssetResizerConfig`\r\n\r\n| Option      | Type                       | Description                     | Default  |\r\n| ----------- | -------------------------- | ------------------------------- | -------- |\r\n| `baseUrl`   | `string`                   | Base url to run resizer from    | `.`      |\r\n| `inputDir`  | `string`                   | Directory of input files        | `assets` |\r\n| `outputDir` | `string`                   | Directory to build output files | `build`  |\r\n| `assets`    | `Array\u003cAssetResizerAsset\u003e` | Array of source assets          |          |\r\n\r\n### `AssetResizerAsset`\r\n\r\n| Option   | Type                        | Description                                 |\r\n| -------- | --------------------------- | ------------------------------------------- |\r\n| `file`   | `string`                    | Path to source asset relative to `inputDir` |\r\n| `output` | `Array\u003cAssetResizerOutput\u003e` | Array of output files to create             |\r\n\r\n### `AssetResizerOutput`\r\n\r\n| Option   | Type       | Description                                                                                                                                                            |\r\n| -------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\r\n| `file`   | `string`   | Name of file to create. Extension may be one of: `jpg`, `png`, `webp`, `avif`, `tiff`, `gif`, `dzi`, `v`.                                                              |\r\n| `width`  | `number?`  | Width, in pixels, of the target output file. One of `width` or `copy` must be present.                                                                                 |\r\n| `height` | `number?`  | (optional) Height, in pixels, of the target output file. If not specified, uses `width`.                                                                               |\r\n| `copy`   | `boolean?` | Optionally copy the file instead of resizing. One of `width` or `copy` must be present.                                                                                |\r\n| `fit`    | `string?`  | One of `cover`, `contain`, `fill`, `inside`, `outside`. Defaults to `cover`. See [sharp documentation](https://sharp.pixelplumbing.com/api-resize#resize) for details. |\r\n\r\n## Development\r\n\r\nFirst run `npm i`, then `npm link` to link the cli bin `asset-resizer` to the development directory.\r\n\r\n### Building\r\n\r\n`npm run build`\r\n\r\n### Tests\r\n\r\n- `npm run test` will run Jest.\r\n- `npm run test:cli` will run command from package.json.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freiniiriarios%2Fasset-resizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freiniiriarios%2Fasset-resizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freiniiriarios%2Fasset-resizer/lists"}