Skip to main content

Takes pictures of code!

Project description


This package takes pictures of source code

Example code:

from sshot import shot
from PIL import Image
code='''
print('Hello World!')
'''
image=shot(code,lang='python')
Image.fromarray(image).save('code.png')

The code above will create something like:

Use in command line:

sshot -i test.py -l python -o code.png
sshot -i test.py -l python -o code.png -b bg.png # Add background image.
sshot -i test.py -l python -o code.png -b 00FF00FF0000 # Red code background color, green line number background color.
sshot -i test.py -l python # Show the image in a tkinter window.

It is also supported to set the background image of code, like:

from sshot import shot
from PIL import Image
from sshot.background import Background
import numpy as np
code='''
print('Hello World!')
'''
bg=np.array(Image.open('bg.png'))
image=shot(code,lang='python',background=Background(bg))
Image.fromarray(image).save('code.png')

About optimization

This version is optimized, much faster now.

Sourceshot 1.0.0 takes 0.161 seconds when creating an image of a Python source code with 3 lines, while this version only takes 0.042 seconds.

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

sourceshot-1.0.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

sourceshot-1.0.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file sourceshot-1.0.1.tar.gz.

File metadata

  • Download URL: sourceshot-1.0.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.0

File hashes

Hashes for sourceshot-1.0.1.tar.gz
Algorithm Hash digest
SHA256 acba56c3ae04098fa87b885b9086c0d02d8cf593556466341c1f8fda82dcc1e1
MD5 475ecd5b59488fb79304f49dc9229454
BLAKE2b-256 2d4b0fc6fe747a7455da4e51945c74be7f9c08d8e8771f789ef0d551efd0efa2

See more details on using hashes here.

File details

Details for the file sourceshot-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: sourceshot-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.0

File hashes

Hashes for sourceshot-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ba6cfb6a105818b2d5e19690f489ed31e92502e8d1285fec10e44362384c75b
MD5 d34a5a08f0c2b5419cf6000560758893
BLAKE2b-256 b7d119795f72a035829dac9d4f53d3eb6dcb912a4ca36ef55eb7b36260bdb1a9

See more details on using hashes here.

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