當前位置: 首頁>>代碼示例>>Java>>正文


Java Directory類代碼示例

本文整理匯總了Java中com.drew.metadata.Directory的典型用法代碼示例。如果您正苦於以下問題:Java Directory類的具體用法?Java Directory怎麽用?Java Directory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Directory類屬於com.drew.metadata包,在下文中一共展示了Directory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getShootTime

import com.drew.metadata.Directory; //導入依賴的package包/類
/**
 * 獲取拍攝時間
 * @param path 照片路徑
 * @return   秒數
 */
public static int getShootTime(String path){
	File jpegFile = new File(path);  
       Metadata metadata;
	try {
		metadata = JpegMetadataReader.readMetadata(jpegFile);
		Directory exif = metadata.getDirectory(ExifIFD0Directory.class); 
        String model = exif.getString(ExifIFD0Directory.TAG_DATETIME);
        
        //Date/Time ==> 2015:09:17 15:24:43
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
        Date d = sdf1.parse(model);
        return (int) (d.getTime() / 1000);
        
	} catch (Exception e) {
		e.printStackTrace();
		return 0;
	}  
         
}
 
開發者ID:cowthan,項目名稱:JavaAyo,代碼行數:25,代碼來源:ExifUtils.java

示例2: printImageTags

import com.drew.metadata.Directory; //導入依賴的package包/類
/**
 * 讀取照片裏麵的信息
 */
private static void printImageTags(File file) throws Exception {
    Metadata metadata = ImageMetadataReader.readMetadata(file);
    String createDate = null;
    String lat = null;
    String lon = null;
    for (Directory directory : metadata.getDirectories()) {
        for (Tag tag : directory.getTags()) {
            String tagName = tag.getTagName();  //標簽名
            String desc = tag.getDescription(); //標簽信息
            switch (tagName) {
                case "Date/Time Original":
                    createDate = desc.split(" ")[0].replace(":", "-");
                    break;
                case "GPS Latitude":
                    lat = desc;
                    break;
                case "GPS Longitude":
                    lon = desc;
                    break;
            }
        }
    }
    moveFile(newFilePath, getposition(pointToLatlong(lat), pointToLatlong(lon)), file, createDate);
}
 
開發者ID:wsldl123292,項目名稱:testeverything,代碼行數:28,代碼來源:ImgClassification.java

示例3: metaDataMenuItemActionPerformed

import com.drew.metadata.Directory; //導入依賴的package包/類
private void metaDataMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_metaDataMenuItemActionPerformed
    if (openedFile == null) {
        return;
    }
    try {
        Metadata metadata = ImageMetadataReader.readMetadata(openedFile);
        String metaData = "";
        for (Directory directory : metadata.getDirectories()) {
            for (Tag tag : directory.getTags()) {
                metaData += tag + "\n";
            }
        }
        alert(metaData, "Meta Data");
        System.out.println("Courtesy: " + 
                "https://github.com/drewnoakes/metadata-extractor");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:varunon9,項目名稱:Image-Stegano,代碼行數:20,代碼來源:ImageStegano.java

示例4: readExif

import com.drew.metadata.Directory; //導入依賴的package包/類
private static HashMap<String, String> readExif(File file) throws ImageProcessingException, IOException {
	HashMap<String, String> map = new HashMap<String, String>();
	InputStream is = null;
	is = new FileInputStream(file);

	Metadata metadata = ImageMetadataReader.readMetadata(is);
	Iterable<Directory> iterable = metadata.getDirectories();
	for (Iterator<Directory> iter = iterable.iterator(); iter.hasNext();) {
		Directory dr = iter.next();
		Collection<Tag> tags = dr.getTags();
		for (Tag tag : tags)
			map.put(tag.getTagName(), tag.getDescription());
	}
	_tracer.debug("Got Exif. " + file.getAbsolutePath() + "\r\n" + map.toString());
	is.close();
	return map;
}
 
開發者ID:probestar,項目名稱:PhotoCollector,代碼行數:18,代碼來源:PhotoCollectorUtils.java

示例5: handle

import com.drew.metadata.Directory; //導入依賴的package包/類
public void handle(Directory directory, Metadata metadata)
        throws MetadataException {
    if (directory.getTags() != null) {
        Iterator<?> tags = directory.getTags().iterator();
        while (tags.hasNext()) {
            Tag tag = (Tag) tags.next();
            String name = tag.getTagName();
            if (!MetadataFields.isMetadataField(name) && tag.getDescription() != null) {
                  String value = tag.getDescription().trim();
                  if (Boolean.TRUE.toString().equalsIgnoreCase(value)) {
                      value = Boolean.TRUE.toString();
                  } else if (Boolean.FALSE.toString().equalsIgnoreCase(value)) {
                      value = Boolean.FALSE.toString();
                  }
                  metadata.set(name, value);
            }
        }
    }
}
 
開發者ID:kolbasa,項目名稱:OCRaptor,代碼行數:20,代碼來源:ImageMetadataExtractor.java

示例6: getOrientation

import com.drew.metadata.Directory; //導入依賴的package包/類
private String getOrientation(ImageFile src) {
	try {
		Metadata metadata = ImageMetadataReader.readMetadata(src.getInputStream());
		Directory directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
		if (directory != null) {
			for (Tag tag : directory.getTags()) {
				if ("Orientation".equals(tag.getTagName())) {
					return tag.getDescription();
				}
			}
		}
	} catch (IOException|ImageProcessingException e) {
		logger.error("Image orientation error", e);
	}
	return "";
}
 
開發者ID:web-education,項目名稱:mod-image-resizer,代碼行數:17,代碼來源:ImageResizer.java

示例7: extract

import com.drew.metadata.Directory; //導入依賴的package包/類
public void extract(@NotNull SequentialReader reader, @NotNull Metadata metadata)
{
    Directory directory = new AdobeJpegDirectory();
    metadata.addDirectory(directory);

    try {
        reader.setMotorolaByteOrder(false);

        if (!reader.getString(PREAMBLE.length()).equals(PREAMBLE)) {
            directory.addError("Invalid Adobe JPEG data header.");
            return;
        }

        directory.setInt(AdobeJpegDirectory.TAG_DCT_ENCODE_VERSION, reader.getUInt16());
        directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS0, reader.getUInt16());
        directory.setInt(AdobeJpegDirectory.TAG_APP14_FLAGS1, reader.getUInt16());
        directory.setInt(AdobeJpegDirectory.TAG_COLOR_TRANSFORM, reader.getInt8());
    } catch (IOException ex) {
        directory.addError("IO exception processing data: " + ex.getMessage());
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:22,代碼來源:AdobeJpegReader.java

示例8: onExtractionSuccess

import com.drew.metadata.Directory; //導入依賴的package包/類
@Override
public void onExtractionSuccess(@NotNull File file, @NotNull Metadata metadata, @NotNull String relativePath, @NotNull PrintStream log)
{
    super.onExtractionSuccess(file, metadata, relativePath, log);

    // Iterate through all values, calling toString to flush out any formatting exceptions
    for (Directory directory : metadata.getDirectories()) {
        directory.getName();
        for (Tag tag : directory.getTags()) {
            tag.getTagName();
            tag.getDescription();
        }
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:15,代碼來源:ProcessAllImagesInFolderUtility.java

示例9: onExtracted

import com.drew.metadata.Directory; //導入依賴的package包/類
@Override
public void onExtracted(@NotNull File file, @NotNull Metadata metadata)
{
    super.onExtracted(file, metadata);

    // Iterate through all values, calling toString to flush out any formatting exceptions
    for (Directory directory : metadata.getDirectories()) {
        directory.getName();
        for (Tag tag : directory.getTags()) {
            tag.getTagName();
            tag.getDescription();
        }
    }
}
 
開發者ID:byronb92,項目名稱:ImageEXIFExtraction,代碼行數:15,代碼來源:ProcessAllImagesInFolderUtility.java

示例10: getDateFromImgEXIF

import com.drew.metadata.Directory; //導入依賴的package包/類
/**
 * @param f
 * @return
 * @throws IOException
 */
private String getDateFromImgEXIF(final File file) throws IOException {
	String date = null;
	if (file.isFile()) {
		try {
			final Metadata metadata = ImageMetadataReader
					.readMetadata(file);
			// obtain the Exif directory
			final Directory directory = metadata
					.getDirectory(ExifSubIFDDirectory.class);
			if (null != directory) {
				final Date tagDate = directory
						.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
				if (null != tagDate) {
					date = this.sdf.format(tagDate);
				}
			}
		} catch (final ImageProcessingException e) {
			// e.printStackTrace();
		}
	}
	return date;
}
 
開發者ID:caomu,項目名稱:img,代碼行數:28,代碼來源:Distribute.java

示例11: getExifDate

import com.drew.metadata.Directory; //導入依賴的package包/類
/**
 *
 * @param filePath
 * @return
 */
private String getExifDate(File file) {

  try {
    Metadata metadata = ImageMetadataReader.readMetadata(file);
    Directory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
    int dateTag = ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL;

    if (directory != null && directory.containsTag(dateTag)) {
      Date date = directory.getDate(dateTag, TimeZone.getDefault());
      return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date);
    } else {
      return "";
    }
  } catch (ImageProcessingException | IOException ex) {
    LOGGER.log(Level.INFO, 
        "Exif error for {0}: {1}",
        new String[]{file.getName(), ex.getLocalizedMessage()}
    );
    return "";
  }
}
 
開發者ID:yarl,項目名稱:pattypan,代碼行數:27,代碼來源:CreateFilePane.java

示例12: parseMetadata

import com.drew.metadata.Directory; //導入依賴的package包/類
@Override
protected void parseMetadata(Metadata metadata) {
	if (metadata == null) {
		return;
	}

	for (Directory directory : metadata.getDirectories()) {
		if (directory instanceof WebpDirectory) {
			parsedInfo.format = ImageFormat.WEBP;
			if (
				((WebpDirectory) directory).containsTag(WebpDirectory.TAG_IMAGE_WIDTH) &&
				((WebpDirectory) directory).containsTag(WebpDirectory.TAG_IMAGE_HEIGHT)
			) {
				parsedInfo.width = ((WebpDirectory) directory).getInteger(WebpDirectory.TAG_IMAGE_WIDTH);
				parsedInfo.height = ((WebpDirectory) directory).getInteger(WebpDirectory.TAG_IMAGE_HEIGHT);
			}
		}
	}
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:20,代碼來源:WebPInfo.java

示例13: parseExifOrientation

import com.drew.metadata.Directory; //導入依賴的package包/類
/**
 * Tries to parse {@link ExifOrientation} from the given metadata. If it
 * fails, {@code defaultOrientation} is returned.
 *
 * @param metadata the {@link Metadata} to parse.
 * @param defaultOrientation the default to return if parsing fails.
 * @return The parsed {@link ExifOrientation} or {@code defaultOrientation}.
 */
public static ExifOrientation parseExifOrientation(Metadata metadata, ExifOrientation defaultOrientation) {
	if (metadata == null) {
		return defaultOrientation;
	}
	try {
		for (Directory directory : metadata.getDirectories()) {
			if (directory instanceof ExifIFD0Directory) {
				if (((ExifIFD0Directory) directory).containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {
					return ExifOrientation.typeOf(((ExifIFD0Directory) directory).getInt(ExifIFD0Directory.TAG_ORIENTATION));
				}
			}
		}
	} catch (MetadataException e) {
		return defaultOrientation;
	}
	return defaultOrientation;
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:26,代碼來源:ImagesUtil.java

示例14: parseMetadata

import com.drew.metadata.Directory; //導入依賴的package包/類
@Override
protected void parseMetadata(Metadata metadata) {
	if (metadata == null) {
		return;
	}

	for (Directory directory : metadata.getDirectories()) {
		if (directory instanceof IcoDirectory) {
			parsedInfo.format = ImageFormat.ICO;
			if (
				((IcoDirectory) directory).containsTag(IcoDirectory.TAG_IMAGE_WIDTH) &&
				((IcoDirectory) directory).containsTag(IcoDirectory.TAG_IMAGE_HEIGHT)
			) {
				parsedInfo.width = ((IcoDirectory) directory).getInteger(IcoDirectory.TAG_IMAGE_WIDTH);
				parsedInfo.height = ((IcoDirectory) directory).getInteger(IcoDirectory.TAG_IMAGE_HEIGHT);
			}
		}
	}
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:20,代碼來源:ICOInfo.java

示例15: parseMetadata

import com.drew.metadata.Directory; //導入依賴的package包/類
@Override
protected void parseMetadata(Metadata metadata) {
	if (metadata == null) {
		return;
	}

	for (Directory directory : metadata.getDirectories()) {
		if (directory instanceof PcxDirectory) {
			parsedInfo.format = ImageFormat.PCX;
			if (
				((PcxDirectory) directory).containsTag(PcxDirectory.TAG_XMIN) &&
				((PcxDirectory) directory).containsTag(PcxDirectory.TAG_XMAX) &&
				((PcxDirectory) directory).containsTag(PcxDirectory.TAG_YMIN) &&
				((PcxDirectory) directory).containsTag(PcxDirectory.TAG_YMAX)
			) {
				Integer min = ((PcxDirectory) directory).getInteger(PcxDirectory.TAG_XMIN);
				Integer max = ((PcxDirectory) directory).getInteger(PcxDirectory.TAG_XMAX);
				if (min != null && max != null) {
					parsedInfo.width = max.intValue() - min.intValue() + 1;
				}
				min = ((PcxDirectory) directory).getInteger(PcxDirectory.TAG_YMIN);
				max = ((PcxDirectory) directory).getInteger(PcxDirectory.TAG_YMAX);
				if (min != null && max != null) {
					parsedInfo.height = max.intValue() - min.intValue() + 1;
				}
			}
		}
	}
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:30,代碼來源:PCXInfo.java


注:本文中的com.drew.metadata.Directory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。