{"id":16125705,"url":"https://github.com/dy/pxls","last_synced_at":"2025-09-12T22:31:40.157Z","repository":{"id":33276111,"uuid":"157437739","full_name":"dy/pxls","owner":"dy","description":"Convert any input pixels array to normalized 4-channel uint8 array","archived":false,"fork":false,"pushed_at":"2022-04-09T20:31:17.000Z","size":34,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T23:44:04.896Z","etag":null,"topics":[],"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/dy.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":"2018-11-13T19:53:49.000Z","updated_at":"2021-10-20T21:35:41.000Z","dependencies_parsed_at":"2022-08-07T20:17:35.137Z","dependency_job_id":null,"html_url":"https://github.com/dy/pxls","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fpxls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fpxls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fpxls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fpxls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dy","download_url":"https://codeload.github.com/dy/pxls/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232792154,"owners_count":18577263,"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-10-09T21:30:49.028Z","updated_at":"2025-01-06T22:04:56.441Z","avatar_url":"https://github.com/dy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pxls [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges) [![Build Status](https://travis-ci.org/dy/pxls.svg?branch=master)](https://travis-ci.org/dy/pxls)\n\nTake in custom pixels container, return normalized 4-channel Uint8Array with pixels. Detects float/int input pixels, handles Infinities, unfolds structures.\n\n[![npm install pxls](https://nodei.co/npm/pxls.png?mini=true)](https://npmjs.org/package/pxls/)\n\n```js\nvar pxls = require('pxls')\nvar ndarray = require('ndarray')\n\npxls([[0,0,0], [1,1,1]]) // \u003cuint8 0,0,0,255, 255,255,255,255\u003e\npxls([0, 1], 1) // \u003cuint8 0,0,0,255, 255,255,255,255\u003e\npxls([0,0,0, 1,1,1], [2,1]) // \u003cuint8 0,0,0,255, 255,255,255,255\u003e\npxls(new Ndarray([0,1], [2,1]) // \u003cuint8 0,0,0,255, 255,255,255,255\u003e\npxls(new Ndarray([0,0,0,1,1,1], [2,1,3]) // \u003cuint8 0,0,0,255, 255,255,255,255\u003e\n```\n\n## `let pixels = pxls(arr, shape|step?)`\n\nTakes input actual pixels container `arr` and returns 4 channels flat _Uint8Array_ `pixels` with layout `[r,g,b,a, r,g,b,a, r,g,b,a, ...]`.\n\n`arr` can be an Array of Arrays, TypedArray, Ndarray, ImageData or DOM container Image, Video, ImageBitmap, Canvas2D, Context2D, WebGLContext.\n\n1-channel input is mapped as grayscale `[v,v,v,255, v,v,v,255]`. 3-channel input fills last channel with `255` `[r,g,b,255, r,g,b,255]`.\n\n`shape` can describe the shape of input array, eg. `[100,100,3]` or `[10,10]`.\n\n`step` optionally can define input number of channels in flat array, that is detected automatically for nested/ndarrays.\n\n\n## See also\n\n* [to-uint8](https://ghub.io/to-uint8) − convert input argument to uint8 array.\n* [ndarray-to-bitmap-rgba](https://github.com/Jam3/ndarray-bitmap-to-rgba) − convert ndarray to rgba bitmap ndarray.\n\n## License\n\n(c) 2018 Dmitry Yv. MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fpxls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdy%2Fpxls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fpxls/lists"}