NAME
sgfThumbnailer - create images of sgf files suitable for use as thumbnails
SYNOPSIS
use sgfThumbnailer;
my $writer = new sgfThumbnailer();
$writer->makeimage('in.sgf', 'out.png');
DESCRIPTION
sgfThumbnailer creates a quick png image from an sgf file.
Included is a script to set up automatic thumbnail generation for linux users within the Nautilus file manager.
Move numbers are not supported, neither are variations.
You can choose which graphics library to use (GD or Image::Magick), whichever is available.
Games that are classed as tsumego (ie problems) will not display moves, only initial setup.
METHODS
new
my $writer = new sgfThumbnailer();
Calling new with no parameter causes sgfThumbnailer to try to load GD, and then Image::Magick if that fails.
my $writer = new sgfThumbnailer($lib);
Try to load graphics library $lib ('GD' or 'Image::Magick')
OPTIONS
setlib
Set the graphics library to either 'Image::Magick' or 'GD'.
$writer->setlib('GD');
GD is faster, but Image::Magick produces better looking images.
If you have suitable fonts (see below), GD can produce thumbnails of the same quality.
Returns the library in use.
font
Use a font to draw the stones. This is useful if your version of GD can't antialias circles, but can antialias text.
To use one of three preconfigured fonts (Alamanc MT, GoType New and Gobd), use font(path, name), where name is 'almanac', 'gotype' or 'gobd'.
If you want to use a different font, use font(path, name, hashref). Name is any identifying string.
The following hash reference keys are used
front (the outline character code, which may look like a white stone)
back (the fill character code, which may look like a black stone)
imfactor (Image::Magick scale factor)
gdfactor (GD scale factor)
xnudge (+ve numbers nudge right)
ynudge (+ve numbers nudge down)
under (second background character code, which can be used to make three coloured stones)
black (instead of front, back and under, this key can be used to set the character to represent a black move)
white (to represent a white move. black and white will be coloured according to bunder and wunder)
eg $writer->font('/path/to/wingding.ttf', 'wd', {front => 123, back => 124, imfactor => 27, gdfactor => 20, xnudge => -1, ynudge => -1});
Characters are drawn in the order under, back, front.
The default settings for a non-preconfigured font are -
{front => undef, back => undef, under => undef, imfactor => 1, gdfactor => 1, xnudge => 0, ynudge => 0}
Once black and white have been defined, they will be used in preference to front, back, under until undefined.
Returns an array of path, name, hash reference.
amendfont
$writer->amendfont($fontname, $hashref);
Amend the the details of the font $fontname according to the contents of $hashref;
eg $writer->amendfont('wd', {front => 122});
Returns a hash reference of the current font settings.
usefont
$writer->usefont($fontname);
Declare that you want to draw images using $fontname. If $fontname is undefined, fonts will not be used to draw the image.
If usefont is not called, the font mentioned in the last call to font() or amendfont() will be used.
eg $writer->usefont('gotype');
Returns the name of the font being used.
block
$writer->block($fontpath, {character => $character, factor => 44, xnudge => $xnudge, ynudge => $ynudge});
Use a different font and character to draw a background $character when using the black and white font keys.
Coloured according to bunder and wunder - see colours heading.
When character is undefined, a square will be drawn.
eg $writer->block('/usr/share/fonts/truetype/msttcorefonts/Arial.ttf', {character => 0x25a0, factor => 44, xnudge => -3, ynudge => 0});
('0x25a0' represents a square that can be coloured)
Returns a hashref of the current block settings.
colours
$writer->colours({element => colour});
Associates a board element with a colour. The element codes used are
bs (black stone)
bso (black stone outline)
ws (white stone)
wso (white stone outline)
line (board lines)
tsumego (tsumego games)
tsumegooff (the outer edge of the image)
nomove (tsumego with no answer!)
nomoveoff (the outer edge of the image)
game (ordinary games)
gameoff (the outer edge of the image)
bunder (black under character)
wunder (white under character)
Default colors are as though
$writer->colours({tsumego => 'cfd5e5', nomove => 'ff739b', game => 'c9c5a4', line => '000000', bs => '000000', ws => 'ffffff', bso => '000000', wso => '000000', bunder => 'ffffff', wunder => 'ffffff', tsumegooff => 'c7f4f3', nomoveoff => 'ffffff', gameoff => 'f39d2a', offboard => 'ffffff'});
Setting the colour to 'random' will cause a random colour to be used.
eg $writer->colours({tsumego => 'ffff00', bs => 'random'})
Returns a hash reference of the colours set
extendboard
$writer->extendboard($value);
If $value is true, the image be extended to resemble a real board.
If its false (default), the image will not extend beyond a stone on the edge.
Returns the current value.
extension
$writer->extension($value);
Sets how far the board extends past a stone on the edge, in fractions of a stone.
If extendboard is false, this value has no effect.
The default is 0.12
Returns the current value.
maxmoves
$writer->maxmoves($integer);
Set the maximum number of moves (not including setup) to illustrate. Default is 25.
Returns the current value.
stonesize
$writer->stonesize($number);
Set the relative size of stones. Default is 0.92, to create a small gap between the stones.
Has no effect when using a font (use gdfactor and imfactor instead.)
Returns the current value.
outline
$writer->outline($value);
If $value is true (default), stones will be drawn with an outline.
If its false, stones will not be drawn with an outline.
If using fonts, you could also use $writer->font('/path/to/somefont.ttf', 'myfont', {front => undef});
Returns the current value.
realboard
$writer->realboard($value);
If $value is true, captured stones will not be drawn.
If its false (default), captured stones will be drawn.
Returns the current value.
scale
$writer->scale($integer);
Set or get scale. Default is 128.
Images will have a maximum height and width of $value.
Returns the current value.
checkselfcapture
$writer->checkselfcapture($value);
If $value is true, and realboard is true, a check will be made to see if a self capture has happened.
If its false (default), no such check will be made, (which is a little faster.)
Returns the current value.