#!/usr/bin/perl -w 


########
#### A program to make thumbnails from a directory of pictures.
# Copyright (C) RRECKTEK LLC  - All Rights Reserved
# Unauthorized copying of this file, via any medium is strictly prohibited
# Proprietary and confidential
# component of RRECKTEK Predictive Analytics Framework     
####
####

# we need these libs
use Getopt::Std;
use strict;

# these commandline args
our ($opt_d, $file, $debug, $convert);
getopts('d:');

# $debug=1;

$convert="/usr/bin/convert";

my $directory=($opt_d);

if (!defined $directory) {$directory=`pwd`}
if (!defined $directory) {die "$! I need a directory man -d"}
chomp($directory);

my @files=`ls $directory |grep -i png`;

foreach $file (@files) {
    chomp($file);
    if ($file =~ /^th-/) {next}
    if ($debug) {
    print "\n proccessing $file";
    }


#`convert -size 120x120  $file th-$file`;
`convert -define jpeg:size=4288x2848   $file  -auto-orient  -thumbnail 300x300   th-$file`;

#system ("$convert", "-size", "176x132", "$file",  "th-$file");

# this adds copyright statement but degrades image quality 

#`convert -font helvetica -fill white  -draw \"text 10,2110 \'COPYRIGHT  2004  RONALD P. RECK   ALL RIGHTS RESERVED.\'\" $file tempfile`;
#`mv tempfile $file`;
}