{"id":15664823,"url":"https://github.com/hectorm/chafa-wasm","last_synced_at":"2025-04-15T16:59:54.471Z","repository":{"id":210783090,"uuid":"727404996","full_name":"hectorm/chafa-wasm","owner":"hectorm","description":"Chafa WebAssembly module to convert images to text.","archived":false,"fork":false,"pushed_at":"2025-04-14T16:22:24.000Z","size":21390,"stargazers_count":27,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T16:59:41.711Z","etag":null,"topics":["ansi","ansi-art","ascii","ascii-art","chafa","images","terminal","terminal-graphics","unicode","unicode-art"],"latest_commit_sha":null,"homepage":"https://hectorm.github.io/chafa-wasm/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hectorm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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},"funding":{"github":"hectorm","custom":"https://hector.molinero.dev/donate"}},"created_at":"2023-12-04T19:49:45.000Z","updated_at":"2025-03-12T22:51:49.000Z","dependencies_parsed_at":"2024-08-06T21:02:20.051Z","dependency_job_id":"543de1e7-af85-467a-ab73-81f02cd1b8c0","html_url":"https://github.com/hectorm/chafa-wasm","commit_stats":{"total_commits":215,"total_committers":2,"mean_commits":107.5,"dds":0.4744186046511628,"last_synced_commit":"fcce3b682c243ee7a2594570d28d544272146e6f"},"previous_names":["hectorm/chafa-wasm"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hectorm%2Fchafa-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hectorm%2Fchafa-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hectorm%2Fchafa-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hectorm%2Fchafa-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hectorm","download_url":"https://codeload.github.com/hectorm/chafa-wasm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249116231,"owners_count":21215142,"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":["ansi","ansi-art","ascii","ascii-art","chafa","images","terminal","terminal-graphics","unicode","unicode-art"],"created_at":"2024-10-03T13:44:15.799Z","updated_at":"2025-04-15T16:59:54.451Z","avatar_url":"https://github.com/hectorm.png","language":"JavaScript","funding_links":["https://github.com/sponsors/hectorm","https://hector.molinero.dev/donate"],"categories":[],"sub_categories":[],"readme":"# Chafa WebAssembly module\n\nHave you ever wanted to convert an image into a much less efficient and lower quality text representation? No? Well, with this module you can.\n\nWith this [Chafa](https://hpjansson.org/chafa/) port to WebAssembly you can convert an image into various text formats like ANSI escape codes, HTML or `console.log` arguments in Node.js, Deno, Bun and web browsers.\n\n\u003cp align=\"center\"\u003e\n\n![](./assets/preview.webp)\n\n\u003c/p\u003e\n\nThis module uses [Emscripten/Embind](https://emscripten.org) to expose low-level bindings of [libchafa](https://hpjansson.org/chafa/ref/) and also includes a higher-level API for the most common scenarios, see the [`docs/`](docs/README.md) directory for details.\n\nIf you just want to play with the parameters interactively, a demo application is also available [here](https://hectorm.github.io/chafa-wasm/).\n\n## Usage\n\n### Installation\n\n```sh\nnpm install chafa-wasm\n```\n\n### Example code\n\n```js\nimport { promises as fs } from \"node:fs\";\nimport { promisify } from \"node:util\";\nimport { stdout } from \"node:process\";\nimport Chafa from \"chafa-wasm\";\n\nconst chafa = await Chafa();\nconst imageToAnsi = promisify(chafa.imageToAnsi);\n\nconst image = await fs.readFile(\"./example.png\");\nconst { ansi } = await imageToAnsi(image.buffer, {\n  // Default values:\n  format: chafa.ChafaPixelMode.CHAFA_PIXEL_MODE_SYMBOLS.value,\n  height: 25,\n  fontRatio: 0.5,\n  colors: chafa.ChafaCanvasMode.CHAFA_CANVAS_MODE_TRUECOLOR.value,\n  colorExtractor: chafa.ChafaColorExtractor.CHAFA_COLOR_EXTRACTOR_AVERAGE.value,\n  colorSpace: chafa.ChafaColorSpace.CHAFA_COLOR_SPACE_RGB.value,\n  symbols: \"block+border+space-wide-inverted\",\n  fill: \"none\",\n  fg: 0xffffff,\n  bg: 0x000000,\n  fgOnly: false,\n  dither: chafa.ChafaDitherMode.CHAFA_DITHER_MODE_NONE.value,\n  ditherGrainWidth: 4,\n  ditherGrainHeight: 4,\n  ditherIntensity: 1.0,\n  preprocess: true,\n  threshold: 0.5,\n  optimize: 5,\n  work: 5,\n});\n\nstdout.write(ansi);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhectorm%2Fchafa-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhectorm%2Fchafa-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhectorm%2Fchafa-wasm/lists"}