Skip to main content

A module for creating nice pictures of code

Project description

# picode

Picode is a Python library and a command-line tool which can convert codes to pictures.

This project is inspired from [carbon](

I wanted to create nice overviews for my project [Discode]( so I made it.

## Installing

Just open a terminal and type:

pip install -U picode

## How does it work?

This project uses [pygments]( for syntax highlighting and [pillow]( for processing images.

### Basic example

Here's a short example:

import picode

image_1 = picode.to_pic(file_path="main.cpp")
image_2 = picode.to_pic(code="#!python\nprint('Hello world!')")"image_1.png")"image_2.png")

Here's `main.cpp`:

#include <iostream>

int main()
std::cout << "Hello world!\n";
return 0;

Here's `image_1.png`:


Here's `image_2.png`:


### Documentation

Consult the [docs]( for more information about how to use it.

## Ideas / Improvements

⚠️ **I don't work on this project on a regular basis but rather when I want to. Don't expect any precise date for these features / ideas to be released.** ⚠️

- Upload the picture to [imgur](
- Copy the picture / picture's link to the clipboard
- Keyboard shortcuts
- Custom default style

## Contributing

Feel free to submit improvements / features / ideas by creating an issue to this project.

If you see any bugs, please create an issue with the details.

If you wanna merge your improvments, please ensure your code respects Google's formatting style by running `beautify.bat` if you're on Windows or `` if you're on Linux. You must have [yapf]( installed to run these scripts.

## Known issues

The parameter `show_line_numbers_separator` has no effect at the moment. It's apparently a problem from `pygments` library. I opened an [issue]( and I hope this this will be fixed soon.

`pygments` seems to have some difficulties to detect which language is used according to a provided code / file. To avoid incorrect syntax highlighting, you can explicitly specify the language using the `language` parameter.

Some tokens aren't recognized as they should do. It causes some issues with the syntax highlighting (some elements aren't colorized as they should be). It seems to be a problem with `pygments`. I opened an [issue]( and I hope this will be fixed soon.

## Changelog


[1.1.0] **Command-line tool**

Bugs fixes:

- Load default font in case the font name / files provided by the user isn't / aren't correct
- Use default style if the one provided by the user isn't correct.

Added Documentation


[1.0.0] First version of the project, providing a basic Python library.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
picode-1.1.1.tar.gz (620.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page