<p><span><span style="font-family:Verdana, Arial, Helvetica, sans-serif;line-height:19px;text-indent:26px;"><span style="font-size:14px;"><span style="font-family:Arial;line-height:26px;"><br></span></span></span></span></p>
### This package takes pictures of source code
Example code:
```python
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:
![](https://i.postimg.cc/sxLHWpJ7/code.png)
Use in command line:
```commandline
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:
```python
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')
```
Bugs below are fixed in this version:
1. Error when reading GIF files. (IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed.)
2. SVG files are read incorrectly.
3. Error when reading JSON files.
This version's command line tool is better at guessing the language of the code.
### Syntax highlight config in JSON file.
A correct syntax highlight config should have a 'config' key.
It can also have an optional 'default' key.
The 'config' key is a dictionary, the key in that dictionary stands for the token name in the TokenChecker class (builtin, identifier, etc.)
The 'default' key stands for the default color.
For example:
```json
{
"config": {
"builtin": [127,0,0],
"exception": [0,127,0],
"string": [0,0,127]
},
"default": [127,127,127]
}
```
Using the JSON file above to create a picture of the code "print('Hello World!'), you will get:
![](https://i.postimg.cc/Mp48Jdxz/code2.png)
Raw data
{
"_id": null,
"home_page": "https://github.com/none-None1/sourceshot",
"name": "sourceshot",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "code,picture",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/7d/80/de3ffc722e695e0cb215263be22e87744563119dbefd15ae6c116ea1e81f/sourceshot-2.0.1.tar.gz",
"platform": null,
"description": "<p><span><span style=\"font-family:Verdana, Arial, Helvetica, sans-serif;line-height:19px;text-indent:26px;\"><span style=\"font-size:14px;\"><span style=\"font-family:Arial;line-height:26px;\"><br></span></span></span></span></p>\r\n\r\n### This package takes pictures of source code\r\nExample code: \r\n```python\r\nfrom sshot import shot\r\nfrom PIL import Image\r\ncode='''\r\nprint('Hello World!')\r\n'''\r\nimage=shot(code,lang='python')\r\nImage.fromarray(image).save('code.png')\r\n```\r\nThe code above will create something like:\r\n![](https://i.postimg.cc/sxLHWpJ7/code.png)\r\n\r\nUse in command line:\r\n```commandline\r\nsshot -i test.py -l python -o code.png\r\nsshot -i test.py -l python -o code.png -b bg.png # Add background image.\r\nsshot -i test.py -l python -o code.png -b 00FF00FF0000 # Red code background color, green line number background color.\r\nsshot -i test.py -l python # Show the image in a tkinter window.\r\n```\r\n\r\nIt is also supported to set the background image of code, like:\r\n```python\r\nfrom sshot import shot\r\nfrom PIL import Image\r\nfrom sshot.background import Background\r\nimport numpy as np\r\ncode='''\r\nprint('Hello World!')\r\n'''\r\nbg=np.array(Image.open('bg.png'))\r\nimage=shot(code,lang='python',background=Background(bg))\r\nImage.fromarray(image).save('code.png')\r\n```\r\nBugs below are fixed in this version:\r\n1. Error when reading GIF files. (IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed.)\r\n2. SVG files are read incorrectly.\r\n3. Error when reading JSON files. \r\nThis version's command line tool is better at guessing the language of the code.\r\n\r\n### Syntax highlight config in JSON file.\r\n\r\nA correct syntax highlight config should have a 'config' key.\r\nIt can also have an optional 'default' key.\r\n\r\nThe 'config' key is a dictionary, the key in that dictionary stands for the token name in the TokenChecker class (builtin, identifier, etc.)\r\nThe 'default' key stands for the default color.\r\n\r\nFor example:\r\n```json\r\n{\r\n \"config\": {\r\n \"builtin\": [127,0,0],\r\n \"exception\": [0,127,0],\r\n \"string\": [0,0,127]\r\n },\r\n \"default\": [127,127,127]\r\n}\r\n```\r\nUsing the JSON file above to create a picture of the code \"print('Hello World!'), you will get:\r\n![](https://i.postimg.cc/Mp48Jdxz/code2.png)\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Takes pictures of code!",
"version": "2.0.1",
"project_urls": {
"Homepage": "https://github.com/none-None1/sourceshot"
},
"split_keywords": [
"code",
"picture"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e998606d82eda68f0e9c106e0d002487058a43ce75d1df6d068eab0028953fa7",
"md5": "03e53b21fc4c37c1cd31313785d28b95",
"sha256": "6a315ce1bd1bf00be9911079532dfedac307e8f70b730b15e0a05244c41d5b85"
},
"downloads": -1,
"filename": "sourceshot-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "03e53b21fc4c37c1cd31313785d28b95",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 9306,
"upload_time": "2023-06-29T03:43:20",
"upload_time_iso_8601": "2023-06-29T03:43:20.987238Z",
"url": "https://files.pythonhosted.org/packages/e9/98/606d82eda68f0e9c106e0d002487058a43ce75d1df6d068eab0028953fa7/sourceshot-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7d80de3ffc722e695e0cb215263be22e87744563119dbefd15ae6c116ea1e81f",
"md5": "b41fba4c8fcfeec3ef49f773b46bc848",
"sha256": "24bdaa2d5fe0efcdf2914e75534262e2808cda94a1a6b672fb1c15241bbaef13"
},
"downloads": -1,
"filename": "sourceshot-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "b41fba4c8fcfeec3ef49f773b46bc848",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 7610,
"upload_time": "2023-06-29T03:43:22",
"upload_time_iso_8601": "2023-06-29T03:43:22.932207Z",
"url": "https://files.pythonhosted.org/packages/7d/80/de3ffc722e695e0cb215263be22e87744563119dbefd15ae6c116ea1e81f/sourceshot-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-29 03:43:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "none-None1",
"github_project": "sourceshot",
"github_not_found": true,
"lcname": "sourceshot"
}