Album

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

Helper programs
===============

This program requires some helper programs for certain tasks.

  jpegtran    will be used to rotate JPEG files loslessly.
	      If missing, JPEG files will be rotated by ImageMagick,
	      with possible loss of information.
  mencoder    is needed to manipulate MPEG files.
	      If missing, MPEG files will be copied without
	      processing. They cannot be rotated, and may not be
	      playable on your mpeg player.
  mplayer     is needed to extract a still from MPEG movies, and to 
	      extract audio from VOICE files.
	      If missing, no stills will be produced, and VOICE files
	      will remain silent.

lib/Album/Tutorial.pm  view on Meta::CPAN

  Number of entries = 7 (7 added)
  .......[7]
  Creating pages for 7 images
  (No image pages needed updating)
  Creating pages for 1 index
  (No index pages needed updating)

'album' tries to avoid doing unnecessary work as much as possible. In
this case, all thumbnails and image and index pages are up to date.
The line of periods shows progress, one period for each image
processed.

=head2 Protecting your work

'album' not only tries to avoid doing unnecessary work, but it is also
very careful to not destroy your original images, nor any other
changes you may have made.

In general, 'album' will I<never> overwrite or modify:

=over 4

lib/Album/Tutorial.pm  view on Meta::CPAN

=item 2. C<info.dat>

=item 3. user config file C<.albumrc> in current directory

=item 4. user config file C<.albumrc> in the home directory

=back

Environment variable ALBUMCONFIG can be used to designate user
config files. It should be set to a colon-separated list of file names
to be processed in order of precedence.

=head2 Importing new images

An important feature of 'album' is importing new images from an
external source. For example, you can import new images from a CD-ROM,
or from a digital camera.

Assuming you mounted a CD-ROM with new images, execute 'album' as
follows:

lib/Album/Tutorial.pm  view on Meta::CPAN

  Number of entries = 9 (2 added)
  .......[7]
  im030.jpg: copy medium thumbnail OK
  im031.jpg: copy medium thumbnail OK
  Creating pages for 9 images
  (Needed to write 18 image pages)
  Creating pages for 1 index
  (Needed to write 1 index page)

Two new images were found on the CD-ROM, copied to the 'large'
directory, and processed as usual. 'info.dat' has been updated with
the new entries. Note that images found on the CD-ROM that already
exist in 'large' (i.e., have the same name) are skipped.

=head2 Using EXIF information

When importing images from a digital camera, 'album' can use the EXIF
information that is present in these files:

=over 4

lib/Album/Tutorial.pm  view on Meta::CPAN


it will set the modification time of the file to the time stamp;

=item *

while copying the image, it will be rotated if necessary,
according to the 'orientation' property in the EXIF information.

=back

To enable EXIF processing, add the B<--exif> command line option, or
specify the import directory with B<--dcim> instead of B<--import>:

  $ ls -l /mnt/camera/dcim/101msdcf
  -rwxr-xr-x 1 jv jv 2347808 Jun 25 12:08 /mnt/camera/dcim/101msdcf/dsc00052.jpg
  -rwxr-xr-x 1 jv jv 1327475 Jun 25 12:05 /mnt/camera/dcim/101msdcf/dsc00053.jpg
  $ album -v --dcim /mnt/camera/dcim/101msdcf --update
  Updating info.dat
  Number of entries = 11 (2 added)
  .........[ 9]
  200405171843310052.jpg: link medium thumbnail OK

script/album  view on Meta::CPAN

# Command line options.
my $import_exif = 0;
my $import_dir;
my $update = 0;			# add new from large/import
my $dest_dir = ".";
my $info_file;
my $linkthem = 1;		# link orig to large, if possible
my $clobber = 0;
my $mediumonly = 0;		# only medium size (for web export)
my $externalize_formats = 0;	# create external format files
my $verbose = 1;		# verbose processing

# These are left undefined, for set_defaults. Note: our, not my.
our $index_columns;
our $index_rows;
our $thumb;
our $medium;			# medium size, between large and small
our $album_title;
our $caption;
our $datefmt;
our $icon;
our $locale;
our $lib_common;

# These are not command line options.
my $journal;			# create journal

# Development options (not shown with -help).
my $debug = 0;			# debugging
my $trace = 0;			# trace (show process)
my $test = 0;			# test mode.

# Process command line options.
app_options();

# Post-processing.
$trace |= ($debug || $test);
$dest_dir =~ s;^\./;;;
$import_dir =~ s;^\./;; if $import_dir;

################ Presets ################

use constant DEFAULTS => { info       => "info.dat",
			   title      => "Photo Album",
			   medium     => 0,
			   mediumsize => 915,

script/album  view on Meta::CPAN

use Image::Magick;
use Data::Dumper;
use POSIX qw(locale_h strftime);
use locale;

# The files already there, if any.
my $gotlist = new FileList;
# The files in the import dir, if any.
my $implist = new FileList;

# The list of files, in the order to be processed.
# This list is initialy filled from info.dat, and (optionally) updated
# from the other lists.
my $filelist = new FileList;

# This is the list of all entries to be journalled (all images, plus
# possible interspersed loose annotations).
my @journal;

# Load cached info, if possible.
load_cache();

script/album  view on Meta::CPAN

# Image types.
use constant T_JPG    => 1;
use constant T_MPG    => 2;
use constant T_VOICE  => 3;	# still image + sound
# Pseudo types.
use constant T_PSEUDO => 0;
use constant T_TAG    => -1;
use constant T_ANN    => -2;
use constant T_REF    => -3;

# List of possible subdirs to process.
my @subdirs;

# Journal tags
my %jnltags;

# Note: the HTML generators use the file names relatively.
sub fjoin	 { File::Spec->catfile(@_); }
sub d_dest       { unshift(@_, $dest_dir) unless $dest_dir eq ".";
		   fjoin(@_); }
sub d_large      { unshift(@_, "large");      goto &d_dest; }

script/album  view on Meta::CPAN

	    </td>
	  </tr>
	</table>
      </body>
    </html>
    EOD

    print STDERR ("\n") if $did;
}

sub process_fmt {
    my ($fmt, %map) = @_;
    $fmt =~ s/^(.*?)\$(\w+)\b/$1.indent($map{$2}, length($1))/gme;
    $fmt;
}

################ Helpers for Image/Index/Journal pages ################

sub jscript {
    my (%nav) = @_;
    my $next = $nav{next};

script/album  view on Meta::CPAN

	}
	$tt2 = "<a href='#' class='info'>" . $tt .
	  "<span>" .
	    "<table border='1' width='100%'>\n" .
	      "<tr><td>$t</td></tr>" .
		"</table>\n" .
		  "</span></a>" if $t;
    }

    update_if_needed(d_dest($dir, $htmllist[$i]),
		     process_fmt($dir eq "medium" ?
				   $fmt_medium_page :
				   $fmt_large_page,
				 title	  => $it,
				 dir	  => $dir,
				 ltop	  => $it2,
				 rtop	  => $tt2,
				 hbuttons => join("", @b),
				 vbuttons => join("$br\n", @b),
				 jscript  => jscript(%nav),
				 image	  => $imglink,

script/album  view on Meta::CPAN

		else {
		    $cc .= "    <td width='$thumb'>&nbsp</td>\n";
		}
	    }
	    $cc .= "  </tr>\n";
	}
    }
    $cc .= "</table>\n";

    update_if_needed(d_dest(ixname($x)),
		     process_fmt($fmt_index_page,
				 title    => $tt,
				 ltop     => $tt,
				 rtop     => $t,
				 hbuttons => join("", @b),
				 vbuttons => join("$br\n", @b),
				 jscript  => jscript(%nav),
				 contents => $cc,
				));
}

script/album  view on Meta::CPAN

		  button("index", "../index$ix.html",  1, 1             ),
	     );
	my %nav = ( up  => "../index$ix.html",
		    idx => "../index$ix.html" );
	$nav{prev} = $jname->($x) if $x > 0;
	$nav{next} = $jname->($x+2) if $x < $journal-1;

	$x++;

	update_if_needed(d_journal("jnl" . $jnltags{$tag} . ".html"),
			 process_fmt($fmt_journal_page,
				     title    => "Journal: " . htmln($tag),
				     tag      => htmln($tag),
				     hbuttons => join("", @b),
				     vbuttons => join("$br\n", @b),
				     journal  => $jnl,
				     jscript  => jscript(%nav),
				    ));
    };

    my $mod = 0;

script/album  view on Meta::CPAN

    my $doing = 0;
    my $did = 0;

    while ( <DATA> ) {
        if ( $doing ) {         # uudecoding...
            if ( /^Xend/ ) {
                close($out);
                $doing = 0;	# Done
		next;
            }
            # Select lines to process.
            next if /[a-z]/;
	    next unless /^X(.*)/s;
	    $_ = $1;
            next unless int((((ord() - 32) & 077) + 2) / 3)
              == int(length() / 4);
            # Decode.
            print $out unpack("u",$_);
            next;
        }

script/album  view on Meta::CPAN

            $name = d_icons($1);
	    print STDERR ("$1 ") if $verbose > 1;
            open($out, ">$name");
	    binmode($out);
            $doing = 1;         # Doing
            next;
        }
    }
    print STDERR ("\n") if $verbose > 1;
    if ( $doing ) {
        die("Error in DATA: still processing $name\n");
        unlink($name);
    }
}

################ Style Sheets ################

my $add_stylesheet_msg;
sub add_stylesheets {
    my $css_fontfam = "font-family: Verdana, Arial, Helvetica";
    my $WHITE = "#FFFFFF";



( run in 0.267 second using v1.01-cache-2.11-cpan-8d75d55dd25 )