#!/usr/bin/perl -w #----------------------------------------------------------- # Name: # DIOW: Digital Images On the Web # # Purpose: # scan a directory with jp(e)g and or gif (upper or # lower cases filenames ) images: create icons and # create an index.html file for on line publication # with icons on screen and links to original images. # Useful when you have too many digital images and # you do not have enough time to create web pages # # Requirements: # uses PERL and the convert program: best is running Linux # # Optional Keywords: # -o : means Output: name of the output HTML filename # -t : means Title : title of the web page # -c : means columnnumber: number of columns # -icon: means iconsize # -annotate: means Annotate: string to be written on the lower right corner of each image # # Examples: # chmod 755 diow.pl # ln -s diow.pl diow # diow # diow -t 'My Images From Versailles, Sept-2000' # diow -o versailles.html # diow -o versailles.html -t 'My Images From Versailles, Aug-2000' # diow -o versailles.html -t 'My Images From Versailles, Aug-2000' -c 5 -ico 40 # diow -o versailles.html -t 'My Images From Versailles, Aug-2000' -c 5 -ico 40 -annotate 'Versailles Aug-2000' # # Informations: # http://mips.as.arizona.edu/~hdole/diow/ # http://wwwfirback.ias.u-psud.fr/users/dole/diow/ # Herve Dole # # Modification History: # ??-Original program: hj.pl by Matthew Kenworthy, UoA # 01-Aug-2000 This version Written by Herve Dole, IAS Orsay # 02-Aug-2000 add -o and -t HD, IAS # 11-Aug-2000 add version and array with legend v1.2 HD, IAS # 11-Aug-2000 add nice keywords processing v1.3 HD, IAS # 17-Aug-2000 add $iconsize HD, IAS v1.4 # 23-Aug-2000 add -column -ico v1.5 HD, IAS # 23-Aug-2000 bug corrected with UPPERCASES and sorted files v1.6 HD, IAS # 18-Jan-2001 add gif files processing v1.7 HD, UoA # 03-Sep-2001 add -annotate string option + png files processing v1.8 HD, UoA # 10-Sep-2001 fixed bug when -annotate not used v1.8.1 HD, UoA # 16-Oct-2003 XHTML 1.0 tranistionnal complient HD v2.0 # 23-Feb-2006 changed geometry to size option in convert call for icons HD # 13-Aug-2006 changed size to resize option in convert HD v2.2 # #----------------------------------------------------------- $diow_version = '2.2'; # Welcome message #---------------- print("--------------------------------------------------------\n"); print(" DIOW v$diow_version: Digital Images On the Web (H. Dole)\n"); print("--------------------------------------------------------\n"); # Users's Data #------------- $myname= 'Put Your Name Here'; # my Name $myemail = 'username\@yourdomain'; # my Email $myurl = 'http://www.myurl'; # my URL $title = 'My Digital Images'; # default title of the page $outhtml = 'index.html'; # default output HTML filename $mytextcolor= '000000'; $mybgcolor = 'FFFFFF'; $mylinkcolor ='FFFF00'; # color for unvisited links $myvlinkcolor = 'FF00FF'; # color for visited link $barcolor = 'FF0000'; # background color for title bar $diowurl = 'http://lully.as.arizona.edu/~hdole/diow/'; # URL where you can download DIOW $nbrow = 4; # number of rows in the table $iconsize = 70; # size of icons $annotate_keyword=0; # annotate option $annotate_string=''; # annotate string $annotate_font = 'helvetica'; # annotate font # helvetica $annotate_color_font='yellow';# annotate font color $annotate_size='20-20'; # annotate Font Size $annotate_color_box='blue';# annotate box color # test if there are keywords #--------------------------- #print(" $ARGV[0] \n"); for ($i=0; $i <= $#ARGV; $i++){ # -t 'title of the HTML page' #---------------------------- if ($ARGV[$i] =~ /^-t/) {$title = $ARGV[$i +1]; } # -o output.html #--------------- elsif ($ARGV[$i] =~ /^-o/) {$outhtml=$ARGV[$i +1]; } # -c 5: integer: number of rows #------------------------------ elsif ($ARGV[$i] =~ /^-c/) {$nbrow=$ARGV[$i +1]; } # -icon 70: integer: size of icons #------------------------------ elsif ($ARGV[$i] =~ /^-icon/) {$iconsize=$ARGV[$i +1]; } # -annotate 'My Name': string: annotation in the Images #------------------------------------------------------ elsif ($ARGV[$i] =~ /^-anno/) {$annotate_string=$ARGV[$i +1]; $annotate_keyword=1; } } # Print Some Argumenst to Check print(" title : $title \n"); print(" output: $outhtml \n"); print(" nb rows: $nbrow \n"); print(" icon size: $iconsize \n"); if ($annotate_keyword==1) { print(" annotate: $annotate_string \n"); print(" ann. font size: $annotate_size \n"); } print("-------------------------\n"); #first get a listing of the current directory, warts and all opendir THISDIR, "." or die "Whoa! Current directory cannot be opened.."; # the regexp looks for either .jpg or .jpeg at the end of a filename. # () means group it together, \. is an escaped period, e? means 0 or 1 # occurences of the letter e and $ means look for it at the end of the # filename # the i appended after the slash means ignore the case. # Look for jpg and gif and png files #@allfiles_raw1 = grep /(\.jpe?g)$/i, readdir THISDIR; Only jpg #@allfiles_raw = grep /(\.jpe?g)$/i||/(\.gif)$/i, readdir THISDIR; Only jpg+gif @allfiles_raw = grep /(\.jpe?g)$/i||/(\.gif)$/i||/(\.png)$/i, readdir THISDIR; closedir THISDIR; # Sort files #----------- @allfiles = sort @allfiles_raw ; open(HTMLFILE,">$outhtml") or die "Can't open $outhtml for writing"; print HTMLFILE ""; print HTMLFILE ""; print HTMLFILE "\n"; print HTMLFILE "
\n"; print HTMLFILE "\n";
print HTMLFILE " $title \n"; print HTMLFILE " | \n";
print HTMLFILE "
\n"; $d=`date +'%a %d-%b-%Y %H:%M'`; print HTMLFILE "Created: $d \n"; print HTMLFILE " | \n"; # Add informations: my URL #------------------------- print HTMLFILE "$myname 's page\n"; print HTMLFILE " |
\n"; print HTMLFILE "using DIOW $diow_version, the \"Digital Images On the Web\" PERL script\n "; print HTMLFILE " | \n"; print HTMLFILE "email\n"; print HTMLFILE " |
\n"; print HTMLFILE "\n"; print HTMLFILE "\"Valid XHTML 1.0\!\"\n"; print HTMLFILE "\n"; print HTMLFILE "
\n"; print HTMLFILE "\n"; print HTMLFILE "\n"; close(HTMLFILE) or die "Can't close $outhtml. Sorry."; # Bye message #------------ print(" DIOW: run OK. Bye.\n"); print("--------------------------------------------------------\n");