Web Analytics Made Easy -
StatCounter plAlbum.pl - CodingForum

Announcement

Collapse
No announcement yet.

plAlbum.pl

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • plAlbum.pl

    Advertisement URL removed
    Last edited by Feyd; Mar 15, 2004, 03:07 PM.
    Scripting | JavaScripts | PerlScripts | Python Scripts | Articles | My Journal

  • #2
    CodingForum Rules # 1.3) No advertisements - codingforum.net is not the classified ads. Do not post advertisements/ self promotion/ spam of any kind. Doing so will get you banned.

    This is clearly an advertisment, prem...and while I appreciate that you may just be offering something that you think others may find useful...it is unsolicited and thus an advertisement.
    Moderator, Perl/CGI Forum
    shadowstorm.net - subvert society

    Comment


    • #3
      Advertisement?? OMG. If I had to advertise, why would I post a link to the script directly; I would have posted a link to some of my other pages where I have ads (which, btw, I do not have on any pages). You should be more judicious when assessing posts.

      Anyway, since you think it is an advertisement, think so...it doesn't matter to me. I don't give a damn about people visiting my websites...I have a purpose, and I was trying to do a favor by posting the link. Come on; it was a direct link to the script. You know that, right?

      For the benefit of others, I'm posting the script here itself. Delete it if you think, I'm trying to advertise my website or something (the credits, of course, remains in the script, as is the case with most folks who code stuff)

      Code:
      #!/usr/bin/perl
      
      #######################################################
      ##	plAlbum.pl
      ##	- Simple Perl script to create an album
      ##	  of images from a given directory
      ##
      ##	(c) 2004 Premshree Pillai (08/03/04)
      ##	[url]http://www.qiksearch.com/[/url]
      #######################################################
      
      use strict;
      use warnings;
      
      my $count = 0;
      my $total_count = 0;
      my $curr_count = 0;
      my @files_temp = ();
      my @files = ();
      my $dirName = '';
      my $slideName = '';
      my $title = '';
      my $file = '';
      my $prev = '';
      my $pipe = '';
      my $next = '';
      
      sub getDir {
      	print "Enter the directory to read images from (rel/abs path): ";
      	$dirName = <STDIN>;
      	chomp $dirName;
      	if(!opendir(IMD, $dirName)) {
      		print "Directory does not exist!\n";
      		getDir();
      	} else {
      		chdir($dirName);
      		closedir(IMD);
      	}
      }
      
      getDir();
      
      sub len {
      	(my @arr) = @_;
      	my $length = @arr;
      	return $length;
      }
      
      sub retPrevFile {
      	(my $index) = @_;
      	if($index == 0) {
      		return "";
      	} else {
      		my $out = $slideName.$files[$count - 1].'.htm';
      		my $str = "« <a href=\"$out\">Previous</a>";
      		return $str;
      	}
      }
      
      sub retNextFile {
      	(my $index) = @_;
      	if($index == len(@files) - 1) {
      		return "";
      	} else {
      		my $out = $slideName.$files[$count + 1].'.htm';
      		my $str = "<a href=\"$out\">Next</a> »";
      		return $str;
      	}
      }
      
      sub retPipe {
      	(my $index) = @_;
      	if($index > 0 && $index < len(@files) - 1) {
      		return " | ";
      	} else {
      		return "";
      	}
      }
      
      sub getSlideName {
      	print "Enter base name for album: ";
      	$slideName = <STDIN>;
      	chomp $slideName;
      	chdir($dirName);
      	if(!mkdir($slideName)) {
      		print "Directory $slideName exists!\n";
      		getSlideName();
      	}
      }
      
      getSlideName();
      
      print "Enter a title for the album: ";
      $title = <STDIN>;
      chomp $title;
      
      chdir('..');
      opendir(IMD, $dirName) || die("Cannot open directory");
      @files_temp= readdir(IMD);
      @files = ();
      closedir(IMD);
      chdir($dirName);
      foreach (@files_temp) {
      	if(opendir(X,$_)) {
      		closedir(X);
      	} else {
      		$files[len(@files)] = $_;
      	}
      }
      
      chdir($dirName);
      chdir($slideName);
      
      $count = 0;
      foreach (@files) {
      	unless (($_ eq ".") || ($_ eq "..") || opendir(X,$_)) { 
      		$file = $slideName.$_.'.htm';
      		$curr_count = $count + 1;
      		$total_count = len(@files);
      		$prev = retPrevFile($count);
      		$next = retNextFile($count);
      		$pipe = retPipe($count);
      		open(DAT,">$file") || die("Cannot Open File");
      		print DAT <<EOM; 
      
      <html>
      			<head>
      				<title>$title</title>
      				<style type="text/css">
      					body	{font-family:Trebuchet MS, Arial, Verdana; font-size:10pt; font-weight:bold}
      					h4	{color:#CCCCCC}
      					a	{font-family:Trebuchet MS, Arial, Verdana; font-size:10pt; font-weight:bold; text-decoration:none}
      					a:hover	{font-family:Trebuchet MS, Arial, Verdana; font-size:10pt; font-weight:bold; text-decoration:underline}
      					img	{border:#000000 solid 1px}
      				</style>
      			</head>
      			<body>
      			<center><h2>$title</h2></center>
      			<center><h4>$file ($curr_count/$total_count)</h4></center>
      			<center><a href="../$_"><img src="../$_"></a></center>
      			<center>$prev$pipe$next</center>
      			</body>
      			</html>
      
      EOM
      		close(DAT);
      		$count++;
      		print "File $file created\n";
      	}
      }
      Scripting | JavaScripts | PerlScripts | Python Scripts | Articles | My Journal

      Comment

      Working...
      X