summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/bin/tkjpeg
blob: b2b5619726c41c29b0a8b0f99c9ad881c2a0a0fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/local/bin/perl -w
use strict;
use Tk;
use Tk::JPEG;
use Getopt::Std;
eval { require Tk::PNG; };

my $mw  = MainWindow->new();
print "vis=",$mw->visual," d=",$mw->depth,"\n";
my ($vis) = grep(!/\b8\b/,grep(/truecolor/,$mw->visualsavailable));
my @args = ();
if ($vis)
 {
  # print $vis,"\n";
  $mw->destroy;
  $mw = MainWindow->new(-visual => $vis);
 }
else
 {
  @args = (-palette => '4/4/4');
 }
# print "vis=",$mw->visual," d=",$mw->depth,' "',join('" "',$mw->visualsavailable),"\"\n";
my %opt;
getopts('f:',\%opt);
if ($opt{'f'})
 {
  push(@args,'-format' => $opt{'f'});
 }
unless (@ARGV)
 {
  warn "usage $0 [-f format] <imagefile>\n";
  exit 1;
 }
my $file = shift;
my $image = $mw->Photo(-file => $file, @args);
#print join(' ',$image->formats),"\n";
print "w=",$image->width," h=",$image->height,"\n";
$mw->Label(-image => $image)->pack(-expand => 1, -fill => 'both');
$mw->Button(-text => 'Quit', -command => [destroy => $mw])->pack;
MainLoop;

__END__

=head1 NAME

tkjpeg - simple JPEG viewer using perl/Tk

=head1 SYNOPSIS

  tkjpeg imagefile.jpg

=head1 DESCRIPTION

Very simplistic image viewer that loads JPEG image, (well actually
anything for which Photo has a handler) and puts it into a
Label for display.

It tries to find a fullcolour visual to use if display is deeper than
8-bit. (On 8-bit it uses a 4/4/4 palette.)

=head1 AUTHOR

Nick Ing-Simmons <nick@ing-simmons.net>

=cut