Convert a PGN into a GIF with stockfish evaluation chart
Project description
gifpgn
Generate a GIF of a chess game from a PGN with optional stockfish analysis chart.
Installation
pip install gifpgn
For stockfish analysis a local stockfish binary is required. For best performance you can compile your own with support for the fastest instruction sets available on your hardware. Alternatively you can install using your distribution's package manager.
eg. apt-get install stockfish
Usage
- Import the package:
from gifpgn import CreateGifFromPGN
-
Initialise the class:
- Using a PGN string:
gif = CreateGifFromPGN(pgn_string)- Using a PGN file:
gif = CreateGifFromPGN(path_to_pgn,pgn_file=True) -
Optionally enable stockfish evaluation:
gif.enable_evaluation()
Stockfish evaluation is expensive and may take a large amount of time to complete.
The default depth of 18 provides a reasonable trade-off of time versus accuracy. Reducing this number will significantly reduce processing time.
Please see the enable_evaluation documentation below for configuation options for numbers of threads and memory usage.
- Generate the GIF:
gif.generate(output_file_path)
See reference section for optional parameters.
Reference
class CreateGifFromPGN()
Arguments:
pgnstr - PGN as a string or filepath. Filepath requires optional parameter pgn_file=Truereversebool, optional - Whether board should be reversed. Defaults to False.durationfloat, optional - Duration of each GIF frame in seconds. Defaults to 0.5.pgn_filebool, optional - Specify whether pgn contains a pgn string [False] or filepath [True]. Defaults to False.
Properties
board_sizeint - Size of the board in pixels. Defaults to 480.bar_sizeint - Width of the evaluation bar in pixels. Defaults to 30.graph_sizeint - Height of the evaluation graph in pixels. Defaults to 81.ws_colorstr - Color of the white squares. Defaults to "#f0d9b5".bs_colorstr - Color of the black squares. Defaults to "#b58863".max_evalint - Maximum position evaluation in centipawns. Defaults to 1000.
enable_evaluation
| enable_evaluation(path_to_stockfish='stockfish', depth: int = 18, threads: int = 1, memory: int = 1024)
Enable stockfish evaluation
Arguments:
path_to_stockfishstr, optional - Path to stockfish binary. Defaults to 'stockfish'.depthint, optional - Depth of stockfish evaluation. Defaults to 18.threadsint, optional - Number of threads to use in stockfish evaluation. Defaults to 1.memoryint, optional - Amount of memory to use in stockfish evaluation in Mb. Defaults to 1024.
generate
| generate(output_file: str)
Output GIF
Arguments:
output_filestr - Full path and filename of output file
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gifpgn-0.1.2.tar.gz.
File metadata
- Download URL: gifpgn-0.1.2.tar.gz
- Upload date:
- Size: 308.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b80ab1cd29633548ee756a05b1372218848e490827f064ecd44ecb4162fac5b
|
|
| MD5 |
9b7be571cddf439586df8bcd45c4040f
|
|
| BLAKE2b-256 |
fd2e4e78328a2b27b7df1734797b40fa7b80de4bc57bc9958969f00f9cd75ce5
|
File details
Details for the file gifpgn-0.1.2-py3-none-any.whl.
File metadata
- Download URL: gifpgn-0.1.2-py3-none-any.whl
- Upload date:
- Size: 320.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
230ccdc3cc9f2e87cd65cf9372e10b117962071877d1d04df2c997b9c84d1ce0
|
|
| MD5 |
71a8180b67549d15c318be9e0d2e646b
|
|
| BLAKE2b-256 |
b8184b6e877dc31d08dffc22334b8fbe50f2968b9b521a84cc212a5901fbbafb
|