2006.11.24 10:23 "[Tiff] Windows HD Photo - any interest?", by Brad Hards

2006.11.24 10:23 "[Tiff] Windows HD Photo - any interest?", by Brad Hards

Not sure if this has been discussed before, but Windows Vista comes with a new image format (previously known as Windows Media Photo, now called HD Photo).

Turns out it is really a TIFF-like format, with a unique codec and some special tags. The tags are described in one specification, known as the Feature specification. The codec is described in a different spec, known as the bitstream specification. They are both embedded in a Device Porting Kit (DPK), which you can find at: http://www.microsoft.com/whdc/xps/hdphotodpk.mspx [I used cabextract to get out the content, and then rebuilt the directory structure based on the DPK specification, which is also in the kit]

I see three options:

  1. Ignore this pseudo TIFF format.
  2. Incorporate the format using the codec in the DPK
  3. Incorporate the format using an independent implementation.

Anyway, I've done a bit of work on this. See attached. This isn't meant to be applied - it is just a start for future work on options 2 or 3, if anyone wants to work on it.

Brad

? hdphoto-2006-11-24.patch
? contrib/dbs/xtiff/.deps
? contrib/dbs/xtiff/.libs
? contrib/dbs/xtiff/xtiff
Index: libtiff/tif_open.c

=================================================================== RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_open.c,v retrieving revision 1.33

diff -u -r1.33 tif_open.c

--- libtiff/tif_open.c  8 Jun 2006 14:27:17 -0000       1.33

+++ libtiff/tif_open.c 24 Nov 2006 10:04:34 -0000
@@ -399,9 +399,10 @@
                           "by this version of libtiff." );
                goto bad;
        }

-       if (tif->tif_header.tiff_version != TIFF_VERSION) {
+       if ( (tif->tif_header.tiff_version != TIFF_VERSION) &&

+ (tif->tif_header.tiff_version != HDP_VERSION) ) {
                TIFFErrorExt(tif->tif_clientdata, name,
- "Not a TIFF file, bad version number %d (0x%x)",
+ "Not a TIFF or HD Photo file, bad version number %d (0x%x)",
                    tif->tif_header.tiff_version,
                    tif->tif_header.tiff_version);
                goto bad;
Index: libtiff/tiff.h

=================================================================== RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tiff.h,v retrieving revision 1.43

diff -u -r1.43 tiff.h

--- libtiff/tiff.h      5 Oct 2006 15:20:40 -0000       1.43
+++ libtiff/tiff.h      24 Nov 2006 10:04:35 -0000

@@ -47,6 +47,7 @@
  */

 #define        TIFF_VERSION            42
 #define TIFF_BIGTIFF_VERSION    43
+#define HDP_VERSION             0xbc

 #define        TIFF_BIGENDIAN          0x4d4d
 #define        TIFF_LITTLEENDIAN       0x4949
@@ -427,6 +428,24 @@
 /* tag 34929 is a private tag registered to FedEx */
 #define        TIFFTAG_FEDEX_EDR               34929   /* unknown use */
 #define TIFFTAG_INTEROPERABILITYIFD    40965   /* Pointer to Interoperability private directory */
+
+/* HD Photo tags (the specification previously known as Windows Media Photo */
+#define HDPTAG_PIXELFORMAT              48129   /* Pixel encoding format */
+#define HDPTAG_TRANSFORMATION           48130
+#define HDPTAG_UNCOMPRESSED             48131
+#define HDPTAG_IMAGETYPE                48132
+#define HDPTAG_IMAGEWIDTH               48256
+#define HDPTAG_IMAGEHEIGHT              48257
+#define HDPTAG_WIDTHRESOLUTION          48258
+#define HDPTAG_HEIGHTRESOLUTION         48259
+#define HDPTAG_IMAGEOFFSET              48320
+#define HDPTAG_IMAGEBYTECOUNT           48321
+#define HDPTAG_ALPHAOFFSET              48322
+#define HDPTAG_ALPHABYTECOUNT           48323
+#define HDPTAG_IMAGEDATADISCARD         48324
+#define HDPTAG_ALPHADATDISCARD          48325
+/* also see 59935 below */
+
 /* Adobe Digital Negative (DNG) format tags */
 #define TIFFTAG_DNGVERSION             50706   /* &DNG version number */
 #define TIFFTAG_DNGBACKWARDVERSION     50707   /* &DNG compatibility version */
@@ -508,6 +527,8 @@
                                                   into ICC profile space */
 #define TIFFTAG_CURRENTICCPROFILE      50833   /* & */
 #define TIFFTAG_CURRENTPREPROFILEMATRIX        50834   /* & */
+/* 59942 is a padding tag used by Microsoft's HD Photo format */
+#define HDPTAG_PADDING                  59932
 /* tag 65535 is an undefined tag used by Eastman Kodak */
 #define TIFFTAG_DCSHUESHIFTVALUES       65535   /* hue shift correction data */

@@ -642,6 +663,7 @@

 #define EXIFTAG_GAINCONTROL            41991   /* Gain control */
 #define EXIFTAG_IMAGEUNIQUEID          42016   /* Unique image ID */

+
 #endif /* _TIFF_ */

 /* vim: set ts=8 sts=8 sw=8 noet: */
Index: tools/tiffdump.c

=================================================================== RCS file: /cvs/maptools/cvsroot/libtiff/tools/tiffdump.c,v retrieving revision 1.13

diff -u -r1.13 tiffdump.c

--- tools/tiffdump.c    21 Nov 2005 03:35:06 -0000      1.13
+++ tools/tiffdump.c    24 Nov 2006 10:04:35 -0000

@@