Chess Diagram from FEN

Copying fen2ppm

Introduction

fen2ppm is a program package that allows a chess author to create a diagram of a board position in graphic format. The resulting graphic image can be included in an HTML file with the <IMG SRC... statement.

The font used for creating chess diagrams is based on the Alfaerie Variant Chess Graphics page by David Howe.

David Howe received his inspiration from the fonts created by Eric Bentzen at Chess Alpha.

White King is an example of one of the Alfaerie chess pieces.

The size of the chess board is 392x392 pixels. Each square is 49x49 pixels. Because of the size of the board, you may count on one diagram per web page for a normal VGA screen.

If you want to create a smaller diagram, you have the option of using the gifsicle program to shrink your GIF image. You may use the --scale parameter to shrink the image.


How To Run

To create a chess diagram from a FEN file, run the following command:

      fen2ppm <fenfile.fen | xview stdin

If you want to create a PNG diagram, use the following example as a guide.

      fen2ppm <d4.fen | pnm2png >d4.png

If you want to create a JPEG file, run ppmtojpeg instead of pnmtopng.

Example:

      fen2ppm <d4.fen | ppmtojpeg >d4.jpg

For GIF files, run ppmtogif.

Example:

      fen2ppm <d4.fen | ppmtogif >d4.gif

To shrink the GIF image:

      gifsicle --scale .5 d4.gif >d4_sm.gif

In this example, gifsicle shrinks the image to half it's original size.

You may then convert the smaller GIF image to a PNG image with the following command:

      giftopnm <d4_sm.gif | pnmtopng >d4_sm.png


Creating Font Files

Font Directory

The make file fen2ppm.mak has a variable called PTH that contains the directory path for your font file.

Change the make file if you need to specify the font directory. The default is your local directory.


FEN Format

d4.fen is a sample diagram that comes with this package.

The following rules apply for creating a good FEN diagram file:


NETPBM package

The Debian package netpbm contains a program pnmtopng that converts a ppm file to the png format. The resulting png file can then be included in an HTML document.

You will need to install netpbm to work with fen2ppm. If you don't have Debian, you can easily compile netpbm from source.

If you have difficulty installing netpbm, you may have an easier time compiling pngminus. pngminus will allow you to create only PNG images. See the following information about installing pngminus.

The ppm file format is the most flexible graphic file format. You can create many other types of graphic files from a ppm file. Here is a list of formatting programs available.

The following table compares other graphic formats to the PNG format. The comment shows the disadvantage of the other format compared to the PNG format. Each graphic format is evaluated for inclusion in an HTML document.

Format Program Disadvantage compared to PNG
PNG pnmtopng Good compression, good license, flexible
GIF ppmtogif Restrictive license
JPEG ppmtojpeg Lossy compression
TIFF pnmtotiff Less compression
BMP ppmtobmp Less compression
PCX ppmtopcx Less compression
XPM ppmtoxpm XPM not for HTML
PS pnmtops PS not for HTML