Code to image from the command line
Project description
🔥Code Nitro: Code to Image from the Command Line
Ever want to share your code as an image? Code Nitro can do that. Code Nitro is lightweight, has minimal dependencies, and works online and offline.
Don't send your code to third parties, use Code Nitro.
🛠️Installation
You can install the nitro command with pip.
pip install codenitro
Basic Usage
The simplest usage is to simply pass a filename. Code Nitro will automatically syntax highlight it based on its extension.
nitro myfile.cpp
# creates myfile.png
🎬 Examples
nitro nitro.py --lines=40-54 --theme=desert
nitro nitro.py --lines=40-54 --theme=forest
nitro nitro.py --lines=40-54 --theme=moon
nitro nitro.py --lines=40-54 --theme=blue
nitro nitro.py --lines=40-54 --theme=cool
⭐Features
- Convert an entire file to an image via command line. By default, Code Nitro will save it in the same directory with the same name (but with .png).
nitro my_code.py [options]
- Convert only part of a file by using
--lines. For example,--lines=5-10will print lines 5 through 10, inclusive.
nitro my_code.py --lines=5-10
- Download a file from GitHub and convert it to an image by including the url in place of the filename.
nitro https://github.com/lukesalamone/code_nitro/blob/master/nitro.py
🐍 Python API
You can also import codenitro and call the exposed code_to_image() function programmatically.
from codenitro import code_to_image
image = code_to_image(
file_input="HelloWorld.java"
lines="23-34",
save=False # optionally return result rather than saving
)
print(type(image))
# "PIL.Image.Image"
🎨 Themes
Nitro comes with a few themes out of the box. Creating your own theme is easy as well. Just update your theme file in ~/.config/codenitro/themes.json
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codenitro-1.1.1.tar.gz.
File metadata
- Download URL: codenitro-1.1.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
028117db6ebf7a3065db696249e50fd96225882f5888b5f5cab3beaad58a525b
|
|
| MD5 |
87c3228e7e72a0128ea9b3d8d907c27a
|
|
| BLAKE2b-256 |
d3894e0f9782006a8dad6504800bf441877e7ff5c9c85a25f1d717bbf80501ff
|
File details
Details for the file codenitro-1.1.1-py3-none-any.whl.
File metadata
- Download URL: codenitro-1.1.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2198e23bb79cf29c92ccc0940a3ca64902b6fc717c3e4c536bad0a62965b396d
|
|
| MD5 |
56a4cef98f6290a5ecab23eb7d19a59d
|
|
| BLAKE2b-256 |
74876e05be0b698f928cbc17b430e6da3d388ffffa38e5e7004e8c69e12e2916
|