{"id":15551310,"url":"https://github.com/thatisuday/catage","last_synced_at":"2025-07-27T12:16:45.384Z","repository":{"id":35127935,"uuid":"210182016","full_name":"thatisuday/catage","owner":"thatisuday","description":"Node package and CLI tool to convert code into an image with syntax highlighting","archived":false,"fork":false,"pushed_at":"2022-12-30T18:46:25.000Z","size":7180,"stargazers_count":56,"open_issues_count":12,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T07:07:38.098Z","etag":null,"topics":["cli","command-line-tool","node","nodejs","npm","syntax","syntax-highlighting"],"latest_commit_sha":null,"homepage":"https://medium.com/@thatisuday/taking-easy-screenshots-of-your-code-with-this-awesome-cli-tool-bcc43aec653a","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thatisuday.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-22T16:51:33.000Z","updated_at":"2024-11-30T05:57:17.000Z","dependencies_parsed_at":"2023-01-15T14:23:10.301Z","dependency_job_id":null,"html_url":"https://github.com/thatisuday/catage","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatisuday%2Fcatage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatisuday%2Fcatage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatisuday%2Fcatage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thatisuday%2Fcatage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thatisuday","download_url":"https://codeload.github.com/thatisuday/catage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837280,"owners_count":21169374,"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-line-tool","node","nodejs","npm","syntax","syntax-highlighting"],"created_at":"2024-10-02T14:04:08.685Z","updated_at":"2025-04-14T07:07:45.606Z","avatar_url":"https://github.com/thatisuday.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# catage (**ca**t to im**age**)\nNode package and CLI tool to convert code into image with syntax highlighting.\n\n[![npm-version](https://img.shields.io/npm/v/catage?style=flat-square)](https://www.npmjs.com/package/catage)\n[![dependencies](https://img.shields.io/david/thatisuday/catage?style=flat-square)](https://www.npmjs.com/package/catage)\n[![downloads](https://img.shields.io/npm/dt/catage?style=flat-square)](https://www.npmjs.com/package/catage)\n[![license](https://img.shields.io/npm/l/catage?style=flat-square)](https://www.npmjs.com/package/catage)\n\n![example](/test/set-data-structure.png?raw=true)\n\n## Install using NPM\n```bash\nnpm install --save catage\nnpm install --global catage\n```\n\n## API\n```js\nconst path = require( 'path' );\n\n// import `convert` function and constants\nconst { convert, IMAGE_FORMATS, LANGUAGES, THEMES } = require( 'catage' );\n\n// convert a code file to an image file\nconvert( options );\n```\n\n### options\n| Name | Use | default Value |\n| ---- | --- | ------------- |\n| inputFile | Required: Relative or absolue path of a code (text) file. | `undefined` |\n| outputFile | Required: Relative or absolue of the output image file. | `undefined` |\n| language | Language of the code file. | `LANGUAGES.DART` |\n| theme | Theme for the syntax highlighting. | `THEMES.FIREWATCH` |\n| format | Format of the output image file. | `IMAGE_FORMATS.PNG` |\n| ignoreLineNumbers | Avoid adding line numbers to the code. | `false` |\n| scale | DPI scale factor of the output image. | `2` |\n| hasFrame | Add OSX window frame in the output image. | `true` |\n| execute | Execute a command with `inputFile` and inject result in output image file. | `null` |\n| displayCommand | An alternative command to display in the output image. | `execute` option value |\n\n\u003e Supported themes: https://iterm2colorschemes.com/ \u003cbr\u003e\nSupported languages: https://github.com/highlightjs/highlight.js/tree/master/src/languages \u003cbr\u003e\nSupported image formats: png,jpeg\n\n### Example\n```js\nconst path = require( 'path' );\n\n// import library functions and constants\nconst { convert, IMAGE_FORMATS, LANGUAGES, THEMES } = require( '../' );\n\n// create image of a code file\nconvert( {\n\n    // by ignoring `outputFile` option, promise resolution will return an image buffer\n    outputFile: path.resolve( __dirname, 'set-data-structure.png' ),\n\n    inputFile: path.resolve( __dirname, 'set-data-structure.dart' ),\n    language: LANGUAGES.DART,\n    format: IMAGE_FORMATS.PNG,\n    theme: THEMES.FIREWATCH,\n    ignoreLineNumbers: false,\n    scale: 2,\n    hasFrame: true,\n    frameTitle: 'Dart Sets Data Structure',\n    execute: 'dart __FILE__', // `__FILE__` placeholder is mandatory\n    displayCommand: 'dart sets.dart',\n} ).then( () =\u003e {\n    console.log( 'DONE!' );\n} );\n```\n\n#### Output Image\n![example](/test/set-data-structure.png?raw=true)\n\n\n## CLI\n```\n$ catage --help\nUsage: catage [options] \u003cinputFile\u003e \u003coutputFile\u003e\n\nConvert code (text) file to an image file\n\nOptions:\n  -v, --version                       Prints current CLI version.\n  -l, --language \u003clanguage\u003e           Language of the code in the input file\n  -t, --theme \u003ctheme\u003e                 Theme for the syntax highlighting\n  -f, --format \u003cformat\u003e               Format of the output image file ( png / jpeg / jpg / svg ).\n  -s, --scale \u003cscale\u003e                 DPI scale factor of the output image\n  --no-line-numbers                   Ignore line numbers in the code\n  --no-frame                          Ignore OSX window frame in the output image\n  --frame-title \u003cframeTitle\u003e          Title of the OSX window frame\n  --execute \u003cexecute\u003e                 Command to execute with the code file. You must provide `__FILE__` placeholder in the command string.\n  --display-command \u003cdisplayCommand\u003e  An alternative command to display in the output result.\n  -h, --help                          output usage information\n```\n\n### 1. Example\n```\ncatage recursive-function.py recursive-function.png -l python -t \"Builtin Solarized Light\" --frame-title \"Recursive Function\" --execute=\"python3 __FILE__\" --display-command=\"python recursive-function.py\"\n```\n\n#### Output Image\n\u003cimg src=\"/test/recursive-function.png?raw=true\" width=\"500\"/\u003e\n\n### 2. Simplest example\n```\ncatage go-defer.go go-defer.jpg -l go -t AtomOneLight -f jpeg --no-line-numbers --no-frame\n```\n#### Output Image\n\u003cimg src=\"/test/go-defer.jpg?raw=true\" width=\"500\"/\u003e\n\n\n## Tricks\n- If you want to take screenshot of a plain text file (no-language), provide any value to the `language` option that does not listed in supported languages. Since it is a plain text file, you can not use `execute` option. Also the code won't be syntax highlighted.\n- If you are using another program to trigger `catage` command, then make sure your program is inheriting `STDIO` of the shell process which started it. This is necessary for syntax highlighting.\n\n## Warning\nThis tool is dependent on `puppeteer` NPM package which has external dependency on headless Chromium browser. After installation, `puppeteer` downloads Chromium browser which could be more than 100MB in zipped format. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatisuday%2Fcatage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthatisuday%2Fcatage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatisuday%2Fcatage/lists"}