Skip to content

Instantly share code, notes, and snippets.

@konradhalas
Created April 16, 2012 14:57
Show Gist options
  • Save konradhalas/2399273 to your computer and use it in GitHub Desktop.
Save konradhalas/2399273 to your computer and use it in GitHub Desktop.
src2png
#! /usr/bin/env python3
import os
import sys
import subprocess
if len(sys.argv) == 1:
files = os.listdir('.')
else:
files = sys.argv[1:]
for file_name in files:
if not file_name.endswith('png'):
output_file = file_name.split('.')[0] + '.png'
comand = 'pygmentize -O font_size=24 -o {} {}'.format(output_file, file_name)
print(comand)
subprocess.call(comand.split())
comand_2 = 'mogrify -border 3x3 {}'.format(output_file)
print(comand_2)
subprocess.call(comand_2.split())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment