Package: libimage-imlib2-perl
Version: 1.12-1
Hello, I am trying to resize a load of images using a perl program. I
originally had this working using ubuntu dapper; it has now stopped
working since I installed feisty. I just tried uploading the images to
my test server, which runs debian etch, and the program still doesn't
work - it stops saying:
can't scale image at ../../charabanc-0.1/scripts/scale-panoramas.pl line 42
The program is pasted below. I am using the perl
wrapper to libimlib2, from the package libimage-imlib2-perl. The program
works by loading the image into a variable '$img', then using
'create_scaled_image' to generate scaled versions of the image at
several sizes. The text of the program is copied below. I have also
tried commenting
out the line which originally scaled the image and replaced it with the
simpler 'clone' function. Neither version works - i.e whichever line of
the two I comment out, the program dies when the original image (which
seems to load OK) is scaled or cloned.
Any help would be greatly appreciated, as this is holding me up with a
project I want to get finished. I have tried reinstalling both libimlib2
and libimage-imlib2-perl, but this doesn't help.
andy baxter.
#!/usr/bin/perl
#
# scale-panoramas.pl - scale a series of raw panorama files into various
resolutions for the virtual tour.
#
# This program expects to be run in a set directory which contains a
subdir 'raw' containing the raw panoramas (each in its own subdir with
the same filename as the subdir but the '.tiff' extension).
# There should also be a subdir 'scaled' to put the scaled images into.
use strict;
use warnings;
use Image::Imlib2;
my $rawPanoDir="raw"; # directory with the raw panoramas in. The
subdirectories of this give the names of the scaled panoramas.
# each subdir has a file in it called '<subdirname>.tif' where
<subdirname> is the name of the subdirectory. This contains the raw
# panorama file.
my $scaledPanoDir="scaled"; # directory with the scaled panoramas in.
The names of the files are <panoname>-<resolution>.jpg,
# where <panoname> is the name of the panorama (taken from
subdirname above), and <resolution> is the vertical resolution
# of the scaled image.
my @resolutions=qw(100 140 200 280 400); # list of resolutions to scale
the panoramas to. These are the vertical heights in pixels.
my @qualities=qw(70 70 70 80 90); # list of jpeg qualities to use for
each of the above resolutions.
my $scaledFormat="jpeg"; # format to use for scaled images. (usually jpeg)
my $scaledExtn=".jpg"; # file extension ditto.
print "Reading directory names\n";
my $dirh;
opendir($dirh,$rawPanoDir);
my @subdirs=readdir($dirh);
foreach my $panoName (@subdirs) {
next if $panoName =~ /^\./;
print "Processing panorama: $panoName\n";
my $panoFile="${rawPanoDir}/${panoName}/${panoName}.tif";
print " opening file: $panoFile\n";
my $img=Image::Imlib2->load($panoFile) || die "Can't open
panorama file: $panoFile\n";
my ($width,$height)=($img->get_width,$img->get_height);
my [EMAIL PROTECTED];
for (my $res=0; $res<$numRes; $res++) {
print " scaling to $resolutions[$res] pixels high at
quality: $qualities[$res]\n";
my $newheight=$resolutions[$res];
my $newwidth=int($width*($newheight/$height));
print " new width=$newwidth, new height=$newheight\n";
#my $scaledImg=$img->clone() ||die;
my
$scaledImg=$img->create_scaled_image($newwidth,$newheight)|| die "can't
scale image";
print " img=$img, scaledImg=$scaledImg \n";
$scaledImg->set_quality($qualities[$res]);
$scaledImg->image_set_format($scaledFormat);
$scaledImg->save("${scaledPanoDir}/${panoName}-${newheight}${scaledExtn}")
|| die "can't save image";
}
}
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]