Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks!

I an application that prints STDOUT like so:

work
computer:/tmp/image12.png
desk:/tmp/image102.png
lab:/tmp/image1122.png
home
laptop:/tmp/image162.png
bed:/tmp/image182.png
smokingroom:/tmp/image1012.png
gym
bench:/tmp/image1562.png
press:/tmp/image127.png
sauna:/tmp/image192.png
steam:/tmp/image12112.png
car
gps:/tmp/image12345.png
tires:/tmp/image11232.png
trunk:/tmp/image167662.png
door:/tmp/image129.png
bumper:/tmp/image172.png<br

That I would like to print to a web page. I would like to have a header (i.e. The lines with no : in them) and the 3, 4, 5, or six lines that follow (for each section) as thumbnails (all on one line from right to left.

Here is what I have (and not quite doing the trick).

thanks

foreach $tmp_file (@fileList){ my @tmp_array; chomp $tmp_file; @tmp_array=split(/:/, $tmp_file); $devgroup=$tmp_array[0]; if ($tmp_array[1] eq ""){ print $query->h3("Device group $devgroup"), $query->p, $query->hr; } else { print $query->img({-src=>$tmp_array[1], -align=>'center', -width=>'750', -height=>'625'}), $query->br; } }
Joseph

Replies are listed 'Best First'.
Re: thumbnail images from an array
by hardburn (Abbot) on Nov 03, 2003 at 17:41 UTC

    And what happens, exactly, when you run that code?

    I bet /tmp isn't in your web server's environment.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

      ha! I'll bet you're right
      Thanks!
      BTW, Is there a standard size to make thumbnails? I can adjustthe size, nut wanted to make sure the code looks ok.
      thanks, Joseph
      How do I make an image "clickable for enlaregment?" My images are all there now, 'cept they aren't clickable.
      thanks, Joseph

        Not really a Perl question, but... place your IMG tags inside of A (anchor) tags that have an HREF to your full-size image.

        Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"
Re: thumbnail images from an array
by zentara (Cardinal) on Nov 04, 2003 at 17:01 UTC
    Don't forget that if you don't actually make the thumbnails, and use them as clickable links to the real photos, it will causes delays as all the full size photos are downloaded just to show the thumbnails. Making thumbnails, by setting a lower size in the html code is not a good way. Thumbnails for a whole directory can be easily made:
    #!/usr/bin/perl use strict; use Image::Magick; my $im = Image::Magick->new; umask 0022; my @names = @ARGV ? @ARGV : grep { -f and -B } <*>; for (@names) { if (/ /) { my $old = $_; tr, ,_,s; $_ .= ".jpg" unless /\.jpg$/; !-e and rename $old, $_ or next; warn "renaming $old to $_\n"; } next if /\.thumb\.jpg$/; my $thumb = "$_.thumb.jpg"; next if -e $thumb; undef @$im; my $ret; $ret = $im->Read($_) and warn($ret), next; $ret = $im->Scale( geometry => '100x100' ) and warn($ret), next; $ret = $im->Write($thumb) and warn($ret), next; warn "thumbnail made for $_\n"; }