#!/usr/bin/perl -w
# heidi @ animae.org 12/16/2005, translation from pix2_html.sh
# originally written by Robin.Rowe@MovieEditor.com 5/3/2004
# License OSI MIT
use strict;
my $description = 'Photographer: Per Inge Oestmoen, Norway, Copyright 2008';
my $quality = 95;
my $is_heavy = 1;
my $is_overwrite = 0;
my $is_burn_in = 0;
my $dir = "thumbs";
my $html = 'index.html';
my $convert = '"C:\Program Files\GraphicsMagick-1.2.5-Q16\gm.exe" convert';
my $size = '320x320'; #'480x480';
my $degrees = '90';
my $gamma = '2.0';
my $date = '2007.10.17';
my $caption = "Photo by Robin Rowe";
#my $caption = "Copyright 2007 $description";
my $color = 'white';
my $bordercolor = 'black';
my $font = 'Dark-Courier';
my $pointsize = '10';
my $text_x = 8;
my $text_y = 480-5;
my $unzip = '"c:\program files\7-zip\7z.exe" e';
sub MkDir()
{ if(!(-d $dir))
{ mkdir $dir or die "Could not make directory $dir: $!";
} }
sub IsImageFileType($)
{ my $file=lc(shift);
if ( -1==index($file,'.tif')
and -1==index($file,'.tiff')
and -1==index($file,'.jpg')
and -1==index($file,'.jpeg')
and -1==index($file,'.png')
and -1==index($file,'.doc') )
{ return 0;
}
return 1;
}
sub IsDocFileType($)
{ my $file=lc(shift);
# print("doc? $file\n");
if (-1!=index($file,'.pdf'))
{ return 1;
}
if (-1!=index($file,'.txt'))
{ return 1;
}
if (-1!=index($file,'.doc'))
{# print("doc = $file\n");
return 1;
}
return 0;
}
sub RenameFiles()
{ foreach my $file (glob '*')
{ #if(UnknownFileType($file))
#{ next;
#}
my $filename=$file;
$filename =~ s/ /_/g;
$filename = lc($filename);
if($filename ne $file)
{ print("rename $file\n");
rename($file,$filename);
} } }
sub UnzipFiles()
{ foreach my $file (glob '*.zip')
{ #if(UnknownFileType($file))
#{ next;
#}
my $cmd="$unzip $file";
print("$cmd\n");
system $cmd;
} }
sub CreateThumbnails()
{ open(my $OUT,'>',$html) or die "Could not open $html: $!";
my $footer = '';
print($OUT <
ZZZ
foreach my $file (glob '*')
{ if(IsDocFileType($file))
{ print("linking $file\n");
$footer.="$description
$in_file