I think you should be making your thumbnails, locally, then uploading them. You probably don't even need to upload the big full images, unless you want people to get the full resolution photo's. Here is a sub to do a directory of Images and make an html table of the thumbnails.

You can also make lower resolution versions of the main image, for easier downloads, but I'll leave that to you. All you need to do is make a second "thumbnail" of larger size (whatever you want then to download) A 4 meg full-resolution photo may be 1800x1200, but you can downsize it to a 800x600 jpeg, and it will only be about 100k.

It can all be done in 1 step, with the upload included, via lwp and a cgi script on your server.

#!/usr/bin/perl use warnings; use strict; use Image::Magick; #watch the width of your picture names #they can widen the table cells if too long umask 0022; my $image = Image::Magick->new; my $count = 0; open(OUT,">thumbs.html"); print OUT<<End_Header; <html> <body> <table align=left bgcolor=9999CC border=2 cellpadding=2 cellspacing=2> <tr> End_Header my @pics= <*.jpg>; foreach my $pic (@pics){ $count++; my ($picbasename) = $pic =~ /^(.*).jpg$/; my $ok; $ok = $image->Read($pic) and warn ($ok); my ($w,$h)= $image->Get('columns','height'); my $thumb = $picbasename . '-t.jpg'; $ok = $image->Scale(geometry => '100x100')and warn ($ok); $ok = $image->Write($thumb)and warn ($ok); my ($tw,$th)= $image->Get('columns','height'); my $picoptions= $w.'x'.$h.'x'.$tw.'x'.$th; print "$pic\t$picoptions\n"; undef @$image; print OUT qq(<td align=center><a href= $pic ><img alt= [$pic-thu +mbnail] src=$thumb height=$th width=$tw ></a><br>$pic</td>); if($count == 4){print OUT "</tr><tr>"; $count = 0}; } print OUT<<EOHTML; </tr> </table> </body> </html> EOHTML close OUT;

I'm not really a human, but I play one on earth. flash japh

In reply to Re: Image uploading and server-side resizing by zentara
in thread Image uploading and server-side resizing by ptum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.