MatPlus.Net

 Website founded by
Milan Velimirović
in 2006

21:27 UTC
ISC 2024
 
  Forum*
 
 
 
 

Username:

Password:

Remember me

 
Forgot your
password?
Click here!
SIGN IN
to create your account if you don't already have one.
CHESS
SOLVING

Tournaments
Rating lists
1-Jan-2024

B P C F





 
 
MatPlus.Net Forum General Getting the FEN string from a diagram in this forum.
 
You can only view this page!
(1) Posted by Rosie Fay [Thursday, Jul 15, 2021 15:20]

Getting the FEN string from a diagram in this forum.


Given a diagram in a message in a topic in this forum, how do I obtain the corresponding FEN string in plain text?

You can do this in Chess Stack Exchange (https://chess.stackexchange.com/questions) because this allows any user (with enough reputation points) to edit any message -- this gives the code from which a diagram was produced, and this code includes the FEN. Not that I intend to go around editing anybody else's messages, but how do I obtain the FEN for a diagram in MAT Plus?
 
(Read Only)pid=21364
(2) Posted by Dmitri Turevski [Thursday, Jul 15, 2021 16:55]

This works in Chrome: right-click the diagram and select "Copy image address". The copied address includes something very similar to the FEN string (only position part w/o slashes, also it apparently does some aritmetics: 88 becomes 16):
http://www.matplus.net/i.php?f=16pPR5pkPP1p2S1p2B2K7PP4P4B4
Not sure if it's really useable, though.
 
 
(Read Only)pid=21365
(3) Posted by Rosie Fay [Thursday, Jul 15, 2021 17:49]

Thank you! That really has helped. I already have a program which takes plain text input, including FEN strings, and turns it into Tex which, with the help of Ulrike Fischer's package "chessboard", produces a PDF with lovely diagrams which I can view using SumatraPDF. My program doesn't understand MAT Plus fen, but it must be possible to do that. So, usable after a bit of work.
 
   
(Read Only)pid=21366
(4) Posted by Hauke Reddmann [Thursday, Jul 15, 2021 20:55]

Firefox can do the same. My suggestion, since you have to
convert it anyway: A mini python proggie which grabs the
URL*, reads its source, scans for FEN images and
converts it to standard FEN. Would cost me half an hour
maximum to write working Python code for that...

* e.g. https://www.codegrepper.com/code-examples/python/how+to+get+source+code+of+website+in+python
("requests" is no standard package and must be pip-installed!
Windows-R, execute "pip install requests")

DEMO PROGRAM:
import requests

url = "http://matplus.net/start.php?px=1626375649&app=forum&act=posts&fid=gen&tid=2722&pid=21361#n21361";
#URL example - kill the semicolon, system inserted it!
html_output_name = "out.txt"

req = requests.get(url, "html.parser")

with open(html_output_name, "w", encoding="utf-8") as f:
f.write(req.text)
f.close()
piccode = "src='i.php?f=" # all FEN pics start thus
with open(html_output_name, "r", encoding="utf-8") as f:
lines = f.readlines()
for line in lines:
#c+=1
if piccode in line:
idx=line.find("small")
print(line[42:idx-3]replace("%2F","/"))
f.close()


Output - all FENs of the images in the URL
6b1/8/8/2n2k2/8/3PP3/1p3P2/1B1K4
7Q/N7/4K3/8/n5q1/8/5R2/2k5
8/1BK5/7r/8/8/8/2RNR3/3k4
k7/1pP5/1P6/8/8/1K3rPR/1PPPPP2/8
r6k/2R4P/8/8/8/1P2PP2/6Bp/2K3S1
1K1s3B/r6q/pR6/k1pS1R2/p1P4r/P1S4B/Q7/8
kB5K/2P4B/P4rP1/4r3/2S1s3/1RP4S/3b4/6RQ
k7/1R6/P4K2/P7/P7/P5r1/8/7R
1N6/pq3P2/p2p4/P3k1B1/2RNp1r1/P1P1P3/2P1p1rp/4R2K

Untested if all images work this way!
 
   
(Read Only)pid=21367
(5) Posted by Hauke Reddmann [Friday, Apr 15, 2022 10:40]

EDIT: No, they don't - any pic generated by algebraic instead of forsyth
notation will also have its URL coded in algebraic notation.
Should be fairly simple to patch, but I'm too lazy at the moment
to write it :-)
 
   
(Read Only)pid=23039
(6) Posted by Hannu Harkola [Friday, Apr 15, 2022 20:09]

Helpmate Analyzer of Viktoras Paliulionis (http://helpman.komtera.lt/) has the OCR - optical character recognition feature. Upload a chessboard image or paste it from the clipboard. The resulting diagram may be corrected if necessary (very often it is). Then copy the FEN below the diagram.
 
   
(Read Only)pid=23042
(7) Posted by Sarah Hornecker [Saturday, Apr 16, 2022 07:42]

The chess composer edderiofer who also is well-versed in chess problem technology has sent me this link and allowed to post it in the forum also:
https://chessvision.ai/

(Sorry for the two notes then, Hauke! I sent them prior.)

EDIT: It does not handle fairy pieces usually, I was told.
 
   
(Read Only)pid=23044
(8) Posted by [Monday, Jun 20, 2022 12:39]

It is possible to do a gradient on borders but it takes a little bit of trickery. For example: https://codeprozone.com/code/css/38095/css-gradient-border.html
 
 
(Read Only)pid=23375

No more posts


MatPlus.Net Forum General Getting the FEN string from a diagram in this forum.