mellin
02-28-2003, 02:04 AM
I was reading the ImageMagic.org website, and tried to make a sample script to automatically resize pictures, from given folder. Then to save those resized pictures to another directory, thus saving me from the work to make thumbnails each time i add a new picture to my site.
Anyway, it really wasn't that simple. Once i started to wrote the script, i didn't anymore understand anything i just read!
This is where i got, actually nowhere but..
-----------------------------------------------------------------------
#!/usr/bin/perl
use CGI;
use Image::Magick;
$query = new CGI;
@imgdir = ("sarah.jpg", "eliza.jpg", "alyson.jpg", "charisma.jpg", "amber.jpg");
$cgi-dir = "/var/www/cgi-bin";
$cgi-lib.pl = "cgi-lib.pl";
$variables.lib = "variables.lib";
require "$cgi-dir/$cgi-lib.pl";
require "$cgi-dir/$variables.lib";
what_to_do();
what_to_do {
build_page() if $q eq "";
show_the_image() if $img;
}
sub build_page {
for (@imgdir) {
$image = Image::Magick->new;
open (IMAGE, "$_")|| &error;
$image->Read(file=>\*IMAGE);
close (IMAGE);
}
}
sub show_the_image {
}
sub error {
print "<p>$error</p>";
}
-----------------------------------------------------------------------
How do i actually tell the imagemagic, what image to resize, what name to use to that new image, and most importantly, what size to resize it to?
Once i understand how to open an image, resize it, save it, i'll be where i want. I think.
Anyway, it really wasn't that simple. Once i started to wrote the script, i didn't anymore understand anything i just read!
This is where i got, actually nowhere but..
-----------------------------------------------------------------------
#!/usr/bin/perl
use CGI;
use Image::Magick;
$query = new CGI;
@imgdir = ("sarah.jpg", "eliza.jpg", "alyson.jpg", "charisma.jpg", "amber.jpg");
$cgi-dir = "/var/www/cgi-bin";
$cgi-lib.pl = "cgi-lib.pl";
$variables.lib = "variables.lib";
require "$cgi-dir/$cgi-lib.pl";
require "$cgi-dir/$variables.lib";
what_to_do();
what_to_do {
build_page() if $q eq "";
show_the_image() if $img;
}
sub build_page {
for (@imgdir) {
$image = Image::Magick->new;
open (IMAGE, "$_")|| &error;
$image->Read(file=>\*IMAGE);
close (IMAGE);
}
}
sub show_the_image {
}
sub error {
print "<p>$error</p>";
}
-----------------------------------------------------------------------
How do i actually tell the imagemagic, what image to resize, what name to use to that new image, and most importantly, what size to resize it to?
Once i understand how to open an image, resize it, save it, i'll be where i want. I think.