#!perl # cf. http://www.james.rcpt.to/programs/mysql/blob/ use strict; use warnings; use DBI; use Tk; use Tk::PNG; use Tk::JPEG; use MIME::Base64 qw(encode_base64); # Which database and which file from the filesystem? my $dbname = 'test'; my $username = 'test'; my $password = 'test'; # Make a connection to your database my $dbh = DBI->connect("dbi:mysql:database=$dbname", $username, $password) or die "Cannot open db"; my $sql = "SELECT photo FROM photos LIMIT 1"; my $sth = $dbh->prepare($sql) or die('Error prep: ' . $dbh->errstr()); my $numrows = $sth->execute() or die('Error exec: ' . $dbh->errstr()); my $ref = $sth->fetchrow_hashref; my $newdata = $$ref{'photo'}; # siehe: http://www.perl-community.de/bat/poard/thread/5210 $newdata = encode_base64($newdata); my $mw = Tk::MainWindow->new(); my $bild = $mw->Photo( -data => $newdata ); my $label = $mw->Label(-image => $bild, -background => '#ffffff')->pack(); $mw->MainLoop();