################################################################################
# #
# ############################################################################ #
# # Title :
# # Description :
# # Coded by : Justin Lee # #
# # Version :
# # Date :
# # 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 File::Copy qw(cp);
use File::Find;
use Image::MetaData::JPEG;
use Getopt::Long qw(:config bundling);
use Tie::Simple; # until I move this into the lib
use constant {
NAME => basename($0),
HOME => @{[ fileparse($0) ]}[1]
};
use lib HOME . 'lib';
my (
$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_hidden_root_window, # Use Win32::GUI (for always) to hide the CMD window.
$use_verbose, # Display the log file in real time, as it's created.
$raw_dir_orig, # Specify where the camera stores it's pictures.
$raw_dir_temp, # Specify where raw pictures are copied to for compressing.
$no_logging, # Disable saving of the log file... Not recomended.
) = (
'','','',
'',
$ENV{USERPROFILE} . '/Desktop/pics',$ENV{'TEMP'} . '/camman',
''
);
GetOptions(
'progress-bar|P' => \$use_cli_progress_bar,
'gfx-progress-bar' => \$use_gfx_progress_bar,
'hide-window|w' => \$use_hidden_root_window,
'verbose|v!' => \$use_verbose,
'raw-directory|R=s' => \$raw_dir_orig,
'temp-directory|T=s' => \$raw_dir_temp,
'no-logging' => \$no_logging,
# 'help|h|H' => \&print_help
);
if ($use_hidden_root_window) {
require Win32::GUI;
my $root = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($root);
}
# start smoking, and make sure we got a way to get ... smokables
my ($inbox, $outbox);
pipe $inbox, $outbox or die;
$outbox->autoflush(1);
tie my $processing, 'Tie::Simple', $inbox,
FETCH => sub {
my $self = shift;
die unless ref $self;
chomp(my $in = <$self>);
return 0 unless $in;
return 0 if $in =~ /^(?:0|n(?:o(?:pe)?)?|done)$/io;
return 1 if $in =~ /^(?:1|y(?:e(?:a?h|s)|up)?|start(?:up)?)$/io;
return $1 if $in =~ /^(.*)$/o;
};
if (my $pid = fork) {
# init!
if ($processing) {
while ($processing) {
print $processing, "\n";
}
}
print "Done.\n";
} elsif (defined $pid) {
# have a nap
sleep 1;
# okay, let's go
print $outbox "start\n";
find(
{
no_chdir => 1,
wanted => sub {
next unless $_ =~ /jpe?g$/oi;
print $outbox "1\n";
print $outbox join('/',split(/\/|\\/,$_)) . "\n";
}
},
$raw_dir_orig
);
print $outbox "done\n";
} else {
exit 1;
}
exit 0;