LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-07-2004, 05:37 PM   #46
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61

Not to beat an old topic to death but I have found that montage handles this much better. I haven't figured out how to get the individual slides combined into one picture on the html page but at least it's only making one png file and there aren't any gifs bouncing all over the page .

$name2 =~ s/\.\w{3}$/_THUMB\.png/;

system(`montage $name1 -geometry '100x100' $name2`);

Code:
#!/usr/bin/perl
# use the command: perl images.pl > index.html
# Set up in rows of 4 pics so you need an amount
# of pics that is evenly divided by 4


use strict; # enforce variable declarations and quoting

mkdir "thumbs", 0777 unless -d "thumbs";

my $i;
my $j;
my $new_row = 0;
my @name=sort(`ls *.jpg *.gif *.png`) ;
my $name1;
my $name2;

if ( (scalar @name)%4 !=0) {
   print "Wrong number of pics in directory, quitting!\n";
   exit;
}

print <<HEADER_EOF;
<!-- \/ starthtml -->
<html>

<body bgcolor="#FFFFFF" text="#000000" link="#FFFFFF" vlink="#FFFFFF">

<table align=\"center\" width=\"80%\" border="1" cellpadding="5" cellspacing="2">
HEADER_EOF

for($i=0; $i < (scalar @name) ; $i=$i+4){
    print "<tr align=\"center\">\n";
    for( $j=0; $j<4 ; $j++){
        chomp( $name[$i+$j] );
        $name1 = $name[$i+$j];
        $name2 = $name[$i+$j];
	$name2 =~ s/\.\w{3}$/_THUMB\.png/;

#        system(`convert $name1 -geometry '100x100' $name2`);

	system(`montage $name1 -geometry '100x100' $name2`);

	system(`mv $name2 ./thumbs/`);
        print "<td align=\"center\"><a href=\"$name1\"><img src=\"./thumbs/$name2\"></a><div>$name1</div></td>\n";

    }
    print "</tr>\n";
}


print <<FOOTER_EOF;
</td></tr></table>

</body>
</html>
FOOTER_EOF
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Does anyone know of a bash script can search & replace txt in a file. jimwelc Linux - Newbie 6 09-15-2008 12:13 AM
Help! Script or commanded needed to replace text in a file farmerjoe Programming 3 01-02-2005 05:59 PM
help! Script or command needed to replace text in a file. farmerjoe Linux - Newbie 2 01-02-2005 03:07 PM
Search and replace text in file using shell script? matthurne Linux - Software 2 11-02-2004 10:11 AM
trying to search and replace text file for single & multiple line breaks separately brokenfeet Programming 7 08-29-2003 01:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration