{"id":29586688,"url":"https://github.com/duniul/crop-image-data","last_synced_at":"2025-07-20T03:31:20.209Z","repository":{"id":128545613,"uuid":"291500414","full_name":"duniul/crop-image-data","owner":"duniul","description":"✂️ Function for cropping an image through its ImageData.","archived":false,"fork":false,"pushed_at":"2024-02-19T10:29:30.000Z","size":575,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-15T23:05:59.674Z","etag":null,"topics":["canvas","crop-image","image","image-data","image-editing"],"latest_commit_sha":null,"homepage":"https://crop-image-data.netlify.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/duniul.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2020-08-30T15:44:29.000Z","updated_at":"2024-02-21T20:58:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"b8a9d28c-c6c0-4e68-851f-e3af61ff4345","html_url":"https://github.com/duniul/crop-image-data","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/duniul/crop-image-data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duniul%2Fcrop-image-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duniul%2Fcrop-image-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duniul%2Fcrop-image-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duniul%2Fcrop-image-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duniul","download_url":"https://codeload.github.com/duniul/crop-image-data/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duniul%2Fcrop-image-data/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265526216,"owners_count":23782275,"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":["canvas","crop-image","image","image-data","image-editing"],"created_at":"2025-07-20T03:31:10.411Z","updated_at":"2025-07-20T03:31:20.189Z","avatar_url":"https://github.com/duniul.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crop-image-data\n\n[![](https://img.shields.io/npm/v/crop-image-data?color=brightgreen)](https://www.npmjs.com/package/crop-image-data)\n[![](https://img.shields.io/bundlephobia/minzip/crop-image-data)](https://bundlephobia.com/result?p=crop-image-data)\n\n✂️ Function for cropping an image through its [ImageData].\n\n## Demo\n\nhttps://crop-image-data.netlify.app\n\n## Installation\n\n```sh\n# npm\nnpm install crop-image-data\n\n# pnpm\npnpm install crop-image-data\n\n# yarn\nyarn add crop-image-data\n```\n\n## Usage\n\n### `cropImageData(imageData, cropOptions)`\n\nCreates a cropped version of an ImageData-instance. Does not mutate the recieved instance.\n\n**Parameters:**\n\n- `imageData` - the ImageData-instance instance to crop\n\n- `cropOptions` - an object specifying the amount of pixels to crop from each side\n  - `top` - number of pixels to crop from the top\n  - `right` - number of pixels to crop from the right side\n  - `bottom` - number of pixels to crop from the bottom\n  - `left` - number of pixels to crop from the left side\n\n**Return value:**\n\nA new, cropped ImageData-instance.\n\n**Examples:**\n\n```js\nimport cropImageData from 'crop-image-data';\n\n// crop 5 pixels on every side\nconst cropped = cropImageData(imageData, { top: 5, right: 5, bottom: 5, left: 5 });\n\n// crop 50 pixels from the top\nconst croppedTop = cropImageData(imageData, { top: 50 });\n\n// crop 10 pixels on each side\nconst croppedSides = cropImageData(imageData, { left: 10, right: 10 });\n```\n\n## Related packages\n\n- [trim-image-data] - finds and trims whitespace (or a specified color) from an image using\n  `crop-image-data`\n\n[imagedata]: https://developer.mozilla.org/en-US/docs/Web/API/ImageData\n[trim-image-data]: https://github.com/duniul/trim-image-data\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduniul%2Fcrop-image-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduniul%2Fcrop-image-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduniul%2Fcrop-image-data/lists"}