Tuesday, March 11, 2008 1:43 PM
by
RickM
DNG is just TIFF with a little makeup (Part 1)
Lets say you had a TIFF 6.0 file and you wanted it to be recognized as a DNG (Adobe Digital Negative) for some particular reason. This seems like it should be trivially easy to do with the DotImage TiffFile framework.
As far as I knew, there were only two caveats:
The image must be in a 8 to 32 bit pixel format.
The image must use Lossless Jpeg, DCT Jpeg, or No Compression at all.
Once you have a file that meets those restrictions you need only add some tags and you should be done...
Orientation:
Int16 orientation = 1;
new TiffTag(TiffTagID.Orientation, orientation)
DNGVersion:
Byte[] dngVersion = { 1, 1, 0, 0 };
new TiffTag(50706, dngVersion, TiffTagDataType.Byte)
UniqueCameraModel:
string uniqueCameraModel = "Fake DNG";
new
TiffTag(50708, uniqueCameraModel, TiffTagDataType.Ascii)
ColorMatrix1 (only needed if the file is not monochrome):
Rational[] colorMatrix1 = {
new Rational(1,1), new Rational(0,1), new Rational(0,1),
new Rational(0,1), new Rational(1,1), new Rational(0,1),
new Rational(0,1), new Rational(0,1), new Rational(1,1)};
TiffTag colorMatrix1Tag = new TiffTag(50721, colorMatrix1, TiffTagDataType.SRational);
PhotometricInterpretation:
The DNG spec expects one of the following two values:
32803 = CFA (Color Filter Array) or 34892 = LinearRaw
TiffTag photometricInterpretationTag = td.Tags.LookupTag(TiffTagID.PhotometricInterpretation);
photometricInterpretationTag.Data = 34892;
At this point Photoshop CS3 is still not liking my DNG even though I have all of the "Required" tags. I ran into a post in the Adobe Forums which may help. My favorite excerpt:
"OK, so to summarize...
No one has a list of the DNG tags that are required. Anything with a default value isn't required (most of the time). Anything with default value "None" may or may not be required."
To Be Continued...