commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Lucas" <gwlu...@sonalysts.com>
Subject [Sanselan] Question about and proposed change for writing metadata (EXIF) tag to TIFF files
Date Sun, 25 Sep 2011 03:18:19 GMT
I've been trying to implement code to write GeoTIFF tags to TIFF files.   I was unable to find
any code examples or documentation for this operation, but after digging through the code,
it looks like the TiffImageWriterLossy and TiffImageWriterLossless classes may be the place
to do this.  TiffImageWriterLossy gets invoked by the Sanselan.writeImage method.   

First off, before I get in to this, it appears to me that the use of the terms Lossy and Lossless
is a little unusual (since it has nothing to do with data compression or signal processing)
in that Lossy means that it overwrites any existing files and data, Lossless means that it
preserves existing data (making small but important adjustments to internal offset values).
   Is this a correct interpretation?

Now, as far as I can tell, the TiffImageWriterLossless is supposed to allow an application
to add EXIF tags to a TIFF file after it is initially written.  TiffImageWriterLossless is
invoked from the ExifRewriter class and apparently it operates by making a copy of an existing
file and adding additionally EXIF tags to the file.   The puzzling thing here is that although
ExifRewriter includes references to TiffImageWriterLossless, ExifRewriter is actually in a
package called "jpegRewrite".    Furthermore, in many, many attempts to get the ExifRewriter
to write to TIFF files, it appears to not work on TIFF files (it consistently throws exceptions
warning that the file header is not a valid JPEG header).

So my questions are as follows.   Is the ExifRewriter intended to work on TIFF files?  I have
studied the TIFF file format, but don't know much about JPEG.  If they were structurally similar,
I guess that the ExifRewriter in the jpegRewrite package might be intended to do double duty
for different formats.   But it doesn't look like that's how it works. If ExifWriter really
can't write TIFF files, is there any way to write application-defined tags to TIFF files?

Anyway, I would like to propose a change to Sanselan based on something I've done strictly
for my own work.  I'd like to see if folks with more experience with the code base than I
have would think it a good idea.  What I did was to change the TiffImageWriterBase class (the
parent of TiffImageWriterLossy) to add another variation of the writeImage method.  The new
method takes an array list of TiffOutputFields, and when it writes the initial TIFF Image
File Directory (represented by the TiffOuputDirectory class) it adds the application-defined
tags to the output.   Thus, the output TIFF file with custom EXIF tags only needs to be written
once and only includes one directory. 

Does anyone have comments on whether this is a good idea or not?

Gary


P.S.  One last question.  I notice that Java generics are not used in Sanselan.  I even found
a comment in the code where the author apologized for using methods from the Java 1.5 API.
  Is there a coding standard that restricts the use of language elements in Sanselan?    

---
Gary W. Lucas, Senior Software Engineer
Sonalysts, Inc
215 Parkway North
Waterford, CT 06320
(860) 326-3682
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message