I have managed to write code that will step thru and display the jpgs, but I can't quite figure out how to scale them. I think I would use the copy method along with a shrink or zoom argument. But I'm not quite proficient enough with Tk to know how to read in one image, copy it to another resized, then display the second one. Can someone help me out? Existing code is below.
TIA.....Steve
#!/usr/bin/perl -w use strict; use Tk; use Tk::JPEG; my $c; my $dir = "c:/temp"; my @fl = ("01.jpg","05.jpg"); my $main = new MainWindow; nextp(); my $nxt = $main->Button('-text' => "Next", '-command' => \&nextp)->pac +k(); $main->Button(-text => 'exit', -command => sub{destroy $main} )->pack(-anchor => 'e'); MainLoop; sub loadpic { my $filename = shift; my $size; my $orientation; $main -> Photo('img', -file => $filename); my ($h,$w) = ($main->height, $main->width); # # how to scale the pic? # $c = $main->Label('-image' => 'img')->pack; return; } sub nextp { my $f = shift(@fl); loadpic("$dir/$f"); return; }
In reply to Tk sizing a pic to fit a window by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |