if (formatPtr == NULL) { if ((formatObj != NULL) && !matched) { Tcl_AppendResult(interp, "image format \"", formatString, "\" is not supported", (char *) NULL); } else { Tcl_AppendResult(interp, "couldn't recognize image data", (char *) NULL); } return TCL_ERROR; } #### use strict; use warnings; use Tk; use Tk::JPEG; use GD; use MIME::Base64; # <---------- 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(); print "screen size $ww x $wh and image is $iw x $ih\n"; my $imtk; if ($iw > $ww or $ih > $wh) { my $wratio = $ww / $iw; my $ratio = $wh / $ih; $ratio = $wratio if $wratio < $ratio; # temporary GD image needed (dunno why) my $fullscreen = GD::Image->new($ww,$wh); # <--------------- $fullscreen->copyResampled( $imgd , # source image 0, # X center of the destination image 0, # Y center of the destination image 0, # X specify the upper left corner of a rectangle in the source image 0, # Y specify the upper left corner of a rectangle in the source image $ww, # final width $wh, # final height $iw, # source width to copy $ih, # source height to copy ); $imtk = $mw->Photo(-data => MIME::Base64::encode( $fullscreen->jpeg()) ); # <--------------- } else { $imtk = $mw->Photo(-file => $file, -format => 'jpeg'); } $mw->Label(-image => $imtk)->pack(-expand => 1, -fill => 'both'); $mw->update; MainLoop;