Skip to main content

Chess GIF Generator for Python

Project description

PyPI Downloads Coverage Status

Introduction

Generate a GIF of a chess game from a PGN with optional:

  • Analysis bar

  • Analysis chart

  • Numerical Annotation Glyphs (NAGs)

  • Move and check arrows

  • PGN module to add engine evaluations and calculate ACPL

    Details on breaking changes in the 1.0.0 release

    This release brings new features such as headers with player names, taken pieces and clocks, and Numeric Annotation Glyphs (NAGs).

    The module was also restructured for easier usage and extensibility. Code using version 0.2.0 and earlier will not work with version 1.0.0 - minor changes will be required to get back up and running again.

    Please see the examples and documentation for details.

Demo

GIF with all features enabled

import chess
import chess.engine
import chess.pgn
import io
from gifpgn import CreateGifFromPGN
from gifpgn.utils import PGN

pgn_string = ...
game = chess.pgn.read_game(io.StringIO(pgn_string))
if not PGN(game).has_analysis():
    with chess.engine.SimpleEngine.popen_uci("/path/to/stockfish") as engine:
        game = PGN(game).add_analysis(engine, chess.engine.Limit(depth=18))
g = CreateGifFromPGN(game)
g.enable_arrows()
g.add_headers(height=20)
g.add_analysis_bar()
g.add_analysis_graph()
g.enable_nags()
gif = g.generate("test_gif.gif")
https://i.imgur.com/hxQM0cl.gif

Small GIF with no analysis

import chess.pgn
import io
from from gifpgn import CreateGifFromPGN

pgn_string = ...
game = chess.pgn.read_game(io.StringIO(pgn_string))
g = CreateGifFromPGN(game)
g.board_size = 240
g.generate("test_small_gif.gif")
https://i.imgur.com/HkT2K8k.gif

Installing

Install with pip:

pip install gifpgn

Documentation

View on Read The Docs

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

gifpgn-1.0.0.tar.gz (499.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gifpgn-1.0.0-py3-none-any.whl (498.2 kB view details)

Uploaded Python 3

File details

Details for the file gifpgn-1.0.0.tar.gz.

File metadata

  • Download URL: gifpgn-1.0.0.tar.gz
  • Upload date:
  • Size: 499.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for gifpgn-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cabf7660f2145050fd3c2ef31a1a6b44a9508f2c8f8077d8f58add9a8c5f8b85
MD5 951bd472a41d11528a90562888a5b31b
BLAKE2b-256 d842e5bcd1f251840e5a022e13c820ef06bfde5879c7da561919a9cc2321b84f

See more details on using hashes here.

File details

Details for the file gifpgn-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gifpgn-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 498.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for gifpgn-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6918ac942b41e16d12614d583922a95c41fecb10fdfd928dd5e9569afe546865
MD5 bb1bd09812303c9fc54bbe5fdaba1a53
BLAKE2b-256 af1e796315b6755f997c3a178ccd3019a32c1f8ec21456a2028b9b5d1ef763ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page