Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 53 lines (45 sloc) 1.82 KB
#!/usr/bin/perl -w
# Karl Palsson, 2012.
# Based on "pubmisc"
# Given a file, work out what "miscstream" file list it should be appended to,
# and add it to that file. (Ensuring no duplicates)
# Afterwards, run make_album with that modified list file.
use Image::ExifTool;
use File::Spec;
# user config....
my $metadata_root = "~/photos";
#my $metadata_root = ".";
my $gallery_base_path = "/home/tweak.net.au/www/site/pics2";
#my $gallery_base_path = ".";
my $gallery_monthly_name = "miscstream";
my $verbose = 1;
my $et = new Image::ExifTool;
# 2007/July/07 (not for human consumption)
$et->Options(DateFormat => "%Y/%B/%m");
my $outdir;
foreach my $file (@ARGV) {
unless (-e $file) {
printf STDERR "$file doesn't exist, skipping\n";
next;
}
my $info = $et->ImageInfo($file);
print "error = " . $$info{'Error'} . "\n" if defined ($$info{'Error'});
my $dateinfo = $$info{"DateTimeOriginal"} || $$info{"FileModifyDate"} || die "No date in the file: $file!";
my ($year, $month_name, $month) = split(/\//, $dateinfo);
my @metadata_files = glob("$metadata_root/$year/miscstream.$year$month.list");
die "urk" unless (@metadata_files == 1);
print("using metadata file: $metadata_files[0]\n");
open(ML, "+>>", $metadata_files[0]) or die $!;
seek ML, 0, 0;
my @entries = <ML>;
if (grep(/$file/, @entries) > 0) {
print("$metadata_files[0] already contains an entry for $file\n");
} else {
print ML "$file\n";
}
close(ML);
$outdir = File::Spec->catfile($gallery_base_path, $year, $month_name, $gallery_monthly_name);
printf "publishing $file to $outdir\n" if $verbose;
my $title = "Miscellaneous pictures from $month_name";
print `perl /home/karlp/bin/make_album --outdir $outdir --rows=4 --file_list $metadata_files[0] -title "$title" --reverse;`;
}