#!/usr/bin/perl
#
#########################################################################
#
# Image Display System Preview Maker 				6/7/2001     
# 			John Moose			moosejc@muohio.edu
#
#########################################################################
# Use this script to pre-generate your site's preview (thumbnail) images 
#
# Please see the files "LICENSE," "README," "INSTALL," and "UPGRADE" for 
# more information.
#
#########################################################################
# 
# Copyright (C) 1999-2001  John Moose
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to:
# 
#	Free Software Foundation, Inc.
#	59 Temple Place - Suite 330
#	Boston, MA  02111-1307, USA.
# 
#########################################################################

use File::Basename;
use File::Find;
use File::Path;
use Image::Magick;
use Image::Info qw(image_info);
use strict qw(vars);
use lib qw(./);
use idsShared;

readPreferences('./ids.conf');

$scaledOverlay = Image::Magick->new;
$scaledOverlay->Read("site-images/previewicon.png"); # read in the "scaled" icon to overlay on scaled images

my($logDir) = "./logs";
my($file, $newLogEntry);

print "Locating image files...\n";
find({ wanted => \&findImagesToPreview, follow => 1 }, 'albums/');  #follows symbolic links 

print "Beginning preview generation...\n";

foreach $file (@FilesToPreview) {
	createDisplayImage($previewMaxDimension, '', $file);
	print "Created preview for \"$file\"\n";
}

print "Preview generation complete.\n";
print "Locating albums...\n";
find({ wanted => \&findAlbumsToPreview, follow => 1 }, 'albums/');  #follows symbolic links

my $album;
foreach $album (@AlbumsToPreview) {
	next if ($album eq 'albums');
	foreach my $availableTheme (@availableThemes) {
		$theme = $availableTheme;
		generateAlbumPreview("$album");
		print "Created album icon for \"$album\" - \"$theme\"\n";
	}
}
print "Album icon generation complete.\n";

$newLogEntry = "Preview Maker: Preview generation complete.";
appendLogFile("$logDir/admin.txt", $newLogEntry);


