#!/usr/bin/perl -w use REST::Client; use JSON; use Data::Dumper; use LWP::Simple; use Tk; use Tk::JPEG; use constant DELAY => 1000; my $index = 0; my $client = REST::Client->new(); $client->GET('http://www.panoramio.com/map/get_panoramas.php?order=popularity&set=public&from=0&to=100&minx='.$ARGV[0].'&miny='.$ARGV[1].'&maxx='.$ARGV[2].'&maxy='.$ARGV[3].'&size=original'); my $aoh = decode_json $client->responseContent(); my @urls; #print Dumper $aoh; foreach my $pic(@{$aoh->{photos}}) { print "$pic->{photo_file_url}\n"; print "$pic->{photo_title}\n"; print "$pic->{latitude} $pic->{longitude} ($pic->{width}x$pic->{height})\n\n"; push @urls,$pic->{photo_file_url}; } ################################################################################ my $mw = new MainWindow(-background=>'black'); #$mw->FullScreen(1); #$mw->geometry($mw->screenwidth . 'x' . $mw->screenheight . '+0+0'); my $sx =$mw->screenwidth; my $sy =$mw->screenheight; my $image = $mw->Photo(); #qw/-width 800 -height 600/ $mw->bind('all' => '' => sub {exit;}); $mw->Button(-image => $image,-background => 'black')->pack(-side => "top", -fill=> "both"); $mw->after(DELAY, \&next_image); MainLoop; ################################################################################ sub next_image { $image->blank(); my $file = &download(${$aoh->{photos}}[$index]{photo_file_url}); my $title = ${$aoh->{photos}}[$index]{photo_title}; my $px = ${$aoh->{photos}}[$index]{width}; my $py = ${$aoh->{photos}}[$index]{height}; print "NEXTIMG: $px x $py\n"; if (eval {$image->read($file,-shrink); 1}) { if ($px >= $sx and $py >= $sy ) { print "SUBSSAMPLING: $px/$sx , $py/$sy: ",$px/$sx,' ',$py/$sy,"\n"; $image->copy($image, -subsample => ( int ($px/$sx),int ($py/$sy) )); #, $py/$sy } else { #$image->copy($image, -zoom => ( 2,2)); } $mw->configure(-title => $title,-width=>$px, -height=> $py); #,-width=>$x, -height=> $y $mw->after(DELAY, \&next_image) if (++$index <= $#{$aoh->{photos}}); } else { $mw->after(0, \&next_image) if (++$index <= $#{$aoh->{photos}}); } } sub download{ my $url=shift; print "RECEIVING: $url\n"; mirror ($url, 'file.jpg'); return 'file.jpg' }