Changeset 3260


Ignore:
Timestamp:
10/11/07 09:26:32 (12 years ago)
Author:
curtis
Message:

TiffComment now has a trivial implementation thanks to TiffTools.getComment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils/TiffComment.java

    r974 r3260  
    33// 
    44 
    5 import loci.formats.RandomAccessStream; 
    65import loci.formats.TiffTools; 
    7 import java.util.Hashtable; 
    86 
    97/** Extracts the comment from the first IFD of the given TIFF file(s). */ 
     
    1614    } 
    1715    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); 
    4018    } 
    4119  } 
Note: See TracChangeset for help on using the changeset viewer.