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("BoardVisualisedFromFEN.SVG", "w")
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("BoardVisualisedFromPGN.SVG", "w")
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: