chess-scan
v1.0.1
Published
Convert chessboard images into FEN notation
Downloads
171
Readme
Chess Scan
Detect chess positions from images and convert them to FEN strings.
Features
- Detects chessboards from screenshots and images
- Recognizes all chess pieces
- Generates valid FEN strings
- Supports local files, URLs, buffers, and raw image data
Installation
npm install chess-scanUsage
Generate FEN
const { imageToFen } = require('chess-scan')
async function main() {
const result = await imageToFen('board.png')
console.log(result.fen)
}
main()Extract Board Image
const { getBoardImg } = require('chess-scan')
async function main() {
const board = await getBoardImg('board.png')
console.log(board.width)
console.log(board.height)
}Extract Individual Squares
const { getSquareImgs } = require('chess-scan')
async function main() {
const squares = await getSquareImgs('board.png')
console.log(squares.length) // 64
}API
imageToFen(input)
Detects the board, recognizes all pieces, and returns the resulting FEN.
imageToFen(input: ImageInput): Promise<{
fen: string
confusion: [{
classId: number
confidence: number
},...]
}>getBoardImg(input)
Returns the detected chessboard as a normalized image.
getBoardImg(input: ImageInput): Promise<Buffer>getSquareImgs(input)
Returns all 64 board squares.
getSquareImgs(input: ImageInput): Promise<Buffer[]>Supported Inputs
The library accepts:
- Local file paths
- Image URLs
- Buffers
- Raw image data
TypeScript
Type definitions are included automatically.
import { imageToFen } from 'chess-scan'Pipeline
The library uses a machine-learning pipeline consisting of:
- Board detection
- Board normalization
- Square extraction
- Piece classification
- FEN generation
Performance depends on image quality, board visibility, and piece style.
License
MIT
