{"id":15396797,"url":"https://github.com/axe312ger/metalsmith-sharp","last_synced_at":"2025-04-15T22:30:51.623Z","repository":{"id":43341694,"uuid":"70951479","full_name":"axe312ger/metalsmith-sharp","owner":"axe312ger","description":"Flexible sharp integration for Metalsmith.","archived":false,"fork":false,"pushed_at":"2022-03-07T08:12:52.000Z","size":548,"stargazers_count":11,"open_issues_count":4,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T12:06:15.797Z","etag":null,"topics":["image-processing","metalsmith","sharp"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axe312ger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-14T22:26:50.000Z","updated_at":"2025-03-12T15:55:10.000Z","dependencies_parsed_at":"2022-09-26T16:21:01.857Z","dependency_job_id":null,"html_url":"https://github.com/axe312ger/metalsmith-sharp","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axe312ger%2Fmetalsmith-sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axe312ger%2Fmetalsmith-sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axe312ger%2Fmetalsmith-sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axe312ger%2Fmetalsmith-sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axe312ger","download_url":"https://codeload.github.com/axe312ger/metalsmith-sharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249165881,"owners_count":21223343,"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":["image-processing","metalsmith","sharp"],"created_at":"2024-10-01T15:34:56.197Z","updated_at":"2025-04-15T22:30:51.117Z","avatar_url":"https://github.com/axe312ger.png","language":"JavaScript","readme":"# metalsmith-sharp\n\n\u003e A fully flexible [sharp](https://sharp.pixelplumbing.com/) implementation for [Metalsmith](http://www.metalsmith.io/)\n\n[![](https://img.shields.io/npm/v/metalsmith-sharp.svg)](https://www.npmjs.com/package/metalsmith-sharp)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://axe312.mit-license.org)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n[![Build Status](https://img.shields.io/circleci/project/axe312ger/metalsmith-sharp.svg?maxAge=2592000)](https://circleci.com/gh/axe312ger/metalsmith-sharp)\n[![CodeCov Badge](https://img.shields.io/codecov/c/github/axe312ger/metalsmith-sharp.svg?maxAge=2592000)](https://codecov.io/gh/axe312ger/metalsmith-sharp)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\n## Install\n\n```js\nnpm install metalsmith-sharp\n```\n\n## Usage\n\nJust use it as regular Metalsmith plugin. An ES-Modules version is exposed as well, ready to be used with `import sharp from 'metalsmith-sharp'`\n\n```js\nconst Metalsmith = require('metalsmith')\nconst sharp = require('metalsmith-sharp')\n\nMetalsmith(__dirname)\n  .use(\n    sharp({\n      methods: [\n        {\n          name: 'resize',\n          args: [200, 200],\n        },\n        {\n          name: 'resize',\n          args: { fit: 'inside' },\n        },\n        {\n          name: 'toFormat',\n          args: ['jpeg'],\n        },\n      ],\n    })\n  )\n  .build((err) =\u003e {\n    if (err) return console.error(err)\n    console.log('Build successfully finished! It is 🥙 time!')\n  })\n```\n\nYou can also do multiple image manipulations in one call:\n\n```js\nconst Metalsmith = require('metalsmith')\nconst sharp = require('metalsmith-sharp')\n\nMetalsmith(__dirname)\n  .use(\n    sharp([\n      {\n        namingPattern: '{dir}{name}-version-1{ext}',\n        methods: [\n          { name: 'normalize' },\n          { name: 'flop' },\n          {\n            name: 'trim',\n            args: 15,\n          },\n        ],\n      },\n      {\n        namingPattern: '{dir}{name}-version-2{ext}',\n        methods: [\n          { name: 'normalize' },\n          {\n            name: 'trim',\n            args: 30,\n          },\n        ],\n      },\n    ])\n  )\n  .build((err) =\u003e {\n    if (err) return console.error(err)\n    console.log('Build successfully finished! It is 🥙 time!')\n  })\n```\n\nFor further examples can be found in the test directory.\n\n## Options\n\nDefault options:\n\n```js\n{\n  src: '**/*.jpg',\n  namingPattern: '{dir}{base}',\n  methods: [],\n  moveFile: false\n}\n```\n\n### methods\n\nArray of method objects that will trigger the corresponding sharp method. They will be called with the passed arguments and in the given order.\n\nCheck the [sharp API documentation](https://sharp.pixelplumbing.com/api-constructor) for a full list of supported methods.\n\n```js\n{\n  methods: [\n    {\n      name: 'anySharpMethod',\n      args: [400, 300],\n    },\n  ]\n}\n```\n\n#### args\n\nargs can be specified as an array that will be passed directly into the method or as a callback function.\n\nThe callback function will be provided with the [image metadata](http://sharp.dimens.io/en/stable/api-input/#metadata) and should return an array.\n\n```js\n{\n  method: [\n    {\n      name: 'resize',\n      args: (metadata) =\u003e [\n        Math.round(metadata.width * 0.5),\n        Math.round(metadata.height * 0.5),\n      ],\n    },\n  ]\n}\n```\n\n### src\n\nGlob for matching source files. All [minimatch features](https://github.com/isaacs/minimatch#features) are supported.\n\n```js\n{\n  src: '**/*.jpg'\n}\n```\n\n### namingPattern\n\nRenaming pattern for the resulting file. By default, the input file will be overwritten.\n\nSupported placeholders:\n\n- `{dir}`: Directory of file followed by slash\n- `{base}`: Full filename with extension\n- `{name}`: Filename without extension\n- `{ext}`: File extension with leading dot\n\n```js\n{\n  namingPattern: '{dir}/{name}-thumb{ext}'\n}\n```\n\n### moveFile\n\nIf the resulting file has a different name, the default behavior is to create a new file and keep the input file. Set this option to true to delete the input file.\n\n```js\n{\n  moveFile: true\n}\n```\n\n## Development\n\nThis project follows the [standard](https://github.com/feross/standard) coding and the [conventional changelog](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md) commit message style. Also it is configured to never decrease the code coverage of its tests.\n\nAlso make sure you check out all available npm scripts via `npm run`.\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/axe312ger/metalsmith-sharp/issues/new).\nBut before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxe312ger%2Fmetalsmith-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxe312ger%2Fmetalsmith-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxe312ger%2Fmetalsmith-sharp/lists"}