I’ve always found the routine for adding a chess diagram to a blog posting to be pretty tedious. I generate the diagram using some chess software, save the diagram as an image, upload the image to some directory on my site, and then link to it.
I wanted a way to include a diagram that did not require generating an image file. I’ve been tinkering with on-the-fly image generation using PHP scripts, and last night I finally got it all to work. I created a PHP script that takes a FEN position string as part of the URL and then creates the image automatically. I invite you to link to the script in order to add chess diagrams to your own blog or other web page.
[UPDATE (3-Dec-2006): The script is now called ChessImager. Detailed information about the ChessImager script can be found here.]
11 Comments
Wow, that’s a great script. It works well and I’ve been looking for one for a new (small) chess website I hope to start. Would it be possible for me to get the source code for that script? Thanks, and great blog!
Andrew, thanks for asking. I’ve decided not to release the source code for now. I intend to keep the URL for the script stable, and I won’t make any incompatible changes to it.
The new enhancements are great steve, I will be continuing to use this I think!
It is also possible to use a FEN to diagram conversion as the one on http://chessteacher.110mb.com/
This returns the same kind of chess diagram, but with a circle on the upper right side of the board to indicate who has to move.
Chess Teacher – the point of my script is to avoid the explicit step of converting to a diagram image. I think it’s a pain to have to create an image file and then upload it to the web somewhere in order to display it in a web posting.
Yes, but you don’t have to convert it to a diagram image and upload this to the web page.
All you have to do is for example enter something like
rnbqkb1r/pp2pp1p/3p1np1/8/3NP3/2N5/PPP2PPP/R1BQKB1R w KQkq – 0 6 in the post itself to get the diagram on the website. In this case a diagram of the Sicilian Dragon.
In my previous post the surrounding fen-tags have disappeared after submitting
Steve tomorrow October 22, 2007. So it’s been 1 year now, so it’s time to release the source code.
Ahmed—Why? What does this anniversary have to do with anything?
Well M.Steve I will be honest :I’m trying to develop a personal chess blog for myself, I reached a point where I need a diagram generator. I also intend to add client side javascript for people to interact with the pieces. So it is not sufficient that I make direct links to your chessimager within my chess blog, although it is an easy task, and your website is very responsive, so it will always return that chess position.I tried many times to write that code which generate a html table with dynamic nodes having pointing to the piece in question but I always fail. Also I have to write a code that must parse that FEN string before it can try to generate the table.
Ahmed—Thanks for elaborating. Your first comment seemed like a demand.
I have too many things going on right now to arrange to make the source code available, although I still might consider doing so in the future.
I have thought many times about making an interactive board using JavaScript like you describe. I do not think that the ChessImager PHP source will be that helpful to you. Making an interactive board will require a substantially different architecture and board-drawing method.
You might consider looking at Palview. It’s what I use to generate the interactive boards in my blog. Here’s an example: http://www.eddins.net/steve/chess/2007/09/12/112.