#!/usr/bin/perl -w use strict; use GD; use Tk; use Tk::JPEG; use MIME::Base64; # Create the main window my $main = MainWindow->new(); # Open a JPG image in GD my $im = GD::Image->new('feather.jpg'); # Create an empty image with the desired dimensions my $resizedim = new GD::Image(120,120); # Copy everything from $im and resize it into $resizedim $resizedim->copyResized($im,0,0,0,0,120,120,$im->getBounds()); # encode the jpeg-output of the $resizedim my $img = encode_base64($resizedim->jpeg()); # create a Photo object with the data and display it within a label my $image = $main->Photo("button", -data => $img, -format => 'jpeg'); my $label= $main->Label(-image => "button"); $label->grid(-in => $main); MainLoop;