\n" )
if $displayed_image_number % $pics_per_row == 0
and ( $displayed_image_number != 0 );
++$displayed_image_number;
# THUMBNAILS
# The value of $thumbnail_filename is the title under each thumbnail.
# $actual_thumbnail_filename is the real file name of the thumbnail.
my $actual_thumbnail_filename = make_thumbnail_filename( $file );
my @values = ( 'ok', 'cp', ROTATION_LABELS );
if ( $add_delete_buttons ) {
splice @values, 2, 0, 'del'; # insert after second position
}
my $title = $unrotated_file_name;
# If the file name is long, it may be words separated by hyphens
# or underlines, so remove them:
$title =~ s/[-_]/ /g if length $title > 15;
# print "exists\n" if $title_list;
# print "ref\n" if ref $title_list;
#print "Check ref for $title\n";
if ( $title_list and exists $title_list->{$unrotated_file_name} ) {
#print "title=$title\n";
$title = $title_list->{$unrotated_file_name}
if $title_list->{$unrotated_file_name};
#print "title=$title\n";
}
$thumbnail_filename = $title;
my $current_dir = cwd;
$picture_title = start_form( -action => TITLE_CGI_PROGRAM )
. textfield(
-name => 'picture_title',
-default => $title,
-override => 1,
-size => 80,
)
. hidden(
-name => 'titlefile',
-default => "$current_dir/" . TITLE_FILE,
-override => 1,
)
. hidden(
-name => 'key',
-default => "$unrotated_file_name",
-override => 1,
)
. end_form;
if ( $add_buttons ) {
$thumbnail_filename .=
radio_group(
-name => $unrotated_file_name,
-values => [ @values ],
-default => 'ok',
-linebreak => 0,
-rows => 2,
-cols => 3,
);
}
$thumbnail_filename .= "";
make_thumbnail( $file, $actual_thumbnail_filename ) or next JPEGFILE;
my ( $x, $y ) = size_of_image_file( $actual_thumbnail_filename )
or warn "Cannot get size of $file!\n";
my $picture_html_filename
= basename( $unrotated_file_name, ".jpg" ) . ".html";
my $picture_s_html_filename
= basename( $unrotated_file_name, ".jpg" ) . "-s.html";
my $picture_l_html_filename
= basename( $unrotated_file_name, ".jpg" ) . "-l.html";
$thumbnail = sprintf(
""
. "",
$y, $x );
# This is just a sanity check:
my $derived_unrot_name = get_unrotated_name $file;
cluck "'$derived_unrot_name' from '$file' not match ",
"'$unrotated_file_name'"
unless $derived_unrot_name eq $unrotated_file_name;
# end of sanity check.
my $timestamp = mtime_to_string( $time{ $unrotated_file_name } );
$thumbnail_number = sprintf "%03d $timestamp", $i + 1;
$thumbnail_number
.= " Sml"
. " Big";
print_to_index( $new_indexfile, " | \n" );
gallery_parse_tags( $theme_dir . "thumbnail.html", $new_indexfile );
print_to_index( $new_indexfile, "\n | \n" );
# END OF THUMBNAIL
# NOW BUILD PICTURE HTML FILES:
# First part of the heading for the individual picture html files.
# Appears above each large photo.
$picture_number = "$file taken at $timestamp";
if ( $i == 0 ) {
$picture_previous = $indexfile;
$picture_s_previous = $indexfile;
$picture_l_previous = $indexfile;
} else {
my $prev = get_unrotated_name $files[ $i - 1 ];
$picture_previous = basename( $prev, ".jpg" ) . ".html";
$picture_s_previous = basename( $prev, ".jpg" ) . "-s.html";
$picture_l_previous = basename( $prev, ".jpg" ) . "-l.html";
}
if ( $i == $#files ) {
$picture_next = $indexfile;
$picture_s_next = $indexfile;
$picture_l_next = $indexfile;
} else {
my $next = get_unrotated_name $files[ $i + 1 ];
$picture_next = basename( $next, ".jpg" ) . ".html";
$picture_s_next = basename( $next, ".jpg" ) . "-s.html";
$picture_l_next = basename( $next, ".jpg" ) . "-l.html";
}
# unlink $theme_dir . "picture.html";
unlink $picture_html_filename;
unlink $picture_s_html_filename;
unlink $picture_l_html_filename;
gallery_parse_tags( ( $theme_dir . "picture.html" ),
$picture_html_filename );
gallery_parse_tags( ( $theme_dir . "picture-s.html" ),
$picture_s_html_filename );
gallery_parse_tags( ( $theme_dir . "picture-l.html" ),
$picture_l_html_filename );
print STDERR "$file "; # A crude progress meter.
# END OF PICTURE HTML FILE CONSTRUCTION
}
print_to_index( $new_indexfile, $navigation );
#
# append index_bottom.html to index.html
# cd ..
print_to_index( $new_indexfile, "\n\n" );
if ( $add_buttons ) {
print_to_index(
$new_indexfile,
popup_menu(
-name => "where_to",
-values => [ @photo_locations ]
),
submit(
-value => "Selected Photos",
-name => "action",
),
submit(
-value => "Copy ALL Photos",
-name => "action",
),
);
}
if ( $add_delete_buttons ) {
print_to_index(
$new_indexfile,
submit(
-value => "Delete ALL Photos",
-name => "action",
),
)
}
print_to_index( $new_indexfile, endform() );
gallery_parse_tags( $theme_dir . "index_bottom.html",
$new_indexfile );
unlink $indexfile;
rename $new_indexfile, $indexfile
or die "Unable to rename $new_indexfile, $indexfile: $!";
print STDERR "\nChanging directory to '$startdir'\n" if $debug;
chdir( $startdir )
or die "Cannot change directory back to $startdir: $!";
my $time = dir_date_name_to_unix_time( $dir );
my $abs = abs_path( $dir );
my $cwd = cwd;
utime $time, $time, $dir or warn "Cannot update utime of $abs in $cwd\n";
last if $max_dirs and ++$num_dirs == $max_dirs;
}
print STDERR "\n\nAll finished.\n";
__END__