Skip to content

Instantly share code, notes, and snippets.

@bngsudheer
Created May 21, 2017 12:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bngsudheer/47a150aa8ac3d2dcc9f8a0c34dbafa80 to your computer and use it in GitHub Desktop.
Save bngsudheer/47a150aa8ac3d2dcc9f8a0c34dbafa80 to your computer and use it in GitHub Desktop.
FEN to SVG:
import chess, sys
import chess.svg
# Install python-chess to your Python3 virtualenv
# virtualenv -p python3 ~/path/to/myvenv
# source /path/to/myvenv/bin/activate
# Usage: python3 fen-to-svg.py 'myfenstring' outputfilename
# or /path/to/myvenv/bin/python3 fen-to-svg.py 'myfenstring' outputfilename
fen = sys.argv[1]
file_name = '{}.svg'.format(sys.argv[2])
board = chess.Board(fen)
boardsvg = chess.svg.board(board = board)
with open(file_name, "w") as f:
f.write(boardsvg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment