This is a trivial utility to read source files, and render them as a JPG or PNG for the purposes of creating a wallpaper image from the source. It reads the input files, uses the Python pygments and pillow libraries to render the sources as an image, then chunks and stripes the image across the defined stripe dimensions. The easiest way to understand it is to see an example:
./imgfromsrc\
--style monokai\
--zoom 70\
--output-as png\
--output my-source.png\
--font "DejaVu Sans Mono"\
--stripe 1440,2560,2\
--lexer golang\
file1.go file2.go file3.go file4.go| Arg | Description |
|---|---|
--style monokai |
Same idea as a VS Code theme. E.g. monokai, dracula, github-dark, etc. |
--zoom 70 |
Zoom input sources to 70%. Also supports a px suffix though the output isn't exact. E.g. 800px could produce 900 pixels wide... |
--output-as png |
Outputs the file as a .png |
--output my-source.png |
The output file. Extension is optional. If omitted, names the output from the first input file except with extension .png or .jpg |
--font "DejaVu Sans Mono" |
The font. On Ubuntu, the following command lists values you can use for this arg: fc-list :spacing=mono family |
--stripe 1440,2560,2 |
Stripes the output horizontally. Values are monitor height, monitor width, and number of monitors. The value shown creates a 510x1440 dual-monitor wallpaper. |
--lexer golang |
The source parser - in this case Golang |
| Positional params | The source files to parse |
This command produces a dual-monitor 5120x1440 wallpaper from the CLI source:
./imgfromsrc\
--style monokai\
--zoom 120
--output-as png\
--font "DejaVu Sans Mono"\
--stripe 1440,2560,2\
--lexer python\
imgfromsrcResult:
