################################################################################
# #
# ############################################################################ #
# # Title : camman.pl # #
# # Description : Sorts, compresses, archives, manages pictures. # #
# # Coded by : Justin Lee # #
# # Version : PRE:0.1 # #
# # Date : Thursday, February 9, 2008 # #
# # License : GNU General Public License v.2 # #
# # Copyright (C) 2008 Justin Lee <kool.name at gmail.com> # #
# ############################################################################ #
# #
# ############################################################################ #
# # This program is free software; you can redistribute it and/or # #
# # modify it under the terms of the GNU General Public License version 2 # #
# # as published by the Free Software Foundation. # #
# # # #
# # 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 the Free Software # #
# # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # #
# # 02110-1301, USA. Or, see: <http://www.gnu.org/licenses/> # #
# ############################################################################ #
# #
################################################################################
use strict;
use warnings;
use File::Basename;
use IO::Handle;
use FileHandle;
use DBI;
use DBD::SQLite;
use File::Copy qw(cp);
use File::Find;
use Image::MetaData::JPEG;
use Image::Magick;
use Class::Date qw(date now);
use Getopt::Long qw(:config bundling);
use constant {
NAME => basename($0),
HOME => @{[ fileparse($0) ]}[1]
};
use lib HOME . 'lib';
use Logger::ByDate;
my (
$use_orig_raw_removal, # Unlink a raw (from the camera) once it has been processed.
$use_init_file, # Tell the script to look for a .INI with the same name.
$use_cli_progress_bar, # Use a crazy text-only progress bar. (Cross platform.)
$use_gfx_progress_bar, # Use Win32::GUI (for now) to create a graphical progress bar.
$use_verbose, # Display the log file in real time, as it's created.
$use_hidden_root_window, # Use Win32::GUI (for always) to hide the CMD window.
$raw_dir_orig, # Specify where the camera stores it's pictures.
$raw_dir_temp, # Specify where raw pictures are copied to for compressing.
$resize_dir, # Specify where resized pics are saved.
$no_temp_raw_removal, # Save the temp raws... Watch `$raw_dir_temp'.
$no_logging, # Disable saving of the log file... Not recomended.
$sql_reset, # Reset all SQL.
$sql_update, # Update SQL. Used if you were to delete a resized pic.
$debug # Future debug handle.
) = (
'','','',
'','','',
'',$ENV{'TEMP'} . '/camman',
$ENV{'USERPROFILE'} . '/My Documents/My Pictures/From Camera/Resized',
'','',
'','',
new Logger::ByDate (HOME . 'logs',{
'wdir' => HOME,
'name' => uc(@{[ split(/\./,NAME) ]}[0]),
});
);
GetOptions(
'remove-old!' => \$use_orig_raw_removal,
'use-init|I' => \$use_init_file,
'progress-bar|P' => \$use_cli_progress_bar,
'gfx-progress-bar' => \$use_gfx_progress_bar,
'verbose|v!' => \$use_verbose,
'hide-window|w' => \$use_hidden_root_window,
'raw-directory|R=s' => \$raw_dir_orig,
'temp-directory|T=s' => \$raw_dir_temp,
'local-directory|L=s' => \$resize_dir,
'save-raws' => \$no_temp_raw_removal,
'no-logging' => \$no_logging,
'sql-reset' => \$sql_reset,
'sql-update' => \$sql_update,
'help|h|H' => \&print_help
);
sub print_help {
print <<"EOH";
Name : \u@{[ NAME ]} - Automatically move, compress and sort your pictures.
Usage : @{[ NAME ]} [options]
Description : \u@{[ NAME ]} is a script written for moving and compressing pictures
from your camera to a local folder. The pictures are stored in
directories named with ISO-like dates of `yyyy-mm-dd'.
Options :
-h, -H, --help
Prints this message.
-w, --hide-window
Use Win32::GUI to hide the console window.
-I, --use-init
Use `@{[ HOME ]}setup.ini' to gather some info.
-P, --progress-bar
Display a crude text progress bar.
-v, --verbose, --no-verbose
Display the log file in real time. (--no-verbose is default)
-R, --raw-directory < /path/to/camera/raws/ >
Specifies the path to the camera raws. It can also be specified
with -I in the setup file. Note that this is a required piece of
data.
-T, --temp-directory < /path/to/temp/files/ >
Specifies a place to save the copied raws. This can also be
specified in the setup file with -I. Defaults to `$ENV{TEMP}'.
-L, --local-directory < /path/to/resized/files/ >
Specifies the place to save the resized pictures. Can be specified
in the setup files with -I.
Defaults to `@{[ $ENV{'USERPROFILE'} . '/My Documents/My Pictures/From Camera/Resized' ]}'.
--remove-old, --no-remove-old
Specifies whether or not to remove the original raws from the camera
directory. The default is to leave them. (--no-remove-old)
--gfx-progress-bar
Use experimental (so experimental it's not even coded, in fact)
Win32::GUI-based graphical progess bar.
--save-raws
Do not remove temporary raw files after compressing is finised.
--logging, --no-logging
Keeps log files in @{[ HOME ]}logs (default). It is not recommended
to use --no-logging.
--sql-reset
Remove all SQL data.
--sql-update
Update the SQL database in case of changes made by the user to the local
picture directory.
EOH
exit 0;
}