This tool was first presented in slide view of a folder of JPEG's. Thanks zentara for his input in that thread. Over time, I improved it, now it is much more user friendly and powerful.

Usage:

  1. The file pattern was hard coded in the previous version, now it allows you to key in, after key in, just click load button. Once load completed, the first pic in the list will be displayed.
  2. You can now manulaly move to next or previous picture by clicking ">" or "<".
  3. You can now manulaly jump forward and backward by clicking ">>" or "<<". You can key in the distance in the entry box between < and >.
  4. You still can let it automatically move to the next picture, just trun on automode. You can also turn it off, by deselecting the checkbox.
  5. With automode, now you can set the speed by enter the delay in between.
use Tk; use Tk::JPEG; use File::Glob ':glob'; my $automode = 0; my @jpgs = bsd_glob("9???.jpg"); my $index = -1; my $mw = MainWindow->new(title => "JPEG"); $mw->geometry("800x800"); my $f = $mw->Frame()->pack(-fill => "both"); $f->Button(-text => "Load", -command => \&load)->pack(-side => "left", + -fill => "both"); my $pattern = $f->Entry(-width => 10, -text => '*')->pack(-side => "le +ft", -fill => "both"); my $step; $f->Button(-text => "<<", -command => sub {prev_image($step->get())})- +>pack(-side => "left", -fill => "both"); $f->Button(-text => "<", -command => sub {prev_image(0)})->pack(-side +=> "left", -fill => "both"); $step = $f->Entry(-width => 3, -text => 10)->pack(-side => "left", -fi +ll => "both"); $f->Button(-text => ">", -command => sub {next_image(0)})->pack(-side +=> "left", -fill => "both"); $f->Button(-text => ">>", -command => sub {next_image($step->get())})- +>pack(-side => "left", -fill => "both"); $f->Checkbutton(-text => "Auto Mode", -onvalue => 1, -offvalue => 0, - +variable => \$automode, -command => sub {if ($automode) {print $autom +ode; next_image()}})->pack(-side => "left", -fill => "both"); $f->Label(-text => "Delay")->pack(-side => "left", -fill => "both"); my $delay = $f->Entry(-width => 4, -text => 1000)->pack(-side => "left +", -fill => "both"); $f->Label(-text => "milli-second(s)")->pack(-side => "left", -fill => +"both"); my $image = $mw->Photo(); next_image(0); my $button = $mw->Label(-image => $image)->pack(-side => "top", -fill +=> "both"); MainLoop; sub load { @jpgs = bsd_glob($pattern->get()); $index = -1; next_image(0); } sub next_image { $index += shift; $index = $#jpgs if ($index > $#jpgs); while ((($index + 1)<= $#jpgs) && !eval {$image->read($jpgs[++ $in +dex], -shrink); 1}) { } if ($automode) { $mw->after($delay->get(), \&next_image) if (($index + 1) <= $# +jpgs); } $mw->configure(-title => $jpgs[$index]); $std = undef; } sub prev_image { $index -= shift; $index = 0 if ($index < 0); $automode = 0; while ((($index - 1) >= 0) && !eval {$image->read($jpgs[-- $index] +, -shrink); 1}) { } if ($index >= 0) { $mw->configure(-title => $jpgs[$index]); $std = undef; } }

Replies are listed 'Best First'.
Re: Slide view of pictures
by zentara (Cardinal) on Nov 17, 2004 at 12:56 UTC
    I get an error with your line
    my @jpgs = bsd_glob("9???.jpg");
    It dosn't read any of my jpgs. It works if I change it to
    my @jpgs = bsd_glob("*.jpg");

    I'm not really a human, but I play one on earth. flash japh
Re: Slide view of pictures
by zentara (Cardinal) on Nov 17, 2004 at 13:04 UTC
    I have another suggestion. When you are in "automode" it only cycles thru once and stops. It would be nice if it had a checkbutton for loop mode, so it could run indefinitely.

    I'm not really a human, but I play one on earth. flash japh
Re: Slide view of pictures
by Discipulus (Canon) on Nov 17, 2004 at 10:40 UTC
    good mornong pg
    it fails to me at this line: $step = $f->Entry(-width => 3, -text => 10)->pack(-side => "left", -fill => "both"); with this error: Not a reference 10 at C:/Perl/site/lib/Tk/Widget.pm line 196. at jpegslide2.pl line 34 the related line of the module is $obj->configure(%args) if (%args); thanks lorenzo