Created
May 21, 2017 12:15
-
-
Save bngsudheer/47a150aa8ac3d2dcc9f8a0c34dbafa80 to your computer and use it in GitHub Desktop.
FEN to SVG:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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