#!/usr/bin/perl
use Gimp ":auto";
use Gimp::Fu;
# P2S2 - Perl Powered Slide Show
# Creates thumbnails of entire directories recursively.
# Generates a generic HTML "Gallery" of your images,
# plus a javascript-powered slide show, both viewable in any standard web browser.
# CHANGELOG
#=================================
# VERSION 0.5
# - added TIFF -> JPG icon support
# VERSION 0.4 (first release)
# TO DO
#=================================
# kill -> creates patterns even if not using gallery or slideshow.
# regular frames - as opposed to frame-hugs-image - maybe someday :-)
# vlink/alink colors
# text size - CSS classes
# front page splash pic option
# JPEG saving variables: put in global prefs section
# GIF support
# GLOBAL PREFS
#=================================
# Enables/disables navigation bar wallpaper. Defaults to user-defined bgcolor if unset.
$enable_navbar_wallpaper = 1; # 0 = inhibit , 1 = enable
# Stops pictures smaller than the resize length from being "res'd up" for icons and leaves them their current size
$res_up_inhibit = 1; # 1 = inhibit, 0 = enable
# starting width of gallery navigation bar. can be resized by user in browser
$navbar_width = 200;
#spacing between each picture frame
$maincellspacing = 20; # between each matt
$maincellpadding = 0; # around each matt
# slideshow box and text colors in #hexdec (HTML) format
$ss_box_color = '#000000';
$ss_box_text_color = '#FFFFFF';
#Names of HTML pages. Probably best to leave these as default
$index_page = 'index.html';
$nav_page = 'nav.html';
$main_page = 'main.html';
$slideshow_page = 'slideshow.html';
$scaled_pix_target = "scaled_pix_target.html";
# Prefixes. These can be left as default unless you want to change your naming conventions
$icon_prefix = 'icon-';
$pattern_prefix = 'ptrn-';
# Check marks. For shell verbose-mode feedback. Very little reason to change these
$pos_check = 'X ';
$neg_check = '- ';
#Files to exclude. Files are NOT full path names:
@excludefiles = ('.' , '..', '.xvpics');
# Gallery image hight when clicked on "scaled" link
$scaled_gallery_pic_height = '600';
#=================================
# / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
# NO MORE EDITING BEYOND THIS POINT IS NEEDED
# / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
#//////////////////////////////////////////////////////////////////////////////////
sub Begin {
(
$starting_dir,
$slideshow_name,
$mainpage_opt_text,
$create_gallery,
$gallery_cols,
$mattwidth,
$outer_matt_bevel,
$inner_matt_bevel,
$length,
$shrink_mode,
$create_ss,
$ss_rotate_delay,
$ss_max_height,
$use_wallpaper,
$wallpaper,
$use_mattpaper,
$mattpaper,
$bgcolor,
$mattcolor,
$textcolor,
$recursive,
$reiconify,
$verbose,
) = @_;
#master list contains: KEY = DIR, VALUE = list of files in that dir.
%masterlist = () if $create_gallery || $create_ss; #global
@masterlist_insertion_order = () if $create_gallery || $create_ss; #global
#convert rgb triples to hex triples
$bgcolor = RGBtoHEXTriples(@{$bgcolor});
$mattcolor = RGBtoHEXTriples(@{$mattcolor});
$textcolor = RGBtoHEXTriples(@{$textcolor});
#make background images for bg's and matts and grab the revamped names
($mattpaper, $wallpaper) = MakePatternFiles($mattpaper, $wallpaper);
#Start the Directory Tracker.
#Push and pop to modify the current branch of scanning.
$starting_dir =~ s/\/$//; #strip trailing slash if any
@DirTracker = ("$starting_dir"); #global variable
# starting deepness level
$startdeep = 0; #global
while ($starting_dir =~ /\//g) {$startdeep++;}
#begin reading dirs
ReadDir();
#start Gallery if needed
StartGallery() if $create_gallery;
#start Slideshow if needed
StartSS() if $create_ss;
print "[ FINISHED ]\n" if $verbose;
return();
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub ShrinkJPG {
# scales a JPG file
# Takes: Full path to file,
# Returns: --
my ($file) = @_;
#prepend icon prefix to name
my @dirs = split (/\//, $file);
$dirs[$#dirs] = $icon_prefix . "$dirs[$#dirs]";
my $newfile = join ("/", @dirs);
#load image and attributes
my $img = file_jpeg_load($file, 0) || die "could not open $file";
my $h = gimp_image_height($img);
my $w = gimp_image_width($img);
my $ratio;
#get ratio
if ( ($shrink_mode eq 'height') or ($h >= $w) ) {
$ratio = $length / $h; #/
}
elsif ( ($shrink_mode eq 'width') or ($h < $w) ) {
$ratio = $length / $w; #/
}
# unless the thumbnail is to be bigger than the pic itself
if ( ($res_up_inhibit ==1) && ($ratio >= 1) ) {$ratio = 1}
#shrink it
$h = int($h * $ratio);
$w = int($w * $ratio);
gimp_image_scale($img, $w, $h);
#get drawable
$drawable = gimp_image_active_drawable($img);
#save the image
file_jpeg_save(0, $drawable, $newfile, $newfile, 1.0, 0.1, 1, 1, "P2S2 Generated Icon ", 0, 1, 0, 0);
return();
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub ShrinkPNG {
# scales a JPG file
# Takes: Full path to file,
# Returns: --
my ($file) = @_;
#prepend icon prefix to name
my @dirs = split (/\//, $file);
$dirs[$#dirs] = $icon_prefix . "$dirs[$#dirs]";
my $newfile = join ("/", @dirs);
#load image and attributes
my $img = file_png_load($file, 0) || die "could not open $file";
my $h = gimp_image_height($img);
my $w = gimp_image_width($img);
my $ratio;
#get ratio
if ( ($shrink_mode eq 'height') or ($h >= $w) ) {
$ratio = $length / $h; #/
}
elsif ( ($shrink_mode eq 'width') or ($h < $w) ) {
$ratio = $length / $w; #/
}
# unless the thumbnail is to be bigger than the pic itself
if ( ($res_up_inhibit ==1) && ($ratio >= 1) ) {$ratio = 1}
#shrink it
$h = int($h * $ratio);
$w = int($w * $ratio);
gimp_image_scale($img, $w, $h);
#get drawable
$drawable = gimp_image_active_drawable($img);
#save the image
file_png_save(0, $drawable, $newfile, $newfile, 1.0, 0, 5, 0,0,0,0);
return();
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub ShrinkTIFF {
# scales a TIFF file
# NOTE: function will convert TIF image to JPG thumbnail for gallery viewing.
# Takes: Full path to file,
# Returns: --
my ($file) = @_;
#prepend icon prefix to name
my @dirs = split (/\//, $file);
$dirs[$#dirs] = $icon_prefix . "$dirs[$#dirs]";
my $newfile = join ("/", @dirs);
#load image and attributes
my $img = file_tiff_load($file, 0) || die "could not open $file";
my $h = gimp_image_height($img);
my $w = gimp_image_width($img);
my $ratio;
#get ratio
if ( ($shrink_mode eq 'height') or ($h >= $w) ) {
$ratio = $length / $h; #/
}
elsif ( ($shrink_mode eq 'width') or ($h < $w) ) {
$ratio = $length / $w; #/
}
# unless the thumbnail is to be bigger than the pic itself
if ( ($res_up_inhibit ==1) && ($ratio >= 1) ) {$ratio = 1}
#shrink it
$h = int($h * $ratio);
$w = int($w * $ratio);
gimp_image_scale($img, $w, $h);
#get drawable
$drawable = gimp_image_active_drawable($img);
#save the image
file_jpeg_save(0, $drawable, $newfile, $newfile, 1.0, 0.1, 1, 1, "P2S2 Generated Icon", 0, 1, 0, 0);
return();
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub ReadDir {
# Recursive engine for scanning dirs. Spits out input to shell
# Takes: --
# Returns: --
#mush DirTracker together for a good directory name:
my $thisdir = join ('/', @DirTracker);
push(@masterlist_insertion_order, "$thisdir") if $create_gallery || $create_ss;
$masterlist{"$thisdir"} if $create_gallery || $create_ss;
print "[ Now scanning $thisdir . . . ] \n" if $verbose;
# count levels deep past starting point (starting_dir)
my $deepness = 0;
while ($thisdir =~ /\//g) {$deepness++}
$deepness -= $startdeep;
#get the current dir's contents:
local(*CURRENT);
opendir(CURRENT, "$thisdir");
my @thisdirinfo = readdir CURRENT;
closedir CURRENT;
#decide what to do with what we find
foreach $i (@thisdirinfo) {
if( Exclude($i) ) {next} #skip if it matches an exclude file
elsif (-d "$thisdir/$i") {
if ($recursive) {
push (@DirTracker, $i); #put the dir to search next in the tracker
ReadDir($verbose, $recursive, $reiconify);
}
else {next}
}
elsif ($i =~ /^$icon_prefix/) {
print "$neg_check$thisdir/$i was skipped (already an icon) \n" if $verbose;
next;
}
elsif ($i =~ /^$pattern_prefix/) {
print "$neg_check$thisdir/$i was skipped (is a background pattern) \n" if $verbose;
next;
}
#if JPG file
elsif ( (-f $i) || ($i =~ /\.(jpg|JPG|jpeg|JPEG)$/) ) {
#check to see if it's already been iconified if reiconify is on
my $hasicon = 0;
unless($reiconify) {
foreach $item (@thisdirinfo) {
#get the simple file name
my @temp = split /\//, $i;
if ($item eq "$icon_prefix$temp[$#temp]") {
print "$neg_check$thisdir/$i already has an icon\n" if $verbose;
$hasicon = 1;
last;
}
}
}
if ($hasicon == 0) {
ShrinkJPG("$thisdir/$i");
print "$pos_check$thisdir/$i was iconified \n" if $verbose;
}
#post to masterlist
push(@{ $masterlist{$thisdir} }, "$thisdir/$i") if $create_gallery || $create_ss;
}
#if PNG file
elsif ( (-f $i) || ($i =~ /\.(png|PNG)$/) ) {
#check to see if it's already been iconified if reiconify is on
my $hasicon = 0;
unless($reiconify) {
foreach $item (@thisdirinfo) {
#get the simple file name
my @temp = split /\//, $i;
if ($item eq "$icon_prefix$temp[$#temp]") {
print "$neg_check$thisdir/$i already has an icon\n" if $verbose;
$hasicon = 1;
last;
}
}
}
if ($hasicon == 0) {
ShrinkPNG("$thisdir/$i");
print "$pos_check$thisdir/$i was iconified \n" if $verbose;
}
#post to masterlist
push(@{ $masterlist{$thisdir} }, "$thisdir/$i") if $create_gallery || $create_ss;
}
#if TIF file
elsif ( (-f $i) || ($i =~ /\.(tif|TIF|TIFF|tiff)$/) ) {
#check to see if it's already been iconified if reiconify is on
my $hasicon = 0;
unless($reiconify) {
foreach $item (@thisdirinfo) {
#get the simple file name
my @temp = split /\//, $i;
if ($item eq "$icon_prefix$temp[$#temp]") {
print "$neg_check$thisdir/$i already has an icon\n" if $verbose;
$hasicon = 1;
last;
}
}
}
if ($hasicon == 0) {
ShrinkTIFF("$thisdir/$i");
print "$pos_check$thisdir/$i was iconified \n" if $verbose;
}
#post to masterlist
push(@{ $masterlist{$thisdir} }, "$thisdir/$i") if $create_gallery || $create_ss;
}
else {
print "$neg_check$thisdir/$i was skipped (unusable file type)\n" if $verbose;
}
}
#Remove this directory from the tracker to go back up a level:
pop @DirTracker;
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
##################################################################################
#/////////////////// HTML GALLERY SECTION /////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub StartGallery {
# Begins writing the gallery section if selected
# Takes: --
# Returns -- (just builds the gallery)
print "[ Now generating HTML gallery . . . ]\n" if $verbose;
BuildIndex();
BuildNavbar();
BuildMainPage();
BuildPages();
BuildOpenPicturesInPage();
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub BuildOpenPicturesInPage {
# Writes the html page that gets linked to by Scaled" gallery pix.
# Takes the query string and scales the pic using javascript
# Takes: --
# Returns -- (just builds the gallery)
open(OUT, ">$starting_dir/$scaled_pix_target");
print OUT PrintHeader('');
print OUT <<"END";
END
print OUT PrintFooter();
close OUT;
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub BuildIndex {
# Builds the index frameset page
# Takes: --
# Returns: -- (saves an index page to disk)
open(OUT, ">$starting_dir/$index_page");
print OUT <<"END";
$slideshow_name
END
close OUT;
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#CONTAINS IMPORTANT DIR & LINK RENAMING CONVENTIONS
sub BuildNavbar {
# work with @masterlist_insertion_order
my $wallpaper_hook = "background=\"$wallpaper\"" if $use_wallpaper && $enable_navbar_wallpaper;
open (NAV, ">$starting_dir/$nav_page");
print NAV qq|Navigation Bar|;
print NAV qq|Back to front page
|; #/
foreach $dir (@masterlist_insertion_order) {
# skip if dir is empty
if ($masterlist{$dir} eq undef) {next;}
# count levels deep past starting point (starting_dir)
my $deepness = 0;
while ($dir =~ /\//g) {$deepness++}
$deepness -= $startdeep;
my $indent_num = $deepness * 5;
my $indent = ' 'x$indent_num;
my $dispdir = $dir;
my $dirlink = $dir;
# get a link title proper
$dispdir =~ s(^.*/) (); #/
$dispdir =~ s/_/ /g;
#modify the dir name for the link
$dirlink =~ s/^$starting_dir//;
$dirlink =~ s/\//-/;
if ($dirlink eq '') {$dirlink = '-';}
print NAV qq|$indent$dispdir
|; #/
}
print NAV '';
close NAV;
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub BuildPages {
# REFER TO BuildNavPage FOR NAMING CONVENTIONS FOR LINKS AND DIRS
# Builds the standard pages with pix
# Takes: --
# Returns: -- (saves pages to disk)
my $mattpaper_hook = "background=\"$mattpaper\"" if $use_mattpaper;
foreach $dir (@masterlist_insertion_order) { #foreach directory
my $dispdir = $dir;
my $dirlink = $dir;
# get a link title proper
$dispdir =~ s(^.*/) (); #/
$dispdir =~ s/_/ /g;
#modify the dir name for the link
$dirlink =~ s/^$starting_dir//;
$dirlink =~ s/\//-/;
if ($dirlink eq '') {$dirlink = '-';}
open(OUT, ">$starting_dir/$dirlink.html");
print OUT PrintHeader($dispdir);
my $colcounter = 0; # start at 0 because first column = 1 and we ++ first thing
my $numpix = scalar( @{ $masterlist{$dir} } );
my $targetcell;
#check for infinite cols, 1 row ( a '*' for # of cols)
if ($gallery_cols eq '0') {
$gallery_cols = $numpix;
$targetcell = $numpix;
}
else {
$targetcell = $numpix - ($numpix % $gallery_cols) + $gallery_cols; #we can't stop short of an even row or tables get messed up. Print blank cells if pic is UNDEF
}
#start tables for pix
print OUT "\n";
foreach $picnum ( 0..($targetcell-1) ) {
$colcounter++;
print OUT '' if ($colcounter == 1); #if first column / outer table
print OUT ''; #outer table
#inner table below
unless ( $masterlist{$dir}[$picnum] eq undef ) {
#get icon location
my @temp = split /\//, $masterlist{$dir}[$picnum];
$temp[$#temp] = "$icon_prefix$temp[$#temp]";
my $icon_loc = join '/', @temp;
$icon_loc =~ s/^$starting_dir\///;
#get relative file location
my $rel_file = $masterlist{$dir}[$picnum];
$rel_file =~ s/$starting_dir\///;
#get just a file name
my $filename = $masterlist{$dir}[$picnum];
$filename =~ s(^.*/) (); #/
#print inner table with picture
print OUT "";
if ($inner_matt_bevel) { print OUT ""; }
#print OUT " ";
print OUT " ";
if ($inner_matt_bevel) { print OUT ' | '; }
print OUT ' | ';
#print OUT "Scaled | Hi-Res";
}
print OUT ' | ';
print OUT '
' if ($colcounter == $gallery_cols); #if last column / outer table /
if ($colcounter == $gallery_cols) { $colcounter = 0; } #reset colcounter *back to zero*
}
print OUT '
'; #outer table
print OUT PrintFooter();
close OUT;
}
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub BuildMainPage {
# Builds the main page
# Takes: --
# Returns: -- (saves the main page to disk)
my $wallpaper_hook = "background=\"$wallpaper\"" if $use_wallpaper;
open(OUT, ">$starting_dir/$main_page");
print OUT <<"END";
$slideshow_name - Main
$slideshow_name
$mainpage_opt_text
END
print OUT qq|View in slideshow format
| if $create_ss;
print OUT <<"END";
Use the links on the left to navigate the gallery
END
close OUT;
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub PrintHeader {
# returns a standard page HTML header
# Takes: Page title
# Returns: a big string
my $wallpaper_hook = "background=\"$wallpaper\"" if $use_wallpaper;
my $temp = <<"END";
$slideshow_name - $_[0]
END
$temp .= "$_[0]
" if $_[0];
return $temp;
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub PrintFooter {
# returns a standard page HTML footer
# Takes: --
# Returns: a string
my $temp = <<"END";
END
return $temp;
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#///////////////// END HTML GALLLERY SECTION /////////////////////////////////////////////////////////////////////////////////////////
##################################################################################
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub StartSS {
print "[ Now generating slideshow . . . ]\n" if $verbose;
my $wallpaper_hook = "background=\"$wallpaper\"" if $use_wallpaper;
my $first_image;
open(OUT, ">$starting_dir/$slideshow_page");
print OUT <<"END";
$slideshow_name - The Slideshow
END
print OUT PrintFooter();
close OUT;
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sub MakePatternFiles {
# creates pattern images JPEG files for including in the background of HTML elements
# Takes: a list of pattern names in gimp
# Returns: new names of input pattern names
# x. "somepattern" --> "ptrn-somepattern.jpg"
my @pattern_names = @_;
OUTERLOOP: foreach $pattern_name (@pattern_names) {
my $gimp_pattern_name = $pattern_name; # for gimp functions
#change (in-house) pattern name for later return
$pattern_name =~ s/[\^\$\+\*\?\.\|\(\)\[\]\{\}\\~`=&%#@!\/<>'";: ]//g;
$pattern_name = "$pattern_prefix$pattern_name.jpg";
#check to see if already exists in the creation dir
local(*CURRENT);
opendir(CURRENT, "$starting_dir");
my @thisdirinfo = readdir CURRENT;
closedir CURRENT;
foreach $i (@thisdirinfo) {
if ($i eq $pattern_name) {
print "$neg_check" . "Pattern: $pattern_name already exists. Skipping pattern creation\n" if $verbose;
next OUTERLOOP;
}
}
#0 = name, 1 = height, 2 = width, etc...
my @pattern_data = gimp_patterns_get_pattern_data($gimp_pattern_name);
#create new image the size of the pattern tile
my $img = gimp_image_new($pattern_data[2], $pattern_data[1], 0);
#make the background
my $layer = gimp_layer_new($img, $pattern_data[2], $pattern_data[1], 0, 'background', 100, 0);
gimp_image_add_layer($img, $layer, 0);
#select all
gimp_selection_all($img);
#set pattern
gimp_patterns_set_pattern($gimp_pattern_name);
#bucket fill pattern
gimp_bucket_fill($layer, 2, 0, 100, 255, 0, 0, 0);
#save the image
file_jpeg_save(0, $layer, "$starting_dir/$pattern_name", "$starting_dir/$pattern_prefix$pattern_name", 1.0, 0.0, 1, 1, "P2S2 Generated Background Tile", 0, 1, 0, 0);
print "X Pattern: $pattern_name created\n" if $verbose;
}
return(@pattern_names);
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# RGBtoHEXTriples - Combo-Sub - Converts standard dec (255) values to hex (FF) in RGB color arrays (triples)
# Takes: an RGB array --> x. (125, 190, 215)
# Returns: a hex string (without # sign)
sub RGBtoHEXTriples {
my @colors = @_;
foreach (@colors) { $_ = RGBtoHEX($_) }
return ( join("", @colors) );
}
#------------------------------------------------------------
# Takes: any integer 0-255
# Returns: hex formatted string ("FF")
sub RGBtoHEX {
my $value = $_[0];
my $divided = ConvertToHexDigit( (int($value / 16)) ); #/
my $leftover = ConvertToHexDigit( ($value % 16) );
$value = "$divided" . "$leftover";
return $value;
}
#------------------------------------------------------------
# Takes: any integer 0-15
# Returns: hex formatted string
sub ConvertToHexDigit {
my $num = $_[0];
if ($num == 10) {$num = A}
if ($num == 11) {$num = B}
if ($num == 12) {$num = C}
if ($num == 13) {$num = D}
if ($num == 14) {$num = E}
if ($num == 15) {$num = F}
return $num;
}
#/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#----------------------------------------------------------------------------------------------------------
sub Exclude {
#Determines if files to exclude are hit
#Takes: --
#Returns: 1 if exclude file was matched, 0 if not.
foreach $i (@excludefiles) {
if ($i eq $_[0]) {return 1}
}
return 0;
}
#----------------------------------------------------------------------------------------------------------
register
"p2s2", # fill in name
"P2S2 - Perl Powered Slide Show", # a small description
"", # a help text
"leiavoia@attbi.com", # Your name
"(c) Some Guy", # Your copyright
"20020627", # Date
"/Xtns/Script-Fu/Misc/p2s2", # menu path
"*", # Image types
[
#[ PF_FILE, "starting_directory", "The target directory", "/home/leiavoia/perl/gimp/samplepix" ],
[ PF_FILE, "starting_directory", "The target directory", "~/" ],
[ PF_STRING, "title", "The title of the slide show and/or gallery", "Picture Gallery" ],
#could be PF_TEXT :
[ PF_TEXT, "optional_text", "Optional descriptive text for the main gallery page", "Some sample text here" ],
[ PF_TOGGLE, "create_gallery", "Do you wish to create an HTML presentation gallery?", 1 ],
[ PF_SLIDER, "columns", "Number of thumbnail columns in the HTML gallery (use ZERO for one long row)", 1, [0, 10, 1] ],
[ PF_SLIDER, "matt_width", "Width of frame matts in pixels", 20, [0, 300, 2] ],
[ PF_SLIDER, "outer_matt_bevel", "Width of outer matt bevel", 8, [0, 10, 1] ],
[ PF_SLIDER, "inner_matt_bevel", "Width of inner matt bevel", 4, [0, 10, 1] ],
[ PF_STRING, "longest_side_value", "Length in pixels of the designated side", "150" ],
[ PF_RADIO, "resize_mode", "Which side should gimp scale to? (auto = longest side)", "auto", ['auto' => 'auto', 'width' => 'width', 'height' => 'height'] ],
[ PF_TOGGLE, "create_slide_show", "Do you wish to create an HTML slide show?", 1 ],
[ PF_SLIDER, "slideshow_rotation_delay", "Pause between each pic in slideshow (milisec's)", 8000, [100, 100000, 100] ],
[ PF_SLIDER, "slideshow_display_height", "Height of each picture in the slideshow (pixels)", 400, [10, 1500, 10] ],
[ PF_TOGGLE, "use_wallpaper", "Use wallpaper, not a solid color", 1 ],
[ PF_PATTERN, "wallpaper", "Wallpaper pattern", 'Marble #1'],
[ PF_TOGGLE, "use_mattpaper", "Use matt pattern, not a solid color.", 1 ],
[ PF_PATTERN, "mattpaper", "Matt pattern", 'Multi-Hued Rock' ],
[ PF_COLOR, "bgcolor", "Background color", "#333333" ],
[ PF_COLOR, "mattcolor", "Matt Color", "#999999"],
[ PF_COLOR, "textcolor", "Text Color", "#000000"],
[ PF_TOGGLE, "execute_recursive", "Program will work recursive directories", 1 ],
[ PF_TOGGLE, "reiconify", "Re-Iconify pictures that already have thumbnails (\"do-over\")", 0 ],
[ PF_TOGGLE, "verbose", "Turn on Verbose mode (recommended for shell execution)", 1 ],
],
\&Begin;
exit main();
__END__
=HELP
P2S2 is a full-featured image gallery and slideshow generator. All you need to do is give it a directory full of images, and out comes a
cross-browser-based "gallery" of thumbnail images with links and a fancy user-configurable slideshow. It's ideal for archiving your vacation photos
or if you have a digital camera, you can just dump all your images on the hard drive, run P2S2, and there you go! It's also great for making a
hardcopy archive for putting on a CDR and sending to friends and family. Since It's all web browser viewable, no one will need any special software
to view your work.
Help for settings:
Starting Directory: pretty obvious. This is the root of the thumbnail generation. P2S2 can act recursively off this directory or not, but it will not
work upwords. This is also the directory where all patterns and HTML pages get dumped. You will find the index page located in this directory.
Title: This will show up on the front page of the gallery and in the title bar of the web browser
Optional Text: This also shows up on the front gallery page. It does not appear anywhere else and can safely be omitted
Create Gallery / Create Slideshow (toggles): You don't have to make a gallery or a slideshow. You can just make thumbnails if you want.
Columns: Gallery thumbnails are arranged into columns. Use zero if you would like one long "wall" (one row) of thumbnail images like a real gallery.
Matt Width: The width of the matt board around the image. You can use zero for no matt at all.
Inner / Outer Matt Bevels: There is an optional inner and outer matt bevel for images. You can make them bigger or smaller or zero for no bevel. NOTE:
some browsers like mozilla pick up the background colors to use for the matt bevels. The inner bevel corresponds to Matt Bacground Color, the outer
bevel to the main Background Color.
Longest Side Value: When thumbnails get resized they need a target length value (see next entry).
Resize Mode: Thumbnails get resized to a target length according to it's mode: length=value, height=value, or AUTO (longest side = value). Using AUTO
will give the most regular results.
Slideshow Rotation Delay: The rotation delay in miliseconds to use as the default for the slideshow. Can be changed by the user later during the
sesssion.
Slideshow Display Height: Most pictures are larger than the screen, so this is the default height for all pictures in the slideshow.
Use Wallpaper / Mattpaper: Instead of using a solid color, you can use GIMP texture patterns for your page background and matt board. Leaving these
setting off will default to solid color mode.
Execute Recursive: If this is selected, P2S2 will sniff out all subdirectories under your starting directory and create links to seperate pages with
images in the gallery. Otherwise, P2S2 will simply work with only the starting directory.
Re-Iconify: You can re-run P2S2 if you make HTML configuration changes, but the icons will not change if they have already been made. If you wish to
resize all the icons, for instance, you have to select this option so that images that already have thumbnails created will not get skipped (as they
do by default).
Verbose: It is recomended that you use P2S2 from the shell instead of in GIMP. This way you get cool feedback as to what is going on. You can do so by
turning on GIMP, then turn on the Perl Server under Xtns->Perl->Server. Then go to the shell and type:
$ perl /location/of/p2s2.pl (wherever you installed it)
There are more options inside the script itself. You need to open the script in a text editor and edit the finer-tuned setting in the GLOBAL PREFS
section at the top. Most of these can safely be left alone, but hey, free software is all about options right?
Enjoy P2S2! Any mods or additions or suggestions would be appreciated. Feel free to clean it up or work on the to-do list while you're at it :-)
leiavoia@attbi.com