]> git.imager.perl.org - imager.git/commitdiff
- added tiff_bitspersample and tiff_photometric tags to tiff images
authorTony Cook <tony@develop=help.com>
Wed, 3 Aug 2005 06:34:18 +0000 (06:34 +0000)
committerTony Cook <tony@develop=help.com>
Wed, 3 Aug 2005 06:34:18 +0000 (06:34 +0000)
  when read

Changes
lib/Imager/Files.pod
t/t106tiff.t
tiff.c

diff --git a/Changes b/Changes
index e5d3f6bc5850ae7b2e121ca0fec6496ac57e6d5f..8ff5510b6dd3a3f05c7bece39599711f0d8d0dc4 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1116,6 +1116,8 @@ Revision history for Perl extension Imager.
 0.45_01
 - give the colorcount() and maxcolors() methods their own entries and
   add them to the method index.
+- added tiff_bitspersample and tiff_photometric tags to tiff images
+  when read
 
 =================================================================
 
index 32e99fd7494c1ec3ebab8ab2020e15ee3b8c2023..12ab284588fb9546df23f1572e6047490e596c52 100644 (file)
@@ -439,6 +439,16 @@ C<tiff_resolutionunit>.  Possible results include C<inch>,
 C<centimeter>, C<none> (the C<i_aspect_only> tag is also set reading
 these files) or C<unknown>.
 
+=item tiff_bitspersample
+
+Bits per sample from the image.  This value is not used when writing
+an image, it is only set on a read image.
+
+=item tiff_photometric
+
+Value of the PhotometricInterpretation tag from the image.  This value
+is not used when writing an image, it is only set on a read image.
+
 =item tiff_documentname
 
 =item tiff_imagedescription
index 3db8fc2ba1e6f8505001ae4e9ed85ed7490a9a68..984f3f82ad4ac0f5721887940e60f9c9696dd830 100644 (file)
@@ -1,7 +1,7 @@
 #!perl -w
 use strict;
 use lib 't';
-use Test::More tests => 77;
+use Test::More tests => 81;
 use Imager qw(:all);
 $^W=1; # warnings during command-line tests
 $|=1;  # give us some progress in the test harness
@@ -32,7 +32,7 @@ SKIP:
     $im = Imager->new(xsize=>2, ysize=>2);
     ok(!$im->write(file=>"testout/notiff.tif"), "should fail to write tiff");
     is($im->errstr, 'format not supported', "check no tiff message");
-    skip("no tiff support", 73);
+    skip("no tiff support", 77);
   }
 
   Imager::i_tags_add($img, "i_xres", 0, "300", 0);
@@ -65,6 +65,8 @@ SKIP:
   ok(abs($tags{i_yres} - 250) < 0.5, "i_yres in range");
   is($tags{tiff_resolutionunit}, 3, "tiff_resolutionunit");
   is($tags{tiff_software}, 't106tiff.t', "tiff_software");
+  is($tags{tiff_photometric}, 2, "tiff_photometric"); # PHOTOMETRIC_RGB is 2
+  is($tags{tiff_bitspersample}, 8, "tiff_bitspersample");
 
   $IO = Imager::io_new_bufchain();
   
@@ -119,6 +121,8 @@ SKIP:
   ok(!$tags{i_aspect_only}, "i_aspect_only");
   # resunit_inches
   is($tags{tiff_resolutionunit}, 2, "tiff_resolutionunit");
+  is($tags{tiff_bitspersample}, 1, "tiff_bitspersample");
+  is($tags{tiff_photometric}, 1, "tiff_photometric");
 
   ok($oofim->write(file=>'testout/t106_oo_fax.tiff', class=>'fax'),
      "write OO, faxable");
diff --git a/tiff.c b/tiff.c
index 692b00818a504647419265df63a53f08f5ace2ea..7cc5bf4cde4bf7d9f453235f13c3f5d48180d7a6 100644 (file)
--- a/tiff.c
+++ b/tiff.c
@@ -188,6 +188,10 @@ static i_img *read_one_tiff(TIFF *tif) {
 
   if (!im)
     return NULL;
+
+  /* general metadata */
+  i_tags_addn(&im->tags, "tiff_bitspersample", 0, bits_per_sample);
+  i_tags_addn(&im->tags, "tiff_photometric", 0, photometric);
     
   /* resolution tags */
   TIFFGetFieldDefaulted(tif, TIFFTAG_RESOLUTIONUNIT, &resunit);