Re: Creating thumbnails (Newbie Question)...

2002-09-21 Thread Randal L. Schwartz

 Joel == Joel Hughes [EMAIL PROTECTED] writes:

Joel After you have install image magick, the basic syntax is...


Joel   use Image::Magick;
Joel   $p = new Image::Magick;
Joel   $p-Read(..your main image...);

Joel   $p-Scale(width=$required_width, height= $required_height);

Joel   $p-Write(..your scaled image...)

Joel your only trickyish part is keeping the projection right when
Joel you scale the image, however, for a start, the above code can
Joel get you going.

No, it's not tricky.  Unless you work really hard at it, your image
is always scaled in proportion, such that the width and the height
fit a maximum of the sizes listed above.  It's just (dare I say) magic!

Let me illusrate:  if an image is 75x150, and you ask for a 25x25 version,
you get a 12x25 version, which is the same proportions, but both
numbers are smaller than 25.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Creating thumbnails (Newbie Question)...

2002-09-20 Thread Joel Hughes

Alex,
the answer to this one is probably imagemagick. I have a small photos site
as well and use imagemagick to create all the other sizes from the master
image.

After you have install image magick, the basic syntax is...


use Image::Magick;
$p = new Image::Magick;
$p-Read(..your main image...);

$p-Scale(width=$required_width, height= $required_height);

$p-Write(..your scaled image...)

your only trickyish part is keeping the projection right when you scale the
image, however, for a start, the above code can get you going.

With my site I have an upload screen for images. Accepting images in this
screen causes the scaled images to be created - I have a couple of scaled
images for various purposes (web user monitor sizes etc).

best of luck

joel


-Original Message-
From: Yuen, Alex [mailto:[EMAIL PROTECTED]]
Sent: 18 September 2002 14:57
To: 'Perl Beginners - CGI'
Subject: Creating thumbnails (Newbie Question)...


Hi,

Very newbie.

I was wondering if it is possible to write a CGI (Perl) program to make a
thumbnail page for my website.

If so, how would I start and use for doing this?

Thanks.

Alex


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Creating thumbnails (Newbie Question)...

2002-09-19 Thread fliptop

On Wed, 18 Sep 2002 at 20:28, Octavian Rasnita opined:

OR:But is it a way, (maybe module?) that allow creating a thumbnail on the fly?
OR:
OR:For example:
OR:I want to put more big images in a folder and if someone visits my page,
OR:they will see a table with thumbnails created on the fly and inserted in the
OR:HTML page, and ... those thumbs made as links to the bigger pictures.
OR:
OR:The script should get the image, create a smaller one automaticly (with a
OR:lower size) and print it on the screen as image/jpg ... etc.
OR:
OR:Is it possible?

octavian - please remember to post your messages to the list so everyone 
can benefit from the questions and answers.

to answer your question - did you investigate the perl module i listed?  
it's called Image::Magick::Thumbnail, and it does exactly what you 
describe.  Please see below:

OR:- Original Message -
OR:From: fliptop [EMAIL PROTECTED]
OR:To: Yuen, Alex [EMAIL PROTECTED]
OR:Cc: 'Perl Beginners - CGI' [EMAIL PROTECTED]
OR:Sent: Wednesday, September 18, 2002 5:52 PM
OR:Subject: Re: Creating thumbnails (Newbie Question)...
OR:
OR:
OR:On Wed, 18 Sep 2002 at 09:56, Yuen, Alex opined:
OR:
OR:YA:I was wondering if it is possible to write a CGI (Perl) program to make a
OR:YA:thumbnail page for my website.
OR:YA:
OR:YA:If so, how would I start and use for doing this?
OR:
OR:if you question is how to create a thumbnail from a regular image, then
OR:you could use ImageMagick.
OR:
OR:http://www.imagemagick.org
OR:http://search.cpan.org/author/LGODDARD/Image-Magick-Thumbnail-0.01/
OR:


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Creating thumbnails (Newbie Question)...

2002-09-18 Thread Yuen, Alex

Hi,

Very newbie.

I was wondering if it is possible to write a CGI (Perl) program to make a
thumbnail page for my website.

If so, how would I start and use for doing this?

Thanks.

Alex


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Creating thumbnails (Newbie Question)...

2002-09-18 Thread fliptop

On Wed, 18 Sep 2002 at 09:56, Yuen, Alex opined:

YA:I was wondering if it is possible to write a CGI (Perl) program to make a
YA:thumbnail page for my website.
YA:
YA:If so, how would I start and use for doing this?

if you question is how to create a thumbnail from a regular image, then 
you could use ImageMagick.

http://www.imagemagick.org
http://search.cpan.org/author/LGODDARD/Image-Magick-Thumbnail-0.01/




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Creating thumbnails (Newbie Question)...

2002-09-18 Thread Yuen, Alex

One part is to create a thumbnail image from a regular image.

Second part is to create a web page or thumbnail page for viewing. Maybe 10
to 20 images per page.

Thanks.

Alex


 --
 From: fliptop[SMTP:[EMAIL PROTECTED]]
 Sent: Wednesday, September 18, 2002 10:52 AM
 To:   Yuen, Alex
 Cc:   'Perl Beginners - CGI'
 Subject:  Re: Creating thumbnails (Newbie Question)...
 
 On Wed, 18 Sep 2002 at 09:56, Yuen, Alex opined:
 
 YA:I was wondering if it is possible to write a CGI (Perl) program to make
 a
 YA:thumbnail page for my website.
 YA:
 YA:If so, how would I start and use for doing this?
 
 if you question is how to create a thumbnail from a regular image, then 
 you could use ImageMagick.
 
 http://www.imagemagick.org
 http://search.cpan.org/author/LGODDARD/Image-Magick-Thumbnail-0.01/
 
 
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Creating thumbnails (Newbie Question)...

2002-09-18 Thread Gary Stainburn

On Wednesday 18 Sep 2002 2:56 pm, Yuen, Alex wrote:
 Hi,

 Very newbie.

 I was wondering if it is possible to write a CGI (Perl) program to make a
 thumbnail page for my website.

 If so, how would I start and use for doing this?

 Thanks.

 Alex

Hi Alex,

Here's a script based on one I was given a while back.  This is a command-line 
one but should easily be convertable to a CGI.

#!/usr/bin/perl
use strict;

use Image::Magick;

my $im = Image::Magick-new;

umask 0022;

# if passed filenames use them, otherwise do all
my @names = @ARGV ? @ARGV : grep { -f and -B } *;

for (@names) {# foreach name
  if (/ /) {  # if name contains a space
my $old = $_;
tr, ,_,s; # change spaces to _
$_ .= .jpg unless /\.jpg$/; # append .jpg if missing
! -e and rename $old, $_ or next; # skip file if rename fails
warn renaming $old to $_\n;
  }
  next if /\.thumb\.jpg$/;# skip if this is thumbnail
  my $thumb = $_.thumb.jpg;
  next if -e $thumb;  # skip if thumbnail exists
  undef @$im; # reset (part of) $im
  my $ret;
  $ret = $im-Read($_)# read file 
and warn($ret), next; # or fail and skip
  $ret = $im-Scale(geometry = '100x100')
and warn($ret), next;
  $ret = $im-Write($thumb)
and warn($ret), next;
  warn thumbnail made for $_\n;
}


-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Creating thumbnails (Newbie Question)...

2002-09-18 Thread Wiggins d'Anconia

Second part:

Depends on how complex you want your thumbnail page to be (of course).

Simplest might be to store all your thumbnails to a directory, do an 
opendir, then while readdir, print your image tag changing only the file 
name in each case.

To complicate matters, you can use the same Image::Magick module to read 
the thumbnail to generate the width/height tags on the fly though I 
would say that is probably overkill.  As for handling pages/numbered to 
display on each page, and stepping between them you are probably going 
to have to pass a couple of variables to the script, such as where to 
start displaying and how many to display. Or you could go the simple 
route and hard code the number shown, in which case you could just pass 
a page variable, either way you then generate the urls on the fly 
referencing previous,next,first,last, etc. So many options, 
so little time.

http://danconia.org



Yuen, Alex wrote:
 One part is to create a thumbnail image from a regular image.
 
 Second part is to create a web page or thumbnail page for viewing. Maybe 10
 to 20 images per page.
 
 Thanks.
 
 Alex
 
 
 
--
From: fliptop[SMTP:[EMAIL PROTECTED]]
Sent: Wednesday, September 18, 2002 10:52 AM
To:   Yuen, Alex
Cc:   'Perl Beginners - CGI'
Subject:  Re: Creating thumbnails (Newbie Question)...

On Wed, 18 Sep 2002 at 09:56, Yuen, Alex opined:

YA:I was wondering if it is possible to write a CGI (Perl) program to make
a
YA:thumbnail page for my website.
YA:
YA:If so, how would I start and use for doing this?

if you question is how to create a thumbnail from a regular image, then 
you could use ImageMagick.

http://www.imagemagick.org
http://search.cpan.org/author/LGODDARD/Image-Magick-Thumbnail-0.01/



 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]