Create code snippet with pygments and pillow.
$ pip install code2imageThis 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.pngfrom 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.
Clone repo
$ git clone https://github.com/axju/code2image.gitCreate virtual environment for linux
$ python3 -m venv venv
$ source venv/bin/activateor create virtual environment for windows
$ python -m venv venv
$ venv/Scripts/activateupdate dev-tools
$ python -m pip install --upgrade wheel pip setuptools twine tox flake8Install local
$ pip install -e .Publish the packages
$ python setup.py sdist bdist_wheel
$ twine upload dist/*Run some tests
$ tox
$ python setup.py test