Skip to main content

Transform your Python code in an image.

Project description

pytoimage

Note: pytoimage is still in its initial stages, for now, you can normally transform your code in an image, choosing the backgroud and the text color. But, all code is currently with a single color, not differentiating anything, such as keywords, strings, functions... this will come in future versions.

Download

You can simply:

pip install pytoimage

Or you can also:

  1. Clone the repository to your local machine.
  2. Enter the directory.
  3. Download necessary modules/libraries.
git clone https://github.com/gabrielstork/pytoimage.git
cd pytoimage
pip install -r requirements.txt

Example

from pytoimage import PyImage

The PyImage class has three parameters: path (the Python code path), background (optional, the background color of the image) and font (optional, the path of a .ttf font).

code = PyImage('pytoimage/pytoimage.py', background=(15, 15, 15), font='fonts/Inconsolata.ttf')

The following method is optional, it allows you customize the theme of your image (see initial note).

palette = {
    'line': (149, 149, 149),
    'normal': (255, 255, 255),
}

code.set_color_palette(palette=palette)

To generate the image, you can simply call the method with no arguments, the start and end are optionals, these are the code intervals.

code.generate_image(start=39, end=51)

Then you can see and save the generated image.

code.show_image()

Example

code.save_image('images/example.png')

forthebadge forthebadge

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

pytoimage-0.0.1.tar.gz (56.9 kB view hashes)

Uploaded Source

Built Distribution

pytoimage-0.0.1-py3-none-any.whl (55.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page