{"id":22911761,"url":"https://github.com/tjhorner/asciify","last_synced_at":"2025-04-01T10:47:21.682Z","repository":{"id":57538200,"uuid":"286875728","full_name":"tjhorner/asciify","owner":"tjhorner","description":"ASCII art library written in Go","archived":false,"fork":false,"pushed_at":"2020-08-12T14:50:53.000Z","size":1089,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T17:56:09.622Z","etag":null,"topics":["ascii-art","golang","golang-library","image-processing"],"latest_commit_sha":null,"homepage":"https://tjhorner.dev/asciify","language":"Go","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/tjhorner.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":"2020-08-12T00:17:27.000Z","updated_at":"2020-09-16T19:36:54.000Z","dependencies_parsed_at":"2022-09-07T16:50:39.532Z","dependency_job_id":null,"html_url":"https://github.com/tjhorner/asciify","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/tjhorner%2Fasciify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjhorner%2Fasciify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjhorner%2Fasciify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjhorner%2Fasciify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tjhorner","download_url":"https://codeload.github.com/tjhorner/asciify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246628418,"owners_count":20808106,"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","golang","golang-library","image-processing"],"created_at":"2024-12-14T04:17:53.530Z","updated_at":"2025-04-01T10:47:21.664Z","avatar_url":"https://github.com/tjhorner.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asciify\n\n[![GoDoc](https://godoc.org/github.com/tjhorner/makerbot-rpc?status.svg)](https://pkg.go.dev/github.com/tjhorner/asciify)\n\nAsciify is an ASCII art library written in Go. It has no external dependencies and is fairly customizable.\n\nYou can use it to convert images to ASCII art (and back to an image again, if you really want to).\n\n## Usage\n\n```shell\ngo get github.com/tjhorner/asciify\n```\n\n## Examples\n\n### Asciify With Default Palette\n\nPass in an `image.Image` to `Asciify` and it will do the thing.\n\n```go\n// Pretend we have `img` defined somewhere\nresult := asciify.Asciify(img, asciify.DefaultCharacterPalette)\n\n// `result` is of type `ASCIIArt`, which you can use like a `[][]string`\nchar := result[0][5]\n\n// Or if you want the art as a single string, use the String() convenience method\nfmt.Println(result.String())\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eResult\u003c/summary\u003e\n\n  ### Input\n  \u003cimg src=\"test_fixtures/gopher.png\"/\u003e\n\n  ### Output\n\u003cpre\u003e\n      `-vUx/(|fvC1\"      \n  :l^-J/{]????[}{|Y[)r~. \n.)njCf[~\u003c]}??}+;:\u003e}/j1f- \n\u003ejuc1?`  .+[[+^   \u003e[f0[C.\n{)wv[]zi  ,}}|q\u003e  \"}]x[J \nIzf}[x#[  ^}[rd\u003c  ,}?(Y\u003c \n !Y?[??^  i)/[l. '_[-1}  \n ^c??}\u003e,:\u003c|b%O]\u003c~]}??[f  \n :r???[}}{1Y0f1}[]???]X  \n lt??????}-~-\u003c]}??????L. \n lt??????])\u003c+]1???????U. \n ;j???????}_?]]???????Y' \n ,x???????]{{}????????X' \n ^v???????????????????z` \n 'Y???????????????????z` \n .C???????????????????z` \n^+U???????????????????x):\nU?(???????????????????)?c\nXjv???????????????????tvC\n::J???????????????????fi`\n `z???????????????????/! \n \"u???????????????????|\u003e \n ,x???????????????????|\u003e \n ;j???????????????????|i \n ;j???????????????????fI \n ,x???????????????????u\" \n `z???????????????????C. \n  U??????????????????[f  \n  }{?????????????????j!  \n  ^U????????????????[u   \n   ~x?????????????-[Y:   \n  .)/)}??????????]()}|   \n  !tifcCj1}]][}(nY]J+z^  \n  ;Yx~ '![fuvx|_:. ;Lj.  \n\u003c/pre\u003e\n\u003c/details\u003e\n\n### Asciify With Custom Palette\n\nYou can also use custom character palettes if you want. The default palette is suitable for most cases, but you might want to use different characters for different scenarios.\n\nTo do so, just make a `CharacterPalette` with the characters you'd like to appear in the output, ordered from darkest to lightest.\n\nThe default palette comes from [here](http://mewbies.com/geek_fun_files/ascii/ascii_art_light_scale_and_gray_scale_chart.htm).\n\n```go\n// Let's use a custom palette\npalette := asciify.CharacterPalette{\"A\", \"B\", \"C\", \"1\", \"2\", \"3\"}\n\nresult := asciify.Asciify(img, palette)\n\nfmt.Println(result.String())\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eResult\u003c/summary\u003e\n\n  ### Input\n  \u003cimg src=\"test_fixtures/gopher.png\"/\u003e\n\n  ### Output\n\u003cpre\u003e\n33333332CC11111CC13333333\n333232C11222221111C111233\n3111C11222122122321111123\n21CC12333321123333211C1C3\n11BC12C2333111B23331211C3\n2C1111B1333111B2333121C23\n32C2122333211123332121133\n33C22123321BAC22211221133\n32122211111CC111122222C33\n3212222221222221222222C33\n3212222222122212222222C33\n3212222222122222222222C33\n3312222222211122222222C33\n33C2222222222222222222C33\n33C2222222222222222222C33\n33C2222222222222222222C33\n32C2222222222222222222113\nC21222222222222222222212C\nC1C22222222222222222221CC\n22C2222222222222222222123\n33C2222222222222222222123\n33C2222222222222222222123\n3312222222222222222222123\n3212222222222222222222123\n3212222222222222222222123\n3312222222222222222222C33\n33C2222222222222222222C33\n33C2222222222222222221133\n3311222222222222222221233\n333C22222222222222221C333\n33321222222222222221C2333\n3331111222222222221111333\n332121CC11112111CC2C2C333\n332C1233211CC1122332C1333\n\u003c/pre\u003e\n\u003c/details\u003e\n\n### Imagify\n\nIf you have some ASCII art and know the palette that was used to create it, you can also turn it back into an image.\n\nThis is pretty much just for fun and shouldn't ever be used in any serious way, as the resulting image will be extremely lossy (depending on your palette) and in grayscale.\n\n```go\n// Turn an image into ASCII art\nresult := asciify.Asciify(img, asciify.DefaultCharacterPalette)\n\n// Then re-imagify it\nimagified, _ := asciify.Imagify(result, asciify.DefaultCharacterPalette)\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eResult\u003c/summary\u003e\n\n  ### Input\n\u003cpre\u003e\n      `-vUx/(|fvC1\"      \n  :l^-J/{]????[}{|Y[)r~. \n.)njCf[~\u003c]}??}+;:\u003e}/j1f- \n\u003ejuc1?`  .+[[+^   \u003e[f0[C.\n{)wv[]zi  ,}}|q\u003e  \"}]x[J \nIzf}[x#[  ^}[rd\u003c  ,}?(Y\u003c \n !Y?[??^  i)/[l. '_[-1}  \n ^c??}\u003e,:\u003c|b%O]\u003c~]}??[f  \n :r???[}}{1Y0f1}[]???]X  \n lt??????}-~-\u003c]}??????L. \n lt??????])\u003c+]1???????U. \n ;j???????}_?]]???????Y' \n ,x???????]{{}????????X' \n ^v???????????????????z` \n 'Y???????????????????z` \n .C???????????????????z` \n^+U???????????????????x):\nU?(???????????????????)?c\nXjv???????????????????tvC\n::J???????????????????fi`\n `z???????????????????/! \n \"u???????????????????|\u003e \n ,x???????????????????|\u003e \n ;j???????????????????|i \n ;j???????????????????fI \n ,x???????????????????u\" \n `z???????????????????C. \n  U??????????????????[f  \n  }{?????????????????j!  \n  ^U????????????????[u   \n   ~x?????????????-[Y:   \n  .)/)}??????????]()}|   \n  !tifcCj1}]][}(nY]J+z^  \n  ;Yx~ '![fuvx|_:. ;Lj.  \n\u003c/pre\u003e\n\n  ### Output\n  \u003cimg src=\"test_fixtures/demon_gopher.png\"/\u003e\n\u003c/details\u003e\n\n## FAQ\n\n### Can I resize the output image?\n\nNo, as that is outside the scope of this project. Since asciify takes in an `image.Image`, it's compatible with the rest of the Go ecosystem, so you could use a library like this to do the resizing before you asciify the image: https://github.com/nfnt/resize\n\n### Shouldn't you be using runes instead of strings?\n\nProbably. My excuse is that someone somewhere might want to use multiple characters to represent a pixel.\n\n## License\n\n```\nCopyright 2020 TJ Horner\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjhorner%2Fasciify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftjhorner%2Fasciify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjhorner%2Fasciify/lists"}