#!/usr/bin/perl -w use strict; use Tk; use Tk::JPEG; use Tk::Photo; use GD; use MIME::Base64; my $mw = tkinit(-title => 'Tests with Images'); main_gui($mw); MainLoop; ### Subroutines ### sub main_gui { $mw = shift; my $frame_left = $mw->Frame(-background => 'red', -width => 130, -height => 500); my $frame_right = $mw->Frame(-background => 'blue', -width => 170, -height => 500); my $frame_center = $mw->Frame(-background => 'yellow', -width => 500, -height => 400); my $frame_bottom = $mw->Frame(-background => 'green', -width => 500, -height => 100); $frame_left ->grid(-row => 0, -column => 0, -rowspan => 2); $frame_right ->grid(-row => 0, -column => 2, -rowspan => 2); $frame_center->grid(-row => 0, -column => 1); $frame_bottom->grid(-row => 1, -column => 1); my $image_data = newFromJpeg GD::Image('DSCF0334.JPG') || die $!; $image_data->flipVertical(); $image_data = encode_base64( $image_data->jpeg(100) ); my $image = $frame_center->Photo(-data => $image_data ); my $small_foto = $mw->Photo; $small_foto->copy($image, -subsample => 5,5); $image->blank(); $frame_center->Label( -image => $small_foto )->pack(); }