Re: [greenstone-users] ImagePlug (size unknown)

From Michael Dewsnip
DateThu, 07 Aug 2003 10:54:48 +1200
Subject Re: [greenstone-users] ImagePlug (size unknown)
In-Reply-To (AFAC9B2BF1A8BF4886F5C0FDE428E90E0791EA1C-edumail2-education-tas-gov-au)
Hi Ben,

While I was getting ready for work this morning I realised I must have got
this wrong - it didn't make any sense to have two metadata values for the
image dimensions. So, it must have been the *file* size, which I didn't
look at.

This is a problem that must be caused by a change in recent versions of
identify. In old versions, file sizes were always displayed as whole
numbers (ie. 53kb, not 52.6kb). This meant that the code for parsing the
output of identify doesn't handle the 52.6kb case, so the metadata was left
as "unknown".

To fix this, you'll need to make another change to ImagePlug.pm. At around
line 330, there is this block of code:

# Read the size
my $size = "unknown";
if ($result =~ m/^.* ([0-9]+)b/) {
$size = $1;
} elsif ($result =~ m/^.* ([0-9]+)kb/) {
$size = 1024 * $1;
}

Change it to this:

# Read the size
my $size = "unknown";
if ($result =~ m/^.* ([0-9]+)b/) {
$size = $1;
}
elsif ($result =~ m/^.* ([0-9]+)(.([0-9]+))?kb/) {
$size = 1024 * $1;
if (defined($2)) {
$size = $size + (1024 * $2);
# Truncate size (it isn't going to be very accurate anyway)
$size = int($size);
}
}

This should fix your problem.

Regards,

Michael

"Dwyer, Benjamin J" wrote:

> I'm using JPEG as the file format. I did your test and it returned:
>
> JPEG 540x760+0+0 DirectClass 8-bit 52.6kb 0.000u 0:01 - Which is
> correct.
>
> I've also have [ImageHeight] and [ImageWidth] in my VList formatting and
> these work fine?!
>
> Ben
>
> -----Original Message-----
> From: Michael Dewsnip [mailto:mdewsnip@cs.waikato.ac.nz]
> Sent: Wednesday, 6 August 2003 11:59 AM
> To: Dwyer, Benjamin J
> Subject: Re: [greenstone-users] ImagePlug (size unknown)
>
> Hi Ben,
> What format are your images (GIF, JPEG, etc.)??
> This may be caused by the identify program (part of ImageMagick) being
> unable to understand the image, and therefore being unable to work out
> its dimensions. To test this, try running "identify <image-name>" on one
> of your images, from the command line.
> - Michael
>
>
> "Dwyer, Benjamin J" wrote:
> Hello,
> I'm having problems when trying to display the size of my images in my
> image collection.
> I have followed the example of the 'simple image collection' that
> contains images of planes.
> The configuration file shows the formatting for the Vlist to be:
> ".......<br>Size: [ImageSize]</td>"
> I have used the same syntax in my configuration file an the collection
> displays: Size: unknown
> Is this a bug or am I doing something wrong?
> Regards,
> Ben Dwyer
> _______________________________________________
> greenstone-users mailing list
> greenstone-users@list.scms.waikato.ac.nz
> https://list.scms.waikato.ac.nz/mailman/listinfo/greenstone-users