{"id":13729395,"url":"https://github.com/jiro4989/textimg","last_synced_at":"2025-05-15T17:09:25.040Z","repository":{"id":37588146,"uuid":"183251932","full_name":"jiro4989/textimg","owner":"jiro4989","description":"Command to convert from color text (ANSI or 256) to image.","archived":false,"fork":false,"pushed_at":"2025-05-12T20:11:08.000Z","size":3743,"stargazers_count":242,"open_issues_count":5,"forks_count":20,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-12T21:28:20.215Z","etag":null,"topics":["cli","command","escape-sequences","go","image"],"latest_commit_sha":null,"homepage":"","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/jiro4989.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":"2019-04-24T15:00:51.000Z","updated_at":"2025-05-12T20:11:10.000Z","dependencies_parsed_at":"2023-02-14T01:01:03.263Z","dependency_job_id":"5e898d23-8f05-4112-b318-7e36605aa1d4","html_url":"https://github.com/jiro4989/textimg","commit_stats":null,"previous_names":["jiro4989/coltoi"],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiro4989%2Ftextimg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiro4989%2Ftextimg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiro4989%2Ftextimg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiro4989%2Ftextimg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiro4989","download_url":"https://codeload.github.com/jiro4989/textimg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384989,"owners_count":22062422,"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":["cli","command","escape-sequences","go","image"],"created_at":"2024-08-03T02:00:59.635Z","updated_at":"2025-05-15T17:09:20.024Z","avatar_url":"https://github.com/jiro4989.png","language":"Go","funding_links":[],"categories":["Image Processing"],"sub_categories":["Open USP Tsukubai"],"readme":"# textimg\n\n![test](https://github.com/jiro4989/textimg/workflows/test/badge.svg)\n[![codecov](https://codecov.io/gh/jiro4989/textimg/branch/master/graph/badge.svg)](https://codecov.io/gh/jiro4989/textimg)\n\ntextimg is command to convert from color text (ANSI or 256) to image.  \nDrawn image keeps having colors of escape sequence.\n\n* [README on Japanese](./README_ja.md)\n\nTable of contents:\n\n\u003c!--ts--\u003e\n* [textimg](#textimg)\n  * [Usage](#usage)\n    * [Simple examples](#simple-examples)\n    * [With other commands](#with-other-commands)\n    * [Rainbow examples](#rainbow-examples)\n      * [From ANSI color](#from-ansi-color)\n      * [From 256 color](#from-256-color)\n      * [From 256 RGB color](#from-256-rgb-color)\n      * [Animation GIF](#animation-gif)\n      * [Slide animation GIF](#slide-animation-gif)\n    * [Using on Docker](#using-on-docker)\n    * [Saving shortcut](#saving-shortcut)\n  * [Installation](#installation)\n    * [Linux users (Debian base distros)](#linux-users-debian-base-distros)\n    * [Linux users (RHEL compatible distros)](#linux-users-rhel-compatible-distros)\n    * [With Go](#with-go)\n    * [Manual](#manual)\n  * [Help](#help)\n  * [Fonts](#fonts)\n    * [Default font path](#default-font-path)\n    * [Emoji font (image file path)](#emoji-font-image-file-path)\n    * [Emoji font (TTF)](#emoji-font-ttf)\n  * [Tab Completions](#tab-completions)\n    * [Bash](#bash)\n    * [Zsh](#zsh)\n    * [Fish](#fish)\n  * [Development](#development)\n    * [How to build](#how-to-build)\n    * [How to test](#how-to-test)\n  * [See also](#see-also)\n\n\u003c!-- Added by: jiro4989, at: Sat Jun 19 17:52:14 JST 2021 --\u003e\n\n\u003c!--te--\u003e\n\n## Usage\n\n### Simple examples\n\n```bash\ntextimg $'\\x1b[31mRED\\x1b[0m' \u003e out.png\ntextimg $'\\x1b[31mRED\\x1b[0m' -o out.png\necho -e '\\x1b[31mRED\\x1b[0m' | textimg -o out.png\necho -e '\\x1b[31mRED\\x1b[0m' | textimg --background 0,255,255,255 -o out.jpg\necho -e '\\x1b[31mRED\\x1b[0m' | textimg --background black -o out.gif\n```\n\nOutput image format is PNG or JPG or GIF.\nFile extension of `-o` option defines output image format.\nDefault image format is PNG. if you write image file with `\u003e` redirect then\nimage file will be saved as PNG file.\n\n### With other commands\n\ngrep:\n\n```bash\necho hello world | grep hello --color=always | textimg -o out.png\n```\n\n![image](https://user-images.githubusercontent.com/13825004/92329722-4e77d380-f0a4-11ea-97eb-0de316ebf6c7.png)\n\nscreenfetch:\n\n```bash\nscreenfetch | textimg -o out.png\n```\n\n[bat](https://github.com/sharkdp/bat):\n\n```bash\nbat --color=always /etc/profile | textimg -o out.png\n```\n\n![image](https://user-images.githubusercontent.com/13825004/92329806-03aa8b80-f0a5-11ea-95f4-d876c34d65d6.png)\n\nccze:\n\n```bash\nls -lah | ccze -A | textimg -o out.png\n```\n\n![image](https://user-images.githubusercontent.com/13825004/113440487-7e633b80-9427-11eb-8e03-4888308780a7.png)\n\nlolcat:\n\n```bash\nseq -f 'seq %g | xargs' 18 | bash | lolcat -f --freq=0.5 | textimg -o out.png\n```\n\n![image](https://user-images.githubusercontent.com/13825004/113440659-ce420280-9427-11eb-933b-7f9b1b618264.png)\n\n### Rainbow examples\n\n#### From ANSI color\n\ntextimg supports `\\x1b[30m` notation.\n\n```bash\ncolors=(30 31 32 33 34 35 36 37)\ni=0\nwhile read -r line; do\n  echo -e \"$line\" | sed -r 's/.*/\\x1b['\"${colors[$((i%8))]}\"'m\u0026\\x1b[m/g'\n  i=$((i+1))\ndone \u003c\u003c\u003c \"$(seq 8 | xargs -I@ echo TEST)\" | textimg -b 50,100,12,255 -o testdata/out/rainbow.png\n```\n\nOutput is here.\n\n![Rainbow example](docs/rainbow.png)\n\n#### From 256 color\n\ntextimg supports `\\x1b[38;5;255m` notation.\n\nForeground example is below.\n\n```bash\nseq 0 255 | while read -r i; do\n  echo -ne \"\\x1b[38;5;${i}m$(printf %03d $i)\"\n  if [ $(((i+1) % 16)) -eq 0 ]; then\n    echo\n  fi\ndone | textimg -o 256_fg.png\n```\n\nOutput is here.\n\n![256 foreground example](docs/256_fg.png)\n\nBackground example is below.\n\n```bash\nseq 0 255 | while read -r i; do\n  echo -ne \"\\x1b[48;5;${i}m$(printf %03d $i)\"\n  if [ $(((i+1) % 16)) -eq 0 ]; then\n    echo\n  fi\ndone | textimg -o 256_bg.png\n```\n\nOutput is here.\n\n![256 background example](docs/256_bg.png)\n\n#### From 256 RGB color\n\ntextimg supports `\\x1b[38;2;255;0;0m` notation.\n\n```bash\nseq 0 255 | while read i; do\n  echo -ne \"\\x1b[38;2;${i};0;0m$(printf %03d $i)\"\n  if [ $(((i+1) % 16)) -eq 0 ]; then\n    echo\n  fi\ndone | textimg -o extrgb_f_gradation.png\n```\n\nOutput is here.\n\n![RGB gradation example](docs/extrgb_f_gradation.png)\n\n#### Animation GIF\n\ntextimg supports animation GIF.\n\n```bash\necho -e '\\x1b[31mText\\x1b[0m\n\\x1b[32mText\\x1b[0m\n\\x1b[33mText\\x1b[0m\n\\x1b[34mText\\x1b[0m\n\\x1b[35mText\\x1b[0m\n\\x1b[36mText\\x1b[0m\n\\x1b[37mText\\x1b[0m\n\\x1b[41mText\\x1b[0m\n\\x1b[42mText\\x1b[0m\n\\x1b[43mText\\x1b[0m\n\\x1b[44mText\\x1b[0m\n\\x1b[45mText\\x1b[0m\n\\x1b[46mText\\x1b[0m\n\\x1b[47mText\\x1b[0m' | textimg -a -o ansi_fb_anime_1line.gif\n```\n\nOutput is here.\n\n![Animation GIF example](docs/ansi_fb_anime_1line.gif)\n\n#### Slide animation GIF\n\n```bash\necho -e '\\x1b[31mText\\x1b[0m\n\\x1b[32mText\\x1b[0m\n\\x1b[33mText\\x1b[0m\n\\x1b[34mText\\x1b[0m\n\\x1b[35mText\\x1b[0m\n\\x1b[36mText\\x1b[0m\n\\x1b[37mText\\x1b[0m\n\\x1b[41mText\\x1b[0m\n\\x1b[42mText\\x1b[0m\n\\x1b[43mText\\x1b[0m\n\\x1b[44mText\\x1b[0m\n\\x1b[45mText\\x1b[0m\n\\x1b[46mText\\x1b[0m\n\\x1b[47mText\\x1b[0m' | textimg -l 5 -SE -o slide_5_1_rainbow_forever.gif\n```\n\nOutput is here.\n\n![Slide Animation GIF example](docs/slide_5_1_rainbow_forever.gif)\n\n### Using on Docker\n\nYou can use textimg on Docker. ([DockerHub](https://hub.docker.com/r/jiro4989/textimg))\n\n```bash\ndocker pull jiro4989/textimg\ndocker run -v $(pwd):/images -it jiro4989/textimg -h\ndocker run -v $(pwd):/images -it jiro4989/textimg Testあいうえお😄 -o /images/a.png\ndocker run -v $(pwd):/images -it jiro4989/textimg Testあいうえお😄 -s\n```\n\nor build docker image of local Dockerfile.\n\n```bash\ndocker-compose build\ndocker-compose run textimg $'\\x1b[31mHello\\x1b[42mWorld\\x1b[m' -s\n```\n\n### Saving shortcut\n\n`textimg` saves an image as `t.png` to `$HOME/Pictures` (`%USERPROFILE%` on\nWindows) with `-s` options.  You can change this directory with\n`TEXTIMG_OUTPUT_DIR` environment variables.\n\n`textimg` adds current timestamp to the file suffix when activate `-t` options.\n\n```bash\n$ textimg 寿司 -st\n\n$ ls ~/Pictures/\nt_2021-03-21-194959.png\n```\n\nAnd, `textimg` adds number to the file suffix when activate `-n` options and\nthe file has existed.\n\n```bash\n$ textimg 寿司 -sn\n\n$ textimg 寿司 -sn\n\n$ ls ~/Pictures/\nt.png  t_2.png\n```\n\n## Installation\n\n### Linux users (Debian base distros)\n\n```bash\nwget https://github.com/jiro4989/textimg/releases/download/v3.1.9/textimg_3.1.9_amd64.deb\nsudo dpkg -i ./*.deb\n```\n\n### Linux users (RHEL compatible distros)\n\n```bash\nsudo yum install https://github.com/jiro4989/textimg/releases/download/v3.1.9/textimg-3.1.9-1.el7.x86_64.rpm\n```\n\n### With Go\n\n```bash\ngo install github.com/jiro4989/textimg/v3@latest\n```\n\n### Manual\n\nDownload binary from [Releases](https://github.com/jiro4989/textimg/releases).\n\n## Help\n\n```\ntextimg is command to convert from colored text (ANSI or 256) to image.\n\nUsage:\n  textimg [flags]\n\nExamples:\ntextimg $'\\x1b[31mRED\\x1b[0m' -o out.png\n\nFlags:\n  -g, --foreground string         foreground text color.\n                                  available color types are [black|red|green|yellow|blue|magenta|cyan|white]\n                                  or (R,G,B,A(0~255)) (default \"white\")\n  -b, --background string         background text color.\n                                  color types are same as \"foreground\" option (default \"black\")\n  -f, --fontfile string           font file path.\n                                  You can change this default value with environment variables TEXTIMG_FONT_FILE\n  -x, --fontindex int             \n  -e, --emoji-fontfile string     emoji font file\n  -X, --emoji-fontindex int       \n  -i, --use-emoji-font            use emoji font\n  -z, --shellgei-emoji-fontfile   emoji font file for shellgei-bot (path: \"/usr/share/fonts/truetype/ancient-scripts/Symbola_hint.ttf\")\n  -F, --fontsize int              font size (default 20)\n  -o, --out string                output image file path.\n                                  available image formats are [png | jpg | gif]\n  -t, --timestamp                 add time stamp to output image file path.\n  -n, --numbered                  add number-suffix to filename when the output file was existed.\n                                  ex: t_2.png\n  -s, --shellgei-imagedir         image directory path for shellgei-bot (path: \"/images/t.png\")\n  -a, --animation                 generate animation gif\n  -d, --delay int                 animation delay time (default 20)\n  -l, --line-count int            animation input line count (default 1)\n  -S, --slide                     use slide animation\n  -W, --slide-width int           sliding animation width (default 1)\n  -E, --forever                   sliding forever\n      --environments              print environment variables\n      --slack                     resize to slack icon size (128x128 px)\n  -h, --help                      help for textimg\n  -v, --version                   version for textimg\n```\n\n## Fonts\n\n### Default font path\n\nDefault fonts that to use are below.\n\n|OS     |Font path |\n|-------|----------|\n|Linux  |/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc |\n|Linux  |/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc |\n|MacOS  |/System/Library/Fonts/AppleSDGothicNeo.ttc |\n|iOS    |/System/Library/Fonts/Core/AppleSDGothicNeo.ttc |\n|Android|/system/fonts/NotoSansCJK-Regular.ttc |\n|Windows|C:\\Windows\\Fonts\\msgothic.ttc |\n\nYou can change this font path with environment variables `TEXTIMG_FONT_FILE` .\n\nExamples.\n\n```bash\nexport TEXTIMG_FONT_FILE=/usr/share/fonts/TTF/HackGen-Regular.ttf\n```\n\n### Emoji font (image file path)\n\ntextimg needs emoji image files to draw emoji.\nYou have to set `TEXTIMG_EMOJI_DIR` environment variables if you want to draw\none.\nFor example, run below.\n\n```bash\n# You can clone your favorite fonts here.\nsudo git clone https://github.com/googlefonts/noto-emoji /usr/local/src/noto-emoji\nexport TEXTIMG_EMOJI_DIR=/usr/local/src/noto-emoji/png/128\nexport LANG=ja_JP.UTF-8\necho Test👍 | textimg -o emoji.png\n```\n\n![Emoji example](docs/emoji.png)\n\n### Emoji font (TTF)\n\ntextimg can change emoji font with `TEXTIMG_EMOJI_FONT_FILE` environment variables and set `-i` option.\nFor example, switching emoji font to [Symbola font](https://www.wfonts.com/font/symbola).\n\n```bash\nexport TEXTIMG_EMOJI_FONT_FILE=/usr/share/fonts/TTF/Symbola.ttf\necho あ😃a👍！👀ん👄 | textimg -i -o emoji_symbola.png\n```\n\n![Symbola emoji example](docs/emoji_symbola.png)\n\n## Tab Completions\n\nYou can use TAB completions on your shell.\n\n### Bash\n\nRun below.\n\n```bash\nsudo cp -p completions/bash/textimg /usr/share/bash-completion/completions/textimg\n```\n\n### Zsh\n\nRun below.\n\n```bash\nsudo cp -p completions/zsh/textimg /usr/share/zsh/functions/Completion/_textimg\n\n# or\n# sudo cp -p completions/zsh/textimg {path to your $fpath}\n```\n\n### Fish\n\nRun below.\n\n```bash\nln -sfn completions/fish/textimg.fish $HOME/.config/fish/completions/textimg.fish\n```\n\n## Development\n\ngo version go1.17 linux/amd64\n\n### How to build\n\nYou run below.\n\n```bash\nmake setup-tools\nmake\n```\n\n**I didn't test on Windows.**\n\n### How to test\n\n```bash\nmake test\n\n# docker\nmake docker-build\nmake docker-test\n```\n\n## See also\n\n* \u003chttps://misc.flogisoft.com/bash/tip_colors_and_formatting\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiro4989%2Ftextimg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiro4989%2Ftextimg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiro4989%2Ftextimg/lists"}