ブログの写真からカメラの機種を調べるスクリプト
先日、GPSデータの削除に使ったImage::ExifToolですが、カメラの機種情報を取得することもできます。
ということで、ブログの写真からカメラの機種を調べるスクリプトを作りました。
#!/usr/bin/perl # file: getCameramodel.pl # usage: getCameramodel.pl [URL] use strict; use warnings; use URI; use LWP::Simple; use Web::Scraper; use Image::ExifTool; sub doScrape { my $blog = shift; my @images = (); my $scraper = scraper { process 'img', 'image[]' => '@src'; }; my $result = $scraper->scrape(URI->new($blog)); for my $img (@{$result->{'image'}}) { push(@images, $img) if ($img =~ m/\.jpe?g$/); } return \@images; } sub getImgInfo { my $images = shift; my $exifTool = new Image::ExifTool; for my $img (@$images) { my $photo = get($img); my $photoinfo = $exifTool->ImageInfo(\$photo); my $make = $photoinfo->{'Make'}; my $model = $photoinfo->{'Model'}; if (defined $make && defined $model) { return my $result = [$make, $model]; } } return my $result = "Can't detected Camera Model."; } my $url = shift || die "usage: getCameramodel.pl [URL]\n"; my $scrapeRes = &doScrape($url); my $imageinfo = &getImgInfo($scrapeRes); if (ref $imageinfo) { print "Manufacturer: $imageinfo->[0]\n"; print "Model: $imageinfo->[1]\n"; } else { print "$imageinfo\n"; } __END__
著名人のブログを調べたら面白いかなぁと書いてみましたが、宮川さんがすでに作っていた。
ブログの画像からカメラ携帯の機種を調べてみる: blog.bulknews.net
What cameraphone are they using?