예제 #1
0
 /**
  * To use this class as a command line application, give it either some file names as parameters
  * (information on them will be printed to standard output, one line per file) or call it with no
  * parameters. It will then check data given to it via standard input.
  *
  * @param args the program arguments which must be file names
  */
 public static void main(String[] args) {
   ImageInfo imageInfo = new ImageInfo();
   imageInfo.setDetermineImageNumber(true);
   boolean verbose = determineVerbosity(args);
   if (args.length == 0) {
     run(null, System.in, imageInfo, verbose);
   } else {
     int index = 0;
     while (index < args.length) {
       InputStream in = null;
       try {
         String name = args[index++];
         System.out.print(name + ";"); // $NON-NLS-1$
         if (name.startsWith("http://")) { // $NON-NLS-1$
           in = new URL(name).openConnection().getInputStream();
         } else {
           in = new FileInputStream(name);
         }
         run(name, in, imageInfo, verbose);
         in.close();
       } catch (Exception e) {
         System.out.println(e);
         try {
           in.close();
         } catch (Exception ee) {
         }
       }
     }
   }
 }
예제 #2
0
 private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
   imageInfo.setInput(in);
   imageInfo.setDetermineImageNumber(false);
   imageInfo.setCollectComments(verbose);
   if (imageInfo.check()) {
     print(sourceName, imageInfo, verbose);
   }
 }
예제 #3
0
 private static void printCompact(String sourceName, ImageInfo imageInfo) {
   System.out.println(
       imageInfo.getFormatName()
           + ";"
           + //$NON-NLS-1$
           imageInfo.getMimeType()
           + ";"
           + //$NON-NLS-1$
           imageInfo.getWidth()
           + ";"
           + //$NON-NLS-1$
           imageInfo.getHeight()
           + ";"
           + //$NON-NLS-1$
           imageInfo.getBitsPerPixel()
           + ";"
           + //$NON-NLS-1$
           imageInfo.getNumberOfImages()
           + ";"
           + //$NON-NLS-1$
           imageInfo.getPhysicalWidthDpi()
           + ";"
           + //$NON-NLS-1$
           imageInfo.getPhysicalHeightDpi()
           + ";"
           + //$NON-NLS-1$
           imageInfo.getPhysicalWidthInch()
           + ";"
           + //$NON-NLS-1$
           imageInfo.getPhysicalHeightInch()
           + ";"
           + //$NON-NLS-1$
           imageInfo.isProgressive());
 }
예제 #4
0
 private static void printVerbose(String sourceName, ImageInfo ii) {
   printLine(0, null, sourceName);
   printLine(1, Messages.getString("ImageInfo.1"), ii.getFormatName()); // $NON-NLS-1$
   printLine(1, Messages.getString("ImageInfo.2"), ii.getMimeType()); // $NON-NLS-1$
   printLine(1, Messages.getString("ImageInfo.3"), ii.getWidth(), 1); // $NON-NLS-1$
   printLine(1, Messages.getString("ImageInfo.4"), ii.getHeight(), 1); // $NON-NLS-1$
   printLine(1, Messages.getString("ImageInfo.5"), ii.getBitsPerPixel(), 1); // $NON-NLS-1$
   printLine(
       1, Messages.getString("ImageInfo.6"), Boolean.toString(ii.isProgressive())); // $NON-NLS-1$
   printLine(1, Messages.getString("ImageInfo.7"), ii.getNumberOfImages(), 1); // $NON-NLS-1$
   printLine(1, Messages.getString("ImageInfo.8"), ii.getPhysicalWidthDpi(), 1); // $NON-NLS-1$
   printLine(1, Messages.getString("ImageInfo.9"), ii.getPhysicalHeightDpi(), 1); // $NON-NLS-1$
   printLine(
       1, Messages.getString("ImageInfo.10"), ii.getPhysicalWidthInch(), 1.0f); // $NON-NLS-1$
   printLine(
       1, Messages.getString("ImageInfo.11"), ii.getPhysicalHeightInch(), 1.0f); // $NON-NLS-1$
   int numComments = ii.getNumberOfComments();
   printLine(1, Messages.getString("ImageInfo.12"), numComments, 1); // $NON-NLS-1$
   if (numComments > 0) {
     for (int i = 0; i < numComments; i++) {
       printLine(2, null, ii.getComment(i));
     }
   }
 }
예제 #5
0
 private static void printVerbose(String sourceName, ImageInfo ii) {
   printLine(0, null, sourceName);
   printLine(1, "File format: ", ii.getFormatName());
   printLine(1, "MIME type: ", ii.getMimeType());
   printLine(1, "Width (pixels): ", ii.getWidth(), 1);
   printLine(1, "Height (pixels): ", ii.getHeight(), 1);
   printLine(1, "Bits per pixel: ", ii.getBitsPerPixel(), 1);
   printLine(1, "Progressive: ", Boolean.toString(ii.isProgressive()));
   printLine(1, "Number of images: ", ii.getNumberOfImages(), 1);
   printLine(1, "Physical width (dpi): ", ii.getPhysicalWidthDpi(), 1);
   printLine(1, "Physical height (dpi): ", ii.getPhysicalHeightDpi(), 1);
   printLine(1, "Physical width (inches): ", ii.getPhysicalWidthInch(), 1.0f);
   printLine(1, "Physical height (inches): ", ii.getPhysicalHeightInch(), 1.0f);
   int numComments = ii.getNumberOfComments();
   printLine(1, "Number of textual comments: ", numComments, 1);
   if (numComments > 0) {
     for (int i = 0; i < numComments; i++) {
       printLine(2, null, ii.getComment(i));
     }
   }
 }