Subject: | Image::Info - the TIFF testsuite may fail due to endianess problems |
Tels,
Several TIFF tests fail if
tiff_image_endianess != machine_endianess
More detailed info:
* Every image file directory entry is exactly 12 bytes:
tag[2] + type[2] + count[4] + value_offset[4])
* most of the times the value offset is a valid file offset (4 bytes)
but if the size of the information is <= 4 it is stored directly
in the value_offset field.
* as several values of the tiff image are short integers (2 bytes)
and by the standard they must be always stored in the lower bytes
of the above field (the TIFF.pm code always assumes it has 4 bytes
and if the image endianess doesn't match the system one we have
problems - the wrong bytes will be used).
The patch attached removes the excess bytes.
/jpo
Subject: | Image-Info-1.20-lib-Image-Info-TIFF.pm.patch |
--- Image-Info-1.20-beta/lib/Image/Info/TIFF.pm 2006-03-05 09:10:51.000000000 +0000
+++ Image-Info-1.20/lib/Image/Info/TIFF.pm 2006-03-11 21:29:24.000000000 +0000
@@ -135,7 +135,13 @@
my $val;
## The 4 bytes of $value_offset may actually contains the value itself,
## if it fits into 4 bytes.
- if ($typelen * $count <= 4) {
+ my $len = $typelen * $count;
+ if ($len <= 4) {
+ if (($byteorder ne $Config{byteorder}) && ($len != 4)) {
+ my @bytes = unpack("C4", $value_offset_orig);
+ for (my $i=0; $i < 4 - $len; $i++) { shift @bytes; }
+ $value_offset_orig = pack("C$len", @bytes);
+ }
@$val = unpack($typepack x $count, $value_offset_orig);
} elsif ($fieldtype == 5 || $fieldtype == 10) {
## Rationals