cmp_ok($im->errstr, '=~', "format 'tiff' not supported", "check no tiff message");
ok(!grep($_ eq 'tiff', Imager->read_types), "check tiff not in read types");
ok(!grep($_ eq 'tiff', Imager->write_types), "check tiff not in write types");
- skip("no tiff support", 209);
+ skip("no tiff support", 207);
}
my $ver_string = Imager::i_tiff_libversion();
{ # reading tile based images
my $im = Imager->new;
- ok($im->read(file => 'testimg/pengtile.tif'), "read tiled image");
+ ok($im->read(file => 'testimg/pengtile.tif'), "read tiled image")
+ or print "# ", $im->errstr, "\n";
# compare it
my $comp = Imager->new;
ok($comp->read(file => 'testimg/penguin-base.ppm'), 'read comparison image');
ok(open(TIFF, '< testimg/pengtile.tif'), 'open pengtile.tif')
or skip 'cannot open testimg/pengtile.tif', 4;
- $cmp_ver ge '0030057'
+ $cmp_ver ge '003005007'
or skip("Your ancient tifflib has bad error handling", 4);
binmode TIFF;
my $data = do { local $/; <TIFF>; };
# patch a tile offset
- substr($data, 0x5AFE, 4) = pack("H*", "1F5C0000");
+ substr($data, 0x1AFA0, 4) = pack("H*", "00000200");
#open PIPE, "| bytedump -a | less" or die;
#print PIPE $data;
my $data;
ok($orig->write(data => \$data, type => 'tiff',
tiff_compression=> $compress),
- "write 8 bit");
+ "write 8 bit")
+ or print "# ", $orig->errstr, "\n";
my $im = Imager->new;
ok($im->read(data => $data), "read it back");
is_image($im, $orig, "check read data matches");
/* needed to implement our substitute TIFFIsCODECConfigured */
#if TIFFLIB_VERSION < 20031121
-#include "tiffconf.h"
static int TIFFIsCODECConfigured(uint16 scheme);
#endif
static const int compress_value_count =
sizeof(compress_values) / sizeof(*compress_values);
+static int
+myTIFFIsCODECConfigured(uint16 scheme);
+
typedef struct read_state_tag read_state_t;
/* the setup function creates the image object, allocates the line buffer */
typedef int (*read_setup_t)(read_state_t *state);
&& im->tags.tags[entry].data) {
uint16 compress;
if (find_compression(im->tags.tags[entry].data, &compress)
- && TIFFIsCODECConfigured(compress))
+ && myTIFFIsCODECConfigured(compress))
return compress;
}
if (i_tags_get_int(&im->tags, "tiff_compression", 0, &value)) {
if ((uint16)value == value
- && TIFFIsCODECConfigured((uint16)value))
+ && myTIFFIsCODECConfigured((uint16)value))
return (uint16)value;
}
if (!find_compression(name, &compress))
return 0;
- return TIFFIsCODECConfigured(compress);
+ return myTIFFIsCODECConfigured(compress);
}
static int
Older versions of tifflib we support don't define this, so define it
ourselves.
+ If you want this detection to do anything useful, use a newer
+ release of tifflib.
+
*/
#if TIFFLIB_VERSION < 20031121
-int TIFFIsCODECConfigured(uint16 scheme) {
+int
+TIFFIsCODECConfigured(uint16 scheme) {
switch (scheme) {
+ /* these schemes are all shipped with tifflib */
case COMPRESSION_NONE:
-#if PACKBITS_SUPPORT
case COMPRESSION_PACKBITS:
-#endif
-
-#if CCITT_SUPPORT
case COMPRESSION_CCITTRLE:
case COMPRESSION_CCITTRLEW:
case COMPRESSION_CCITTFAX3:
case COMPRESSION_CCITTFAX4:
-#endif
+ return 1;
-#if JPEG_SUPPORT
+ /* these require external library support */
+ default:
case COMPRESSION_JPEG:
-#endif
-
-#if LZW_SUPPORT
case COMPRESSION_LZW:
-#endif
-
-#if ZIP_SUPPORT
case COMPRESSION_DEFLATE:
case COMPRESSION_ADOBE_DEFLATE:
-#endif
- return 1;
-
- default:
return 0;
}
}
#endif
+static int
+myTIFFIsCODECConfigured(uint16 scheme) {
+#if TIFFLIB_VERSION < 20040724
+ if (scheme == COMPRESSION_LZW)
+ return 0;
+#endif
+
+ return TIFFIsCODECConfigured(scheme);
+}
+
/*
=back