[greenstone-users] Imagemagik and file sizes

From ak19@cs.waikato.ac.nz
DateWed Apr 9 16:56:07 2008
Subject [greenstone-users] Imagemagik and file sizes
In-Reply-To (58327-130-217-244-133-1207716770-squirrel-webmail-scms-waikato-ac-nz)
The following is sent to Greenstone-users without the attachment
ImagePlug.pm mentioned below. Instead, the modifications to ImagePlug.pm
are:
# Read the size
.......
elsif ($result =~ m/^.* (([0-9]+)(.([0-9]+))?e+([0-9]+))(kb|b)?/) {
# Deals with file sizes on Linux of type "3.4e+02kb" where e+02 is 1*10^2.
# 3.4e+02 therefore evaluates to 3.4 x 1 x 10^2 = 340kb.
# Programming languages including Perl know how that 3.4e+02 is a number,
# so we don't need to do any calculations.
$size = $1*1; # turn the string into a number by multiplying it by 1
#if we did $size = $1; $size would be merely the string "3.4e+02"
$size = int($size); # truncate size
}
.....

> Hello Diego,
>
> Thanks for your helpful discovery and for narrowing down where the
> solution needs to go. Following your suggestion, I have updated the
> ImagePlug.pm file and have attached it to this message. Could you try it
> out on that sample file photo1.jpg which you mentioned and tell me if it
> does what you want it to? If you can, then:
> - Make a copy of your ImagePlug.pm file so that you have a back-up
> - Save the attachment ImagePlug.pm in $GSDLHOME/perllib/plugins to be the
> one that Greenstone uses
> - Use it as before to confirm whether the size of your example image is
> now no longer "unknown" when running on Linux.
>
> Thank you again for helpful suggestion,
> Anupama
>
>
>> Hi List, just a simple question:
>>
>> Imagemagik has different behaviour in Windows and Linux that is
>> reflected
>> in
>> ImageSize extracted metadata.
>>
>> If you run "identify photo1.jpg" in Windows, Imagemagik gives the
>> following
>> info:
>>
>> photo1.jpg JPEG 2086x1399 2086x1399+0+0 DirectClass 8-bit 336.08kb
>> 0.234u
>> 0:01
>>
>>
>> So, [ImageSize] will be 344064 because ImagePlug multiply that value by
>> 1024.
>>
>>
>> If you run "identify photo1.jpg" in Linux, Imagemagik gives the
>> following
>> info:
>>
>> photo1.jpg JPEG 2086x1399 2086x1399+0+0 DirectClass 3.4e+02kb
>>
>> So, [ImageSize] will be "Unknown" because ImagePlug will try to multiply
>> 3.4e+02 by 1024. It is a problem of format. The solution will be to
>> change
>> ImagePlug where it has:
>>
>>
>> # 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);
>> }
>> }
>>
>> to something that check size notation and do the correct operations. I
>> think
>> it should be easy to somebody who knows Perl. Is there anybody that can
>> do
>> this?
>>
>> TIA
>>
>>
>>
>> Diego J. Spano
>> Direcci□n General de Gesti□n Inform□tica
>> Ministerio de Justicia, Seg. y DD. HH.
>> Tel.: 4328.3015 (int.1404)
>> 4322.6122 (directo)
>> Argentina
>> _______________________________________________
>> greenstone-users mailing list
>> greenstone-users@list.scms.waikato.ac.nz
>> https://list.scms.waikato.ac.nz/mailman/listinfo/greenstone-users
>>
>