Render a chessboard from a PGN file I’d like to render a 2D chessboard image and save it after the last move as a PNG or JPEG from a given PGN file on a Linux console. How can I do this?

I have a PGN file and I want to get a screenshot of the board.

Seems to be a simple task but I can’t find a solution for it which is scriptable on the Linux console.

P.S. The wording "simple task" seems to be annoying for some readers here. Being not a native speaker I have a hard time to understand this nuance but I by no mean want to step on anybody's feet. Coming from a Linux console background I have the feeling that this should be doable on the console with ease. But that I haven't found the tool to do it.
You can use the SVG rendering functionalities of python-chess. This will allow you to create a SVG-formatted visualisation of any board position loaded using python-chess.
FEN to SVG
For example, given a FEN as input (say we save our python script as boardtosvg.py)
Using python3 and the python-chess library version 0.30.1
import chess
import chess.svg
import sys

arguments = sys.argv
fen = str(arguments[1])

board = chess.Board(fen)
boardsvg = chess.svg.board(board=board)
f = open(&quot;BoardVisualisedFromFEN.SVG&quot;, &quot;w&quot;)
f.write(boardsvg)
f.close()


Example, FEN: 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1'

Command to run your script from the terminal:
python boardtosvg.py 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1'


Saved file (in case you cannot open SVGs, you can at least use a browser such as chrome to view the file):

Position from a PGN to SVG
Similarly, if the input is a PGN file, then here's how you'd for istance save the SVG of the last position of the game (you can extend this to saving the position at any move):
import chess
import chess.svg
import chess.pgn
import sys

arguments = sys.argv
pgnfilename = str(arguments[1])

#Read pgn file:
with open(pgnfilename) as f:
    game = chess.pgn.read_game(f)
#Go to the end of the game and create a chess.Board() from it:
game = game.end()
board = game.board()
boardsvg = chess.svg.board(board=board)
f = open(&quot;BoardVisualisedFromPGN.SVG&quot;, &quot;w&quot;)
f.write(boardsvg)
f.close()


Example, PGN of Adams vs Kasparov 2005: adams_kasparov_2005.pgn
python boardtosvg.py 'adams_kasparov_2005.pgn'

Saved file:

Now all that is left to do is to convert the so-created SVG files to PNG, which you can also do in python, see the solutions in the link below:

Convert SVG to PNG in Python