{"id":19773595,"url":"https://github.com/ultraflame4/clir","last_synced_at":"2025-06-22T21:33:24.452Z","repository":{"id":153690456,"uuid":"630029426","full_name":"ultraflame4/CliR","owner":"ultraflame4","description":"A text renderer that renders unicode art from image into the terminal","archived":false,"fork":false,"pushed_at":"2024-05-06T12:38:39.000Z","size":2785,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T11:45:51.018Z","etag":null,"topics":["ascii-art","cli","generator","terminal","unicode-art","unicode-characters"],"latest_commit_sha":null,"homepage":"","language":"Python","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/ultraflame4.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":"2023-04-19T14:16:37.000Z","updated_at":"2024-07-02T04:41:49.000Z","dependencies_parsed_at":"2023-06-28T14:33:00.442Z","dependency_job_id":"35c41548-10e7-4c16-8a7e-a491cb835c3c","html_url":"https://github.com/ultraflame4/CliR","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/ultraflame4/CliR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultraflame4%2FCliR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultraflame4%2FCliR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultraflame4%2FCliR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultraflame4%2FCliR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ultraflame4","download_url":"https://codeload.github.com/ultraflame4/CliR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultraflame4%2FCliR/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261371970,"owners_count":23148723,"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":["ascii-art","cli","generator","terminal","unicode-art","unicode-characters"],"created_at":"2024-11-12T05:10:20.123Z","updated_at":"2025-06-22T21:33:19.441Z","avatar_url":"https://github.com/ultraflame4.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CliRenderer\n\n\u003e [!TIP]\n\u003e _Check out the rust rewrite here: [clir.rs](https://github.com/ultraflame4/clir_rs/) . Its ~4x faster, and has support for plain text mode to create text art that also looks great outside the terminal._\n\nA text renderer that renders unicode art from images to the terminal\n\n## Installation\n**Install the latest version with**: `pip install CliRenderer`\n\n## Usage\nSee `clirender --help` for a list of options and arguments.\n\n### Notice when reading output\n\n#### Linux\ncat the contents like this\n`cat outfile`\n\n#### Windows Powershell\ncat the contents like this\n`Get-Content outfile -encoding UTF8`\n\nThis is because the contents of the output files will be encoded in utf-8. powershell defaults to utf-7 for some reason.\n\n----\n## Example Outputs:\n![img.png](resources/img.png)\nOriginal - [Pixabay. (2017, February 25). View Of High Rise Buildings during Day Time](https://www.pexels.com/photo/view-of-high-rise-buildings-during-day-time-302769/)\n\n![img.png](resources/img2.png)\nOriginal - [Pixabay. (2017b, March 29). Dock under cloudy sky in front of mountain](https://www.pexels.com/photo/dock-under-cloudy-sky-in-front-of-mountain-206359/)\n\n## Credits\n1. Pixabay. (2017, February 25). View Of High Rise Buildings during Day Time. Pexels. https://www.pexels.com/photo/view-of-high-rise-buildings-during-day-time-302769/\n2. Pixabay. (2017b, March 29). Dock under cloudy sky in front of mountain. Pexels. https://www.pexels.com/photo/dock-under-cloudy-sky-in-front-of-mountain-206359/\n## How It Works\n\n### Disclaimer\nI am terrible at explaining things.\n\n----\n\nThis program mainly relies on unicode braille characters to represent pixels.\n\nBraille characters are basically a 2x4 grid of dot(s).\n\nFirst, I grayscale the image, this is important for later,\n\nthen I basically divided the image into many cells of 2x4 pixels width and height.\n\nAfter because each image cell consists of 2x4 pixels that is grayscale, I can easily find the middle color.\nCycling through the cell, we can now convert the pixels into binary.\nPixel in the cell that are darker than the middle will be False\nPixels that are lighter wil be True\nNow we have a boolean array representing bits.\n\nThe table below represent how each pixel in the cell correspond to its position in the array.\n| 1 | 5 |\n|---|---|\n| 2 | 6 |\n| 3 | 7 |\n| 4 | 8 |\n\nCoincidentally, braille characters are ordered the similarly in unicode.\n| 1 | 4 |\n|---|---|\n| 2 | 5 |\n| 3 | 6 |\n| 7 | 8 |\n\nHowever, for some reason, 7 is inserted before 4.\n\nSo we can just account for that by rearranging the array before converting it into binary like so:\n```python\n#pixels is the boolean array\nconverted = [pixels[7], pixels[3], pixels[6], pixels[5], pixels[4], pixels[2], pixels[1], pixels[0]]\n```\n\nAfter converting the array into binary, the binary is the index of the character in the string we need.\n\n#### Coloring\n\nDuring the process above, another image is generated, we call this a mask,\n\nwhere it is white, the pixel will be represented by the braille character.\n\nwhere it is black, the pixel will be represented by the background color.\n\nWe once again divide the image up into cells,\n\niterating through the pixels in the cells, we set 2 colors for each cell: fore and back.\n\nThe fore color is calculated by averaging the color from the image where pixel in the mask is white.\n\nThe back color is calculated by similarily but using where the pixel in the mask is black.\n\nThen using [rich.py](https://github.com/Textualize/rich), we can color the foreground and background of each character using the fore and back character of each cell.\n\n### More characters\nbraille characters unfortunately do not really take up the entire character space given to them.\n\nThis makes less noticeable, however we can subsitute some of the braille characters to give them more \"weight\".\n\nFor example, I replaced \"⣀\" with \"▂\".\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultraflame4%2Fclir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fultraflame4%2Fclir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultraflame4%2Fclir/lists"}