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


Java Metadata.getDirectories方法代碼示例

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


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

示例1: printImageTags

import com.drew.metadata.Metadata; //導入方法依賴的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

示例2: metaDataMenuItemActionPerformed

import com.drew.metadata.Metadata; //導入方法依賴的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

示例3: readExif

import com.drew.metadata.Metadata; //導入方法依賴的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

示例4: onExtractionSuccess

import com.drew.metadata.Metadata; //導入方法依賴的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

示例5: onExtracted

import com.drew.metadata.Metadata; //導入方法依賴的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

示例6: parseMetadata

import com.drew.metadata.Metadata; //導入方法依賴的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

示例7: parseExifOrientation

import com.drew.metadata.Metadata; //導入方法依賴的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

示例8: parseMetadata

import com.drew.metadata.Metadata; //導入方法依賴的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

示例9: parseMetadata

import com.drew.metadata.Metadata; //導入方法依賴的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

示例10: writeHierarchyLevel

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
private static void writeHierarchyLevel(@NotNull Metadata metadata, @NotNull PrintWriter writer, @Nullable Directory parent, int level)
{
    final int indent = 4;

    for (Directory child : metadata.getDirectories()) {
        if (parent == null) {
            if (child.getParent() != null)
                continue;
        } else if (!parent.equals(child.getParent())) {
            continue;
        }

        for (int i = 0; i < level*indent; i++) {
            writer.write(' ');
        }
        writer.write("- ");
        writer.write(child.getName());
        writer.write(NEW_LINE);
        writeHierarchyLevel(metadata, writer, child, level + 1);
    }
}
 
開發者ID:drewnoakes,項目名稱:metadata-extractor,代碼行數:22,代碼來源:ProcessAllImagesInFolderUtility.java

示例11: Row

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
Row(@NotNull File file, @NotNull Metadata metadata)
{
    this.file = file;
    this.metadata = metadata;

    ExifIFD0Directory ifd0Dir = metadata.getDirectory(ExifIFD0Directory.class);
    ExifSubIFDDirectory subIfdDir = metadata.getDirectory(ExifSubIFDDirectory.class);
    ExifThumbnailDirectory thumbDir = metadata.getDirectory(ExifThumbnailDirectory.class);
    if (ifd0Dir != null) {
        manufacturer = ifd0Dir.getDescription(ExifIFD0Directory.TAG_MAKE);
        model = ifd0Dir.getDescription(ExifIFD0Directory.TAG_MODEL);
    }
    boolean hasMakernoteData = false;
    if (subIfdDir != null) {
        exifVersion = subIfdDir.getDescription(ExifSubIFDDirectory.TAG_EXIF_VERSION);
        hasMakernoteData = subIfdDir.containsTag(ExifSubIFDDirectory.TAG_MAKERNOTE);
    }
    if (thumbDir != null) {
        Integer width = thumbDir.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_IMAGE_WIDTH);
        Integer height = thumbDir.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_IMAGE_HEIGHT);
        thumbnail = width != null && height != null
            ? String.format("Yes (%s x %s)", width, height)
            : "Yes";
    }
    for (Directory directory : metadata.getDirectories()) {
        if (directory.getClass().getName().contains("Makernote")) {
            makernote = directory.getName().replace("Makernote", "").trim();
        }
    }
    if (makernote == null) {
        makernote = hasMakernoteData ? "(Unknown)" : "N/A";
    }
}
 
開發者ID:byronb92,項目名稱:ImageEXIFExtraction,代碼行數:34,代碼來源:ProcessAllImagesInFolderUtility.java

示例12: setToArray

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
public void setToArray(Metadata metadata){   
  for (Directory directory : metadata.getDirectories()) {
      directory.getTags().forEach((tag) -> {
          if (!directory.hasErrors()) {
              out.add(tag.getTagName()+" "+tag.getDescription());
              System.out.println(tag.toString());
          }
      });
  }
}
 
開發者ID:Obsidiam,項目名稱:joanne,代碼行數:11,代碼來源:ImageManager.java

示例13: parseMetadata

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

	for (Directory directory : metadata.getDirectories()) {
		if (directory instanceof GifHeaderDirectory) {
			parsedInfo.format = ImageFormat.GIF;
			parsedInfo.numComponents = 3;
			if (
				((GifHeaderDirectory) directory).containsTag(GifHeaderDirectory.TAG_IMAGE_WIDTH) &&
				((GifHeaderDirectory) directory).containsTag(GifHeaderDirectory.TAG_IMAGE_HEIGHT)
			) {
				parsedInfo.width = ((GifHeaderDirectory) directory).getInteger(GifHeaderDirectory.TAG_IMAGE_WIDTH);
				parsedInfo.height = ((GifHeaderDirectory) directory).getInteger(GifHeaderDirectory.TAG_IMAGE_HEIGHT);
			}
			if (((GifHeaderDirectory) directory).containsTag(GifHeaderDirectory.TAG_BITS_PER_PIXEL)) {
				parsedInfo.colorSpaceType = ColorSpaceType.TYPE_RGB;
				Integer i = ((GifHeaderDirectory) directory).getInteger(GifHeaderDirectory.TAG_BITS_PER_PIXEL);
				if (i != null) {
					parsedInfo.bitDepth = i.intValue();
				}
			}
			if (((GifHeaderDirectory) directory).containsTag(GifHeaderDirectory.TAG_GIF_FORMAT_VERSION)) {
				String s = ((GifHeaderDirectory) directory).getString(GifHeaderDirectory.TAG_GIF_FORMAT_VERSION, "US-ASCII");
				if (s != null) {
					((GIFParseInfo) parsedInfo).formatVersion = s;
				}
			}
		} else if (directory instanceof GifControlDirectory) {
			boolean hasTransparency = ((GifControlDirectory) directory).isTransparent();
			((GIFParseInfo) parsedInfo).hasTransparency = hasTransparency;
			if (hasTransparency) {
				if (parsedInfo.numComponents == null) {
					throw new ParseException(
						"Invalid GIF image - Graphic Control Extension block encountered before the Header block"
					);
				}
				parsedInfo.numComponents = 4;
			}
		}
	}
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:45,代碼來源:GIFInfo.java

示例14: printAllTags

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
/**
 * Prints Tag.getDescription() of all Tags in Metadata
 * 
 * @param metadata Metadata read from image file
 */
public static void printAllTags(Metadata metadata) {
	if(metadata == null) {
		System.out.println("Metadata was null. Nothing to print.");
	}
	
	for(Directory dir : metadata.getDirectories()) {
		System.out.println("Directory: " + dir.getName());
		for(Tag tag : dir.getTags()) {
			System.out.println("\tTag: " + tag.getTagName() + ", Value: " + tag.getDescription());
		}
	}
}
 
開發者ID:1stResponder,項目名稱:nics-tools,代碼行數:18,代碼來源:ImageProcessor.java

示例15: readMetadata

import com.drew.metadata.Metadata; //導入方法依賴的package包/類
/**
 * Read metadata from picture
 *
 * @param source
 * @return
 * @throws ImageProcessingException
 * @throws IOException
 */
public static Set<gal.udc.fic.muei.tfm.dap.flipper.domain.Metadata> readMetadata(byte[] source) throws ImageProcessingException, IOException {

    ByteArrayInputStream bis = new ByteArrayInputStream(source);

    Metadata metadata = ImageMetadataReader.readMetadata(bis);

    Set<gal.udc.fic.muei.tfm.dap.flipper.domain.Metadata> result = new HashSet<gal.udc.fic.muei.tfm.dap.flipper.domain.Metadata>();
    for (Directory directory : metadata.getDirectories()) {
        result.addAll(directory.getTags().stream().map(tag -> new gal.udc.fic.muei.tfm.dap.flipper.domain.Metadata(
            directory.getName(), tag.getTagType(), tag.getTagName(), tag.getDescription())).collect(Collectors.toList()));
    }

    return result;
}
 
開發者ID:dalbelap,項目名稱:flipper-reverse-image-search,代碼行數:23,代碼來源:MetadataExtactorUtils.java


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