album-4.12/0000755000000000000000000000000012302545200011227 5ustar rootrootalbum-4.12/album0000755000000000000000000077160012302545132012274 0ustar rootroot#!/usr/bin/perl # Filename: album # Author: David Ljung Madison # See License: http://MarginalHacks.com/License/ my $VERSION= '4.12'; # Description: Makes a photo album. use strict; use IO::File; umask 022; # 0755 package album; # For plugins $|++; # For galbum ################################################## ################################################## # SETTINGS ################################################## ################################################## # Operating System? (Get from $^O variable) # OSX=Darwin, Win98=MSWin, WinXP=MSWin (damn), Win2k=MSWin32, Cygwin=cygwin my $OSX = ($^O =~ /darwin/i) ? 1 : 0; my $WINDOWS = (!$OSX && ($^O =~ /Win/i)) ? 1 : 0; my $WIN2K = ($^O =~ /MSWin32/i) ? 1 : 0; my $CYGWIN = ($^O =~ /cygwin/i) ? 1 : 0; # tcap isn't needed under cygwin, and I don't think it's # needed (or works) under Win2k my $TCAP = ($WINDOWS && !$CYGWIN && !$WIN2K) ? 1 : 0; my $CAVA = 0; # Cava packager for Windows apps if ($WINDOWS) { eval "use Cava::Pack"; $CAVA = 1 unless $@; $0 = $^X if $CAVA && $^X !~ m%(^|[/\\])perl(\.exe)?$%i; } my ($BASENAME,$PROGNAME) = split_path($WINDOWS ? '\\' : '/', $0); # Avoid "Broken pipe" messages $SIG{PIPE} = 'IGNORE'; ################################################## # CONF FILES ################################################## my $PROGFILE = ($PROGNAME =~ /^([^\.-]{3,})[\.-]/) ? $1 : $PROGNAME; #$PROGFILE = "album" if $PROGFILE eq "galbum"; my @CONFS = ( "/etc/$PROGFILE/conf", "/etc/$PROGFILE/$PROGFILE.conf", "/etc/$PROGFILE.conf", ); push(@CONFS, "$BASENAME/$PROGFILE.conf") if $BASENAME ne '.'; push(@CONFS, "$ENV{HOME}/.${PROGFILE}rc") if $ENV{HOME}; push(@CONFS, "$ENV{HOME}/.$PROGFILE.conf") if $ENV{HOME}; push(@CONFS, "$ENV{HOME}/.$PROGFILE/conf") if $ENV{HOME}; # I like to keep all my dot files in one directory besides my $HOME map { push(@CONFS, "$_/${PROGFILE}.conf") } split(':',$ENV{CONF}) if $ENV{CONF}; # Windows: "C:\Documents and Settings\TheUser" push(@CONFS, "$ENV{USERPROFILE}/$PROGFILE.conf") if $ENV{USERPROFILE}; my @DATA_PATH = ( "/etc/$PROGFILE", "/usr/share/$PROGFILE", ); push(@DATA_PATH, "$ENV{HOME}/.$PROGFILE") if $ENV{HOME}; my @PLUGIN_PATH = ( '@DATA_PATH/plugins' ); ################################################## # OPTIONS ################################################## # add_option(lvl, option, type, hash) # lvl = usage printing level: -h=1 -more=2 -usage=... # option = option name # hash{args} = args for usage (i.e., -option ) # hash{default} = default value # hash{usage} = "This is the usage line" # hash{usage} = ["Can also be","an array of lines"] # hash{one_time} = Set for options that shouldn't be saved in album.conf # type is one of: sub OPTION_SEP() { 1; } # Separator sub OPTION_BOOL() { 2; } sub OPTION_NUM() { 3; } sub OPTION_STR() { 4; } sub OPTION_ARR() { 5; } # Array of strings add_option(1,'h',\&usage, usage=>"Show usage"); add_option(1,'more',\&usage, usage=>"To show more options."); #add_option(2,'More',\&usage, usage=>"To show even more options."); add_option(2,'usage',\&usage, args=>'', emptyarg_okay=>1, usage=>"Show usage as deep as you like."); add_option(1,'lang',\&get_language, args=>'', emptyarg_okay=>1, usage=>"Specify language(s)"); add_option(2,'list_langs',\&list_languages, usage=>"List out full language information"); add_option(3,'make_lang',\&make_language, args=>'', usage=>"Print out a new language file"); add_option(10,'list_html_trans',\&list_languages, usage=>["List HTML translations for each language", "Useful for creating multi-lingual images for themes", "Output is in HTML and utf-8, change charset as needed"]); add_option(99,'check_langs',\&check_languages, usage=>"Check installed languages"); add_option(99,'make_lang_check',\&make_language, usage=>"Test that output/translations are okay for -make_lang"); add_option(10,'lang_path', OPTION_ARR, default=>['@DATA_PATH/lang'], usage=>"Add a path to search for language files"); add_option(2,'q',OPTION_BOOL, one_time=>1, usage=>"Be quiet"); add_option(2,'d',OPTION_BOOL, one_time=>1, usage=>"Set debug mode"); add_option(3,'D',OPTION_BOOL, one_time=>1, usage=>"Heavy debug mode"); add_option(9,'dtheme',OPTION_BOOL, one_time=>1, usage=>"Theme debug mode"); add_option(9,'Dtheme',OPTION_BOOL, one_time=>1, usage=>"Theme heavy debug mode"); add_option(99,'pod',\&gen_pod, usage=>"Generate pod text"); add_option(1,'conf', \&read_conf, one_time=>1, args=>'', usage=>"Read a .conf file"); add_option(2,'virgin_check',OPTION_BOOL, one_time=>1, default=>1, usage=>"Do the virgin check to see if you've run album before"); add_option(3,'save_conf',OPTION_BOOL, default=>1, usage=>"Save $PROGFILE.conf files in photo album"); add_option(3,'configure',OPTION_BOOL, usage=>"Setup initial $PROGNAME site configuration"); add_option(1,'version',\&version, usage=>"Display program version info"); add_option(3,'license',\&license, args=>'[type]', emptyarg_okay=>1, usage=>"Show license"); add_option(1,'mv',\&get_plugin, usage=>"Move imgs across albums: see 'album -plugin_info utils/mv'"); add_option(3,'create_plugin',\&get_plugin, usage=>"Create plugin: see 'album -plugin_info utils/create_plugin'"); # Album Options: add_option(1,'Album Options:',OPTION_SEP); add_option(9,'crf', OPTION_BOOL, one_time=>1, default=>0, usage=>"Album hash output in computer readable format"); add_option(9,'list_options', OPTION_BOOL, one_time=>1, default=>0, usage=>"Show default options and values for a given album"); add_option(3,'image_pages',OPTION_BOOL, default=>1, usage=>"Create a page for each image"); add_option(2,'thumbs',OPTION_BOOL, default=>1, usage=>"Images have thumbnails"); add_option(2,'dir_thumbs',OPTION_BOOL, default=>1, usage=>"Directories have thumbnail (if supported by theme)"); add_option(9,'thumb_post',OPTION_STR, default=>'', usage=>"Additional postfix for thumbnails."); add_option(1,'medium', OPTION_STR, args=>'', usage=>"Generate medium size images"); add_option(2,'just_medium',OPTION_BOOL, usage=>"Don't link to full-size images"); add_option(1,'slideshow',OPTION_BOOL, default=>0, usage=>"Slideshow capabilities (only with some themes)"); add_option(1,'embed',OPTION_BOOL, default=>1, usage=>"Use image pages for non-picture image pages"); add_option(3,'columns',OPTION_NUM, default=>4, usage=>"Number of image columns"); add_option(1,'clean',OPTION_BOOL, one_time=>1, usage=>"Remove unused thumbnails"); add_option(3,'captions',OPTION_STR, default=>'captions.txt', usage=>"Specify captions filename"); add_option(3,'image_headers',OPTION_BOOL, default=>0, usage=>"Show header.txt on image pages (default theme only)"); add_option(2,'album_captions',OPTION_BOOL, default=>1, usage=>"Also show captions on album page"); add_option(3,'folder_count',OPTION_BOOL, default=>1, usage=>"Show folder/image counts for each album"); add_option(1,'caption_edit',OPTION_BOOL, usage=>"Add comment tags so that caption_edit.cgi will work"); add_option(1,'exif', OPTION_ARR, args=>'', usage=>["Append exif info to captions. Use %key% in fmt string", "Example: -exif \"
Camera: %Camera model%\"", "If any %keys% are not found by jhead, nothing is appended."]); add_option(3,'exif_album', OPTION_ARR, args=>'', usage=>"-exif for just album pages"); add_option(3,'exif_image', OPTION_ARR, args=>'', usage=>"-exif for just image pages"); add_option(2,'file_sizes',OPTION_BOOL, usage=>"Show image file sizes"); ## For backwards compat with themes? add_option(999,'image_sizes', \&deprecated_option, usage=>"DEPRECATED: Size of images"); add_option(2,'fix_urls',OPTION_BOOL, default=>1, usage=>"Encode unsafe chars as %xx in URLs"); add_option(2,'known_images',OPTION_BOOL, default=>1, usage=>"Only include known image types"); add_option(2,'top',OPTION_STR, default=>'../', usage=>"URL for 'Back' link on top page"); add_option(2,'all',OPTION_BOOL, usage=>"Do not hide files/directories starting with '.'"); add_option(1,'add', OPTION_ARR, args=>'', one_time=>1, usage=>"Add a new directory to the album it's been placed in"); add_option(2,'depth',OPTION_NUM, default=>-1, one_time=>1, usage=>"Depth to descend directories (default infinite [-1])"); add_option(3,'follow_symlinks',OPTION_NUM, default=>1, usage=>"Dereference symbolic links"); add_option(2,'hashes',OPTION_BOOL, default=>1, one_time=>1, usage=>"Show hash marks while generating thumbnails"); add_option(2,'name_length',OPTION_NUM, default=>40, usage=>"Limit length of image/dir names"); add_option(2,'sort',OPTION_STR, default=>'captions', usage=>"Sort type, captions, name, date or EXIF date ('exif')"); ## Deprecated! add_option(99,'date_sort', \&deprecated_option, instead=>'sort', usage=>"DEPRECATED: Sort images/dirs by date instead of name"); add_option(99,'name_sort', \&deprecated_option, instead=>'sort', usage=>"DEPRECATED: Sort by name, not caption order"); add_option(2,'reverse_sort',OPTION_BOOL, usage=>"Sort in reverse"); add_option(2,'case_sort',OPTION_BOOL, default=>0, usage=>"Use case sensitive sorting when sorting names"); add_option(3,'body',OPTION_STR, default=>'', usage=>"Specify tags for non-theme output"); add_option(3,'charset', OPTION_STR, args=>'', usage=>["Charset for non-theme and some theme output", "This is also set by using language files (with -lang)"]); add_option(10,'force_charset', OPTION_STR, args=>'', usage=>"Force charset (not overridden by languages)"); add_option(99,'default_charset', OPTION_STR, args=>'', default=>'iso-8859-1', usage=>"Default charset"); add_option(2,'image_loop',OPTION_BOOL, default=>1, usage=>"Do first and last image pages loop around?"); add_option(1,'burn', OPTION_BOOL, usage=>["Setup an album to burn to CD", "Implies '-index index.html' and '-no_theme_url'"]); add_option(2,'index', OPTION_STR, args=>'', usage=>["Select the default 'index.html' to use.", "For file://, try '-index index.html' to add 'index.html' to index links."]); add_option(2,'default_index', OPTION_STR, args=>'', default=>'index.html', usage=>["The file the webserver accesses when", "when no file is specified."]); add_option(3,'html', OPTION_STR, args=>'', default=>'.html', usage=>"Default postfix for HTML files (also see -default_index)"); # Thumbnail Options: add_option(1,'Thumbnail Options:',OPTION_SEP); add_option(1,'geometry', \&parse_geometry, singleval=>1, args=>'x', default=>'133x133', usage=>"Size of thumbnail"); add_option(99,'x',OPTION_NUM, default=>133, usage=>"x Size of thumbnail"); add_option(99,'y',OPTION_NUM, default=>133, usage=>"y Size of thumbnail"); add_option(1,'type',OPTION_STR, default=>'jpg', usage=>"Thumbnail type (gif, jpg, tiff,...)"); add_option(1,'medium_type',OPTION_STR, usage=>"Medium type (default is same type as full image)"); add_option(1,'crop',OPTION_BOOL, default=>0, usage=>["Crop the image to fit thumbnail size", "otherwise aspect will be maintained"]); add_option(3,'CROP',OPTION_STR, usage=>"Force cropping to be top, bottom, left or right"); add_option(1,'dir',OPTION_STR, default=>'tn', usage=>"Thumbnail directory"); add_option(2,'force',OPTION_BOOL, one_time=>1, usage=>["Force overwrite of existing thumbnails and HTML", "otherwise thumbnails are only written when changed,", "and themed HTML is only written when changed"]); add_option(2,'force_html',OPTION_BOOL, one_time=>1, usage=>"Force rewrite of HTML"); add_option(9,'force_subalbum',OPTION_BOOL, one_time=>1, usage=>"Ignore 'You have moved a subalbum' error."); add_option(2,'sample',OPTION_BOOL, usage=>"Use 'convert -sample' for thumbnails (faster, low quality)"); add_option(2,'sharpen', OPTION_STR, args=>'x', usage=>"Sharpen after scaling"); add_option(1,'animated_gifs',OPTION_BOOL, usage=>"Take first frame of animated gifs (only some systems)"); add_option(2,'scale_opts',OPTION_ARR, usage=>"Options for convert (use '--' for mult)"); add_option(3,'medium_scale_opts',OPTION_ARR, usage=>"List of medium convert options"); add_option(3,'thumb_scale_opts',OPTION_ARR, usage=>"List of thumbnail convert options"); # Plugin Options: add_option(1,'Plugin and Theme Options:',OPTION_SEP); add_option(1,'data_path', OPTION_ARR, default=>\@DATA_PATH, usage=>["Path for themes, plugins, language files, etc...",""]); add_option(1,'plugin', \&get_plugin, args=>'', usage=>"Load a plugin"); add_option(1,'plugin_usage', \&usage, args=>'', usage=>"Show usage for a plugin"); add_option(3,'plugin_info', \&list_plugins, args=>'', one_time=>1, usage=>"Print info for a specific plugins"); add_option(10,'plugin_path', OPTION_ARR, default=>['@DATA_PATH/plugins'], usage=>"Add a path to search for plugins.\n\t"); add_option(10,'plugin_post', OPTION_STR, default=>'.alp', usage=>"Default postfix for plugins"); add_option(3,'list_plugins', \&list_plugins, one_time=>1, usage=>"Print info for all known plugins"); add_option(10,'list_plugins_crf', \&list_plugins, one_time=>1, usage=>"Print info for all plugins in computer readable format"); add_option(4,'list_hooks', \&list_hooks, one_time=>1, usage=>"Show all known plugin hooks (for developers)"); add_option(4,'hook_info', \&list_hooks, args=>'', one_time=>1, usage=>"Show hook info for a specific hook (for developers)"); # Theme Options: #add_option(1,'Theme Options:',OPTION_SEP); add_option(1,'theme', OPTION_STR, args=>'', usage=>"Specify a theme directory"); add_option(2,'theme_url', OPTION_STR, args=>'', usage=>"In case you want to refer to the theme by absolute URL"); add_option(10,'theme_path', OPTION_ARR, args=>'', default=>[], usage=>["Directories that contain themes",""]); add_option(3,'list_themes', OPTION_BOOL, one_time=>1, default=>0, usage=>"Show available themes"); add_option(3,'theme_full_info', OPTION_BOOL, default=>0, usage=>"Use full info for themes"); add_option(99,'theme_interp_wrap', \&theme_interp_wrap, one_time=>1, usage=>"Internal option for packaged application support - do not use"); # Paths: add_option($WINDOWS?1:10,'Paths:',OPTION_SEP); add_option(10,'convert',OPTION_STR, default=>'convert', usage=>"Path to convert (ImageMagick)"); add_option(10,'identify',OPTION_STR, default=>'identify', usage=>"Path to identify (ImageMagick)"); add_option(10,'jhead',OPTION_STR, default=>'jhead', usage=>"Path to jhead (extracts exif info)"); add_option(10,'ffmpeg',OPTION_STR, default=>'avconv', usage=>"Path to avconv/ffmpeg (extracting movie frames)"); add_option(10,'conf_file',OPTION_STR, default=>'album.conf', usage=>"Conf filename for album configurations"); add_option(10,'conf_version',OPTION_NUM, usage=>"Configuration file version"); add_option(10,'dev_null',OPTION_STR, default=>default_dev_null(), usage=>"Throwaway temp file"); # Windows crap: # "Windows. It may be slow, but at least it's hard to use" add_option($WINDOWS?1:10,'windows',OPTION_STR, default=>$WINDOWS, usage=>"Are we (unfortunately) running windows?"); add_option($WINDOWS?1:10,'cygwin',OPTION_STR, default=>$CYGWIN, usage=>"Are we using the Cygwin environment?"); add_option($WINDOWS?1:99,'slash',OPTION_STR, default=>$WINDOWS ? '\\' : '/', usage=>"The slash used between path components"); # Win98: Needs TCAP: ftp://ftp.simtel.net/pub/simtelnet/msdos/sysutl/tcap31.zip add_option($TCAP?1:10,'use_tcap',OPTION_BOOL, default=>$TCAP, usage=>"Use tcap? (win98)"); add_option($TCAP?1:10,'tcap',OPTION_STR, default=>'tcap', usage=>"Path to tcap (win98)"); add_option($TCAP?1:10,'tcap_out',OPTION_STR, default=>'atrash.tmp', usage=>"tcap output file (win98)"); add_option($TCAP?1:10,'cmdproxy',OPTION_STR, default=>'cmdproxy', usage=>"Path to cmdproxy (tcap helper for long lines)"); # Default directory page add_option(10,'header',OPTION_STR, default=>'header.txt', usage=>"Path to header file"); add_option(10,'footer',OPTION_STR, default=>'footer.txt', usage=>"Path to footer file"); add_option(10,'credit',OPTION_STR, usage=>"Credit line to add to the bottom of every album"); # We can't set -no_album as a command-line option because it # gets misread as a -no_