#!/usr/bin/perl5 #setup for libraries BEGIN { $JPL="/intac/u1/jshuyler/perl"; $JPL="/files/perl"; push (@INC, $JPL); push (@INC, $JPL . "/lib"); push (@INC, $JPL . "/lib/Text"); push (@INC, $JPL . "/lib/Text/CSV"); push (@INC, $JPL . "/lib/Image"); push (@INC, $JPL . "/lib/Image/Info"); require Image::Info; import Image::Info; } use Image::Info qw(image_info dim html_dim); #get Jeff's libraries for counting require "strings.pl"; require "hash-count.pl"; #print "USAGE: perl5 input_file output_file_prefix\n\n"; #setup filename and titleinformation $subpageFilename = "index.html"; $indexpageFilename = "pics.html"; $title = "Pictures"; ##prep CSV module #$csv = Text::CSV->new(); #prep image info extraction @info_array=("file_media_type", "file_ext", "width", "height", "color_type", "SamplesPerPixel", "BitsPerSample", "Resolution", "ResolutionUnit", "XResolution", "YResolution", "Comment", "Interlace", "Compression"); #prep ImageInfo module $oy = image_info("bob/TN_Pic_991231_022a.JPG"); ($w, $h)=dim($oy); print "width: $w height: $h\n"; $d=html_dim($oy); print "htmldim: $d\n"; #$ct=$oy->{"color_type"}; #print "$ct\n"; foreach $attr (@info_array) { $inf=$oy->{"$attr"}; printf "%15s: %s\n", $attr, $inf; } $d0=$oy->{"BitsPerSample"}[0]; $d1=$oy->{"BitsPerSample"}[1]; $d2=$oy->{"BitsPerSample"}[2]; $d3=$oy->{"BitsPerSample"}[3]; print "$d0 $d1 $d2 $d3\n"; #die "stopping"; #main starts HERE @dirlst=`find . -type d -print`; chomp(@dirlst); @dir1=sort(grep(!/^\.$/, @dirlst)); for $d (@dir1) { print "-----directory: $d\n"; ($tns, $pics)=&DoPage ($d, $subpageFilename, $title); $tn{$d}=$tns; $im{$d}=$pics; } # open(FF, ">pics.html") || die "creating: $indexfile"; print FF "$title\n"; print FF "\n"; print FF "


\n"; print FF "

$title

\n"; print FF "


\n"; print FF "\n"; print FF "\n"; print FF "\t\n"; print FF "\t\n"; print FF "\t\n"; print FF "\n"; foreach $d (@dir1) { $e=$d; $e =~ s/\.\///g; print FF "\n"; print FF "\t\n"; print FF "\t\n"; print FF "\t\n"; print FF "\n"; } print FF "
DirectoryPicturesThumbnails
$e$im{$d}$tn{$d}
\n"; print FF "


\n"; print FF "\n"; close(FF); if (0) { print "\n\n"; print_array("thumbnail"); print "\n\n"; print_array("picture"); } #subs begin sub DoPage { local($ddir)=local($dir)=shift; local($outfile)=shift; local($title)=shift; $ddir=~s/\.\///g; open(FO, ">$dir/$outfile") || die "creating: $dir/$outfile"; print FO "$title\n"; print FO "\n"; print FO "


\n"; print FO "

$title

\n"; print FO "

$ddir

\n"; print FO "


\n"; ($tns, $pics)=&DoFiles($dir); print FO "


\n"; print FO "\n"; close(FO); ($tns, $pics); } sub DoFiles { local($dir)=shift; @files=sort(`cd $dir;find . ! -name "*.htm*" -type f -print`); chomp(@files); @pics=grep(!/TN_/, @files); @thumb=grep(/TN_/, @files); $pics=scalar(@pics); $thumb=scalar(@thumb); if (($pics-$thumb)!=0) { printf "%30s pics:%3d thumb:%3d diff:%3d\n", $d, $pics, $thumb, $pics-$thumb; } else { printf "%30s pics:%3d thumb:%3d\n", $d, $pics, $thumb; } print FO "\n"; print FO "\n"; print FO "\t\n"; print FO "\t\n"; print FO "\n"; print FO "\n"; print FO "\t\n"; #print FO "\t\n"; #print FO "\t\n"; #print FO "\t\n"; print FO "\n"; #print FO "\t\n"; #print FO "\t\n"; #print FO "\t\n"; #print FO "\t\n"; #print FO "\t\n"; foreach $f (@pics) { #prep filename for use $f =~ s/\.\///g; #create useful dir/filename $fname="$dir/$f"; #get stat info for file ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($fname); #get imagefile info $oy = image_info($fname); print "$fname\n"; $width=$oy->{"width"}; $height=$oy->{"height"}; $ext=$oy->{"file_ext"}; $media=$oy->{"file_media_type"}; $colortype=$oy->{"color_type"}; $samplesperpixel=$oy->{"SamplesPerPixel"}; $bps=$oy->{"BitsPerSample"}; #file thumbnail file that corresponds to the image we are working on @tnFile=grep(/$f/, @thumb); $numtnfiles=scalar(@tnFile); #a little counting to checl shit out inc_array("thumbnail", $tnFile[0]); inc_array("picture", $f); #spit out something to keep the user interested print "\n\n--File: $f - $tnFile[0] - $numtnfiles\n"; print "\t$size - $width x $height - $ext - $media - $colortype - $samplesperpixel - $bps->[0], $bps->[1], $bps->[2], $bps->[3]\n"; #build row with thumbnail and image data print FO "\n"; print FO "\t\n"; printf FO "\t\n", $size/1024; #print FO "\t\n"; #print FO "\t\n"; #print FO "\t\n"; #print FO "\t\n"; #print FO "\t\n"; print FO "\n"; } print FO "
ThumbnailImage Attributes
Filesize (kB)DimensionsFileExtMedia Type
$width x $height$ext$media$colortype$samplesperpixel - $bps->[0] $bps->[1] $bps->[2] $bps->[3]

$f
%7.2f$width x $height$ext$media$colortype$samplesperpixel - $bps->[0] $bps->[1] $bps->[2] $bps->[3]
\n"; ($thumb, $pics); }