Exemplo n.º 1
0
 private static Directory getMetaDirectory(File file) {
   try {
     Metadata metadata = JpegMetadataReader.readMetadata(file);
     return metadata.getDirectory(ExifDirectory.class);
   } catch (JpegProcessingException e) {
     e.printStackTrace();
   }
   return null;
 }
Exemplo n.º 2
0
  /* (non-Javadoc)
   * @see org.inbio.m3s.dao.multimedia.MetadataExtractorDAO#init(java.lang.String)
   */
  public void init(String fileAddress) throws IllegalArgumentException {
    logger.info("using the fileAddress: '" + fileAddress + "'");
    this.fileAddress = fileAddress;

    try {
      File jpegFile = new File(fileAddress);
      Metadata metadata = JpegMetadataReader.readMetadata(jpegFile);
      this.exifDirectory = metadata.getDirectory(ExifDirectory.class);

    } catch (JpegProcessingException e) {
      e.printStackTrace();
      throw new IllegalArgumentException(
          "The fileAddress [" + fileAddress + "] doesn't exist. ", e.getCause());
    }
  }
Exemplo n.º 3
0
  /**
   * @param filename
   * @return
   */
  private HashMap<String, String> extractExifDatas(String filename) {
    HashMap<String, String> datas = new HashMap<String, String>();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_HH'h'mm.ss");
    try {
      File jpegFile = new File(filename);
      Metadata metadata = ImageMetadataReader.readMetadata(jpegFile);

      // reading exif
      ExifSubIFDDirectory directory = metadata.getDirectory(ExifSubIFDDirectory.class);
      if (directory != null) {
        Date date = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
        if (date != null) {
          datas.put("date", formatter.format(date));
        }
      }
    } catch (JpegProcessingException e) {
      System.err.println("Problem during datas extraction : " + e.getMessage());
    } catch (IOException e) {
      System.err.println("Problem during datas extraction" + e.getMessage());
    } catch (ImageProcessingException e) {
      System.err.println("Problem during datas extraction" + e.getMessage());
    }
    return datas;
  }