{"id":23448734,"url":"https://github.com/alttiri/get-image-data","last_synced_at":"2025-10-30T19:30:38.856Z","repository":{"id":268160395,"uuid":"903468711","full_name":"AlttiRi/get-image-data","owner":"AlttiRi","description":"A simple JS library to get `ImageData`","archived":false,"fork":false,"pushed_at":"2024-12-15T17:31:36.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T13:37:58.037Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@alttiri/get-image-data","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/AlttiRi.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-12-14T17:22:25.000Z","updated_at":"2024-12-15T17:28:20.000Z","dependencies_parsed_at":"2024-12-14T20:18:49.335Z","dependency_job_id":"24af1acc-27d9-4776-b159-c0689efedbe8","html_url":"https://github.com/AlttiRi/get-image-data","commit_stats":null,"previous_names":["alttiri/get-image-data"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlttiRi%2Fget-image-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlttiRi%2Fget-image-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlttiRi%2Fget-image-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlttiRi%2Fget-image-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlttiRi","download_url":"https://codeload.github.com/AlttiRi/get-image-data/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239032245,"owners_count":19570770,"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":[],"created_at":"2024-12-23T22:18:29.993Z","updated_at":"2025-10-30T19:30:38.851Z","avatar_url":"https://github.com/AlttiRi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [get-image-data](https://github.com/AlttiRi/get-image-data)\n\nA simple JS library to get `ImageData`.\n\n```bash\nnpm i @alttiri/get-image-data\n```\n\n---\n\n- In Node.js use [`getImageDataWithSharp`](https://github.com/AlttiRi/get-image-data/blob/master/src/get-with-sharp.ts) to get `ImageData` with `sharp` library. \n\n  _Do not forget to install [`sharp`](https://www.npmjs.com/package/sharp) (`npm i sharp`).\n  Since `sharp` is not included as a dependency (This allows you to install the version of `sharp` you need)._\n\n\n- For browsers just use [`getImageDataWithCanvas`](https://github.com/AlttiRi/get-image-data/blob/master/src/get-with-canvas.ts). \n    \n  It uses `OffscreenCanvas` to get the `ImageData` for `File`/`Blob` input.\n\n  _You can get `File` from the HTML input element, and `Blob` from `fetch` response._\n\n---\n\n### Node.js examples\n\n```bash\nnpm i @alttiri/get-image-data sharp\n```\n\n#### An image path (`string`) as input:\n```ts\nimport {getImageDataWithSharp as getImageData} from \"@alttiri/get-image-data\";\n\nconst imagePath = \"C:/Windows/IdentityCRL/WLive48x48.png\";\nconst imageData = await getImageData(imagePath);\nconsole.log(imageData);\n```\n\n#### Or `ArrayBufferLike`/`ArrayBufferView`:\n```ts\nimport {getImageDataWithSharp as getImageData} from \"@alttiri/get-image-data\";\nimport fs from \"node:fs/promises\";\n\nconst imagePath = \"C:/Windows/IdentityCRL/WLive48x48.png\";\nconst fileBuffer = await fs.readFile(imagePath);\nconst imageData = await getImageData(fileBuffer);\nconsole.log(imageData);\n```\n\nThe result:\n```\n{\n  width: 48,\n  height: 48,\n  data: Uint8ClampedArray(9216) [255, 255, 255, 0, ...],\n  colorSpace: \"srgb\"\n}\n```\n---\n\n### Web examples\n\n```bash\nnpm i @alttiri/get-image-data\n```\n\n#### `File` from `HTMLInputElement`:\n\n```js\nimport {getImageDataWithCanvas as getImageData} from \"@alttiri/get-image-data\";\n\nconst input = document.querySelector(`input[type=\"file\"]`);\ninput.onchange = async function() {\n  const file = input.files[0];\n  const imageData = await getImageData(file);\n  console.log(imageData);\n}\n```\n\n#### `Blob` from `fetch` response:\n\n```ts\nimport {getImageDataWithCanvas as getImageData} from \"@alttiri/get-image-data\";\n\nconst imageUrl = \"https://i.imgur.com/DR94LKg.jpeg\";\nconst resp = await fetch(imageUrl);\nconst blob = await resp.blob();\nconst imageData = await getImageData(blob);\nconsole.log(imageData);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falttiri%2Fget-image-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falttiri%2Fget-image-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falttiri%2Fget-image-data/lists"}