Skip to content

full-stack-hero/code2image

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

code2image

Create code snippet with pygments and pillow.

https://raw.githubusercontent.com/axju/code2image/master/examples/shadow-box-small.png

Install

$ pip install code2image

Command line fun

This package was developed to automate some boring image creation process. But it has also a script for some command line fun.

$ code2image --help
$ code2image path/to/source/code.py path/to/output/image.png

Python examples

from code2image.cls import Code2Image

c2i = Code2Image()

# load the source code from this file
with open(__file__) as f:
    code = f.read()

# create the image with highlighted code
img = c2i.highlight(code)

# save the image
img.save('simple.png')

See the "examples" folder for more.

Development

Clone repo

$ git clone https://github.com/axju/code2image.git

Create virtual environment for linux

$ python3 -m venv venv
$ source venv/bin/activate

or create virtual environment for windows

$ python -m venv venv
$ venv/Scripts/activate

update dev-tools

$ python -m pip install --upgrade wheel pip setuptools twine tox flake8

Install local

$ pip install -e .

Publish the packages

$ python setup.py sdist bdist_wheel
$ twine upload dist/*

Run some tests

$ tox
$ python setup.py test

About

Create code snippet with pygments and pillow

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%