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.
You can simply:
pip install pytoimage
Or you can also:
- Clone the repository to your local machine.
- Enter the directory.
- Download necessary modules/libraries.
git clone https://github.com/gabrielstork/pytoimage.git
cd pytoimage
pip install -r requirements.txt
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()
code.save_image('images/example.png')