{"id":18405746,"url":"https://github.com/pybites-open-source/pybites-carbon","last_synced_at":"2026-04-01T17:18:08.333Z","repository":{"id":46930649,"uuid":"405594426","full_name":"PyBites-Open-Source/pybites-carbon","owner":"PyBites-Open-Source","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-15T05:40:28.000Z","size":1787,"stargazers_count":92,"open_issues_count":3,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-28T00:37:14.872Z","etag":null,"topics":["hacktoberfest","python"],"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/PyBites-Open-Source.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,"zenodo":null}},"created_at":"2021-09-12T09:02:12.000Z","updated_at":"2026-03-18T13:39:27.000Z","dependencies_parsed_at":"2024-11-06T03:14:24.737Z","dependency_job_id":"ce130ee8-c087-49d6-970a-d4d2e8b10729","html_url":"https://github.com/PyBites-Open-Source/pybites-carbon","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/PyBites-Open-Source/pybites-carbon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyBites-Open-Source%2Fpybites-carbon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyBites-Open-Source%2Fpybites-carbon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyBites-Open-Source%2Fpybites-carbon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyBites-Open-Source%2Fpybites-carbon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PyBites-Open-Source","download_url":"https://codeload.github.com/PyBites-Open-Source/pybites-carbon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyBites-Open-Source%2Fpybites-carbon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["hacktoberfest","python"],"created_at":"2024-11-06T03:04:34.600Z","updated_at":"2026-04-01T17:18:08.305Z","avatar_url":"https://github.com/PyBites-Open-Source.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pybites Carbon\n\nA small utility to generate beautiful code images using [the awesome _carbon_ service](https://carbon.now.sh/).\n\n## Install Package\n\n### Install as a Standalone Tool using `uv tool` (Recommended)\nThe [uv package manager](https://docs.astral.sh/uv/) is a \"fast Python package and project manager.\"\n\nYou can add the package to [uv tools](https://docs.astral.sh/uv/guides/tools/).\n\nWhen using playwright, you must also download the browser binary. This package specifically uses the chromium browser.\n\n```shell\n# Add package to your tools\nuv tool add pybites-carbon\n\n# Install playwright\nuv tool run playwright install chromium\n# Another way to install playwright. 'uvx' is a alias for 'uv tool run'\nuvx playwright install chromium\n\n# To use pybites-carbon as a tool, run it with the command below using the '--from' option\n# because it clashes with another PyPI package called 'carbon'\nuv tool run --from pybites-carbon carbon\n\n# Run using the 'uvx' alias\nuvx --from pybites-carbon carbon\n```\n\n### Install as a Project Dependency using uv Package Manager\n\nIf you already have a virtual environment and pyproject.toml file set up, ignore the first two steps.\n\n```shell\n# Create a new virtual environment\nuv venv\n\n# Create a new project\nuv init\n\n# Install package as project dependency\nuv add pybites-carbon\n# Install playwright browser\nuv run playwright install chromium\n```\n\n### Install with pip\n\nInstall from PyPI using pip.\n\n```shell\n# Create a new virtual environment\npython -m venv .venv\n\n# Activate virtual environment\n# On macOS/Linux:\nsource .venv/bin/activate\n\n# On Windows:\n.venv\\Scripts\\activate\n\n# Install packages\npip install pybites-carbon\nplaywright install chromium\n```\n\n## Usage\n\nYou can load in code from a file, the clipboard or a snippet. You can change the language, the image background and theme. You can also provide a different directory to store the image.\n\n```\n$ carbon -h\nusage: carbon [-h] [-v] (-f CODE | -c | -s CODE) [-i] [-l LANGUAGE] [-b BACKGROUND] [-t THEME] [-d DESTINATION] [-w WT]\n              [--driver-path DRIVER_PATH]\n\nCreate a carbon code image\n\noptions:\n  -h, --help            show this help message and exit\n  -v, --version         show program's version number and exit\n  -f CODE, --file CODE  File with code (default: None)\n  -c, --clipboard       Use code on clipboard (default: None)\n  -s CODE, --snippet CODE\n                        Code snippet (default: None)\n  -l LANGUAGE, --language LANGUAGE\n                        Programming language (default: python)\n  -b BACKGROUND, --background BACKGROUND\n                        Background color (default: #ABB8C3)\n  -t THEME, --theme THEME\n                        Name of the theme (default: seti)\n  -d DESTINATION, --destination DESTINATION\n                        Specify folder where image should be stored (defaults to current directory) (default:\n                        /Users/bbelderbos/code/pybites-carbon)\n  -w WT, --wt WT        Windows control theme (default: sharp)\n```\n\n## Examples\n\n1. Make a hello world snippet carbon image:\n\n\t```\n\t$ carbon -s 'print(\"hello world\")'\n\t```\n\n\tResulting image:\n\n\t![image from string](https://pybites-tips.s3.eu-central-1.amazonaws.com/pybites-carbon-example1.png)\n\n2. Make a code image of a file, let's pick a [FastAPI](https://fastapi.tiangolo.com/) app I am working on:\n\n\t```\n\t$ cat $HOME/code/infinite-scroll/main.py\n\tfrom fastapi import FastAPI, Query\n\tfrom sqlmodel import select, Session\n\n\tfrom youtube.models import YouTube, YouTubeRead\n\tfrom youtube.db import engine\n\n\tapp = FastAPI()\n\n\n\t@app.get(\"/videos/\", response_model=list[YouTubeRead])\n\tdef read_videos(offset: int = 0, limit: int = Query(default=100, lte=100)):\n\t\twith Session(engine) as session:\n\t\t\tvideos = session.exec(\n\t\t\t\tselect(YouTube).offset(offset).limit(limit)\n\t\t\t).all()\n\t\t\treturn videos\n\t```\n\n\tRun the script with the `-f` option:\n\n\t```\n\tcarbon -f $HOME/code/infinite-scroll/main.py\n\t```\n\n\tResulting image:\n\n\t![image from file](https://pybites-tips.s3.eu-central-1.amazonaws.com/pybites-carbon-example2.png)\n\n3. Copying the following lines to the clipboard:\n\n\tHere is my favorite feature: make an image from code I currently have on my OS clipboard (thanks [`pyperclip`](https://pypi.org/project/pyperclip/)):\n\n\tTry it out, copy this code:\n\n\t```\n\tfrom time import sleep\n\n\tsleep(2)\n\t```\n\n\tThen run the script with `-c`:\n\n\t```\n\t$ carbon -c\n\t```\n\n\tResulting image:\n\n\t![image from clipboard](https://pybites-tips.s3.eu-central-1.amazonaws.com/pybites-carbon-example3.png)\n\n## Useful shell aliases\n\nI added this alias to my `.zshrc` to make it even easier:\n\n![image from string](https://pybites-tips.s3.eu-central-1.amazonaws.com/pybites-carbon-shell-alias.png)\n\n(Actually I created this image having this alias line on my clipboard, then I ran: `carbon -c -l application/x-sh -t monokai -b #D7D7BE -d $HOME/Downloads`)\n\n## Developer setup\n\n### Installation\n1. Clone or fork this repository\n\n2. Install packages using the following options.\n\t- Install using the uv package manager (recommended).\n\n\t\t`uv sync` also creates project virtual environment if it doesn't exist.\n\t\t```shell\n\t\tuv sync\n\t\tuv run playwright install chromium\n\t\t```\n\t- Install using pip.\n\n\t\tCreate a virtual environment and install packages using the requirements-dev.txt file.\n\t\t```shell\n\t\tpython -m venv .venv\n\t\tpip install requirements-dev.txt\n\t\tplaywright install chromium\n\t\t```\n\t- Install using the Makefile via `make setup`.\n\n3. Install Tesseract.\n\n\tRefer to their [instructions on the GitHub repo](https://github.com/tesseract-ocr/tesseract#installing-tesseract) or the [documentation](https://tesseract-ocr.github.io/tessdoc/Installation.html) for details.\n\n\t- Install on Ubuntu with:\n\t\t```\n\t\tsudo apt install tesseract-ocr\n\t\t```\n\n\t- Install on Windows following the [Mannheim University Library wiki](https://github.com/UB-Mannheim/tesseract/wiki).\n\n### Running pybites-carbon\nThe resulting `carbon_image.png` image will be downloaded to your current directory unless you specify a different destination directory using `-d` (or `--destination`).\n\nTo run the tests, type `pytest` or `make test` (it uses `pytesseract` - in the dev requirements - to read the text from the generated carbon image file).\n\nWe recommend running [`ruff`](https://docs.astral.sh/ruff/) before committing code. To set this up, run this after checking out the repo:\n\n```\n$ pre-commit install\npre-commit installed at .git/hooks/pre-commit\n```\n\n---\n\nEnjoy and feel free to mention [me](https://twitter.com/bbelderbos) or [Pybites](https://twitter.com/pybites) when you post one of the created images on Twitter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpybites-open-source%2Fpybites-carbon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpybites-open-source%2Fpybites-carbon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpybites-open-source%2Fpybites-carbon/lists"}