A small Pillow-based helper that turns lists of FEN strings into PNG diagrams.
example: queen's gambit
This Python script uses the Pillow library to generate custom chess board diagrams as PNG images.
It allows you to visualize and print chess positions from FEN strings, design unique piece styles, and export diagrams for use in books, websites, or training materials.
The script is lightweight, open-source, and perfect for developers, chess teachers, and enthusiasts who want to automate or personalize chess illustrations with clean, printable output.
Tags: #chess #python #pillow #diagram-generator #chessboard #chess-diagram #image-generator #open-source #fen #board-visualizer
- Python 3.9 or newer.
- Pillow (
pip install pillow).
- Add one position per line inside
chess_board_printer.txtusing the format:Lines starting with<FEN string> -> <diagram name>;#are ignored so you can keep notes in the same file. - Keep your piece icons (1000×1000 PNGs work well) inside the
pieces/folder. The filenames must match the defaults listed inprint_positions.py.
Run the script from the project root:
python print_positions.pyEach valid entry creates position_<diagram name>.png in the same directory.
All tunable values live at the top of print_positions.py and can be edited in place:
SQUARE_SIZEcontrols the resolution of every board square (default 500px, resulting in 4000×4000 output).INCLUDE_BOARDtoggles between a coloured board and a transparent background (set it toFalsefor transparent output).LIGHT_SQUARE_COLORandDARK_SQUARE_COLORdefine the board palette.OUTPUT_NAME_TEMPLATElets you change the naming scheme of the generated PNGs.
To use different artwork, replace the PNGs inside the pieces/ folder with your
own files—keep the filenames identical so the FEN lookup table continues to work.
You can create sub-folders with alternative sets; just point PIECES_FOLDER to
the desired directory before running the script.