topical media & game development
mashup-flickr-10-badge.pl / pl
#!/usr/bin/perl
use FileHandle;
use Image::Magick;
use Flickr::API;
use XML::Parser::Lite::Tree::XPath;
use Getopt::Std;
getopt('d');
apisecret = 'YOUR-API-SECRET';
filename = 'badge'; # The output file name
dir = './';
opt_d if (defined(dir !~ /\/dir .= '/';
}
apikey,
'secret' => photosCount = 8;
@recentPoolPhotos = ();
#recentPoolPhotos == -1)
{
my flickr->execute_method('flickr.groups.pools.getPhotos',
{
'group_id' => photosCount,
'page' => 1,
});
my response->{'tree'});
@recentPoolPhotos = i = 0; photosCount; p = i];
push(@photos, response = groupNSID,
});
my response->{'tree'});
my @groups = groups[0]->{'attributes'}->{'url'};
}
sub getGroupIconURL
{
my response = groupNSID,
});
my response->{'tree'});
my @groups = #groups >= 0)
{
my groups[0]->{'attributes'}->{'iconserver'};
url;
}
sub getPhotoPage
{
my (url = 'http://www.flickr.com/photos/' . p->{'attributes'}->{'id'} . '/';
}
sub getRecentPoolPhotosAsImage
{
if (!defined(photosCount);
p (@photos)
{
my p->{'attributes'}->{'server'} . '/'
. p->{'attributes'}->{'secret'}
. '_s.jpg';
img);
}
}
return mapRef) = @_;
my filename.jpg\" width=\"225\" height=\"225\"
usemap=\"#s .= "<map name=\"item (@topleftx = $$item[0];
my bottomrightx = bottomrighty = url = $$item[4];
topleftx,bottomrightx,url\" />\n";
}
fh = new FileHandle "> fh)
{
print s;
image, x, width, mapRef, image->Composite(image => x, y => mapRef, y, height, mapRef, y, h, x, w, url);
push (@photos = getRecentPoolPhotosAsImage();
my @map = ();
my groupIconImage = Image::Magick->new;
image = Image::Magick->new;
image->ReadImage('xc:white');
addImage(photos->[0], 0, 0, 75, 75, photoDetails[0]));
addImage(photos->[1], 75, 0, 75, 75, photoDetails[1]));
addImage(photos->[2], 150, 0, 75, 75, photoDetails[2]));
addImage(photos->[3], 0, 75, 75, 75, photoDetails[3]));
addImage(photos->[4], 150, 75, 75, 75, photoDetails[4]));
addImage(photos->[5], 0, 150, 75, 75, photoDetails[5]));
addImage(photos->[6], 75, 150, 75, 75, photoDetails[6]));
addImage(photos->[7], 150, 150, 75, 75, photoDetails[7]));
addImage(groupIconImage->[0], 88, 88, 48, 48, image->Write(filename => filename . '.jpg', quality => 85);
undef mapRef);
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.