in reply to Image uploading and server-side resizing
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;
|
|---|