Skip to content

gabrielstork/pytoimage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

📦 Transform your Python code in an image.

Resources

License

Stars

Watchers

Forks

Languages