use strict; use warnings; use Tk; use Tk::JPEG; use GD; my $file = $ARGV[0]; my $mw = MainWindow->new(); my $ww = $mw->screenwidth; my $wh = $mw->screenheight; my $imgd = GD::Image->newFromJpeg($file); my ($iw, $ih) = $imgd->getBounds(); my $imtk; if ($iw > $ww or $ih > $wh) { my $wratio = $ww / $iw; my $ratio = $wh / $ih; $ratio = $wratio if $wratio < $ratio; $imgd->copyResampled($imgd, 0, 0, 0, 0, $iw * $ratio, $ih * $ratio, $iw, $ih); $imtk = $mw->Photo(-data => $imgd->jpeg(), -format => 'jpeg'); } else { $imtk = $mw->Photo(-file => $file, -format => 'jpeg'); } $mw->Label(-image => $imtk)->pack(-expand => 1, -fill => 'both'); $mw->update; MainLoop;