{"id":16125506,"url":"https://github.com/semibran/img-data","last_synced_at":"2025-08-11T06:33:25.546Z","repository":{"id":57272515,"uuid":"93477275","full_name":"semibran/img-data","owner":"semibran","description":"Easily read from and write to ImageData instances","archived":false,"fork":false,"pushed_at":"2017-06-06T04:49:12.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T08:34:32.110Z","etag":null,"topics":["canvas","data","image","img"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/semibran.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}},"created_at":"2017-06-06T04:48:55.000Z","updated_at":"2020-05-19T03:12:36.000Z","dependencies_parsed_at":"2022-08-25T01:12:33.000Z","dependency_job_id":null,"html_url":"https://github.com/semibran/img-data","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/semibran/img-data","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimg-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimg-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimg-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimg-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/semibran","download_url":"https://codeload.github.com/semibran/img-data/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimg-data/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269727088,"owners_count":24465397,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"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":["canvas","data","image","img"],"created_at":"2024-10-09T21:29:51.441Z","updated_at":"2025-08-11T06:33:25.510Z","avatar_url":"https://github.com/semibran.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# img-data\n\u003e Easily read from and write to [`ImageData`](https://developer.mozilla.org/en-US/docs/Web/API/ImageData) instances\n\n## install\n```sh\nnpm install img-data\n```\n\n## usage\nThis example takes a `\u003ccanvas\u003e` element from the DOM and fills it with the color of the top-left pixel.\n```js\nconst { get, set } = require('img-data')\n\nvar canvas = document.getElementById('canvas')\nvar context = canvas.getContext('2d')\nvar data = context.getImageData(0, 0, canvas.width, canvas.height)\nvar color = get(data, { x: 0, y: 0 })\nfor (var y = 0; y \u003c canvas.height; y++) {\n  for (var x = 0; x \u003c canvas.width; x++) {\n    set(data, { x, y }, color)\n  }\n}\n\ncontext.putImageData(data, 0, 0)\n```\n\n### `color = get(image, position)`\nRetrieves the `color` (`[red, green, blue, alpha]`) of the pixel found at the given `position` on `image`.\n- `image`: The `ImageData` instance to read from\n- `position`: The position (`{ x, y }`) denoting the location of the desired pixel\n\n`get` will return `undefined` if `position` is out of bounds.\n\n### `set(image, position, color)`\nReplaces the color of the pixel found at the given `position` on `image` with `color`.\n- `image`: The `ImageData` instance to write to\n- `position`: The position (`{ x, y }`) denoting the location of the desired pixel\n- `color`: The color (`[red, green, blue, alpha]`) to use in the replacement process\n\n`set` will fail silently if `position` is out of bounds.\n\n## license\n[MIT](https://opensource.org/licenses/MIT) © [Brandon Semilla](https://git.io/semibran)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemibran%2Fimg-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsemibran%2Fimg-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemibran%2Fimg-data/lists"}