Changeset 3260
- Timestamp:
- 10/11/07 09:26:32 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/utils/TiffComment.java
r974 r3260 3 3 // 4 4 5 import loci.formats.RandomAccessStream;6 5 import loci.formats.TiffTools; 7 import java.util.Hashtable;8 6 9 7 /** Extracts the comment from the first IFD of the given TIFF file(s). */ … … 16 14 } 17 15 for (int i=0; i<args.length; i++) { 18 // read IFDs 19 RandomAccessStream in = new RandomAccessStream(args[i]); 20 Hashtable ifd = TiffTools.getFirstIFD(in); 21 in.close(); 22 23 // extract comment 24 Object o = TiffTools.getIFDValue(ifd, TiffTools.IMAGE_DESCRIPTION); 25 String comment = null; 26 if (o instanceof String) comment = (String) o; 27 else if (o instanceof String[]) { 28 String[] s = (String[]) o; 29 if (s.length > 0) comment = s[0]; 30 } 31 else if (o != null) comment = o.toString(); 32 33 if (comment != null) { 34 // sanitize line feeds 35 comment = comment.replaceAll("\r\n", "\n"); 36 comment = comment.replaceAll("\r", "\n"); 37 38 System.out.println(comment); 39 } 16 String comment = TiffTools.getComment(args[i]); 17 if (comment != null) System.out.println(comment); 40 18 } 41 19 }
Note: See TracChangeset
for help on using the changeset viewer.