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


Java Directory.getTags方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: MetadataProcessor

import com.drew.metadata.Directory; //導入方法依賴的package包/類
public MetadataProcessor(File imageFile) {
    this.imageFile = imageFile;
    try {
        data = ImageMetadataReader.readMetadata(imageFile);
    } catch (Exception ex) {
        Logger.getLogger(MetadataProcessor.class.getName()).log(Level.SEVERE, null, ex);
    }
    
    for (Directory directory : data.getDirectories()) {
        extracted_data += String.format("----------------------------------------------%15s---------------------------------\n", directory.getName());
        for (Tag tag : directory.getTags()) {
            extracted_data += tag + "\n";
        }
        if (directory.hasErrors()) {
            for (String error : directory.getErrors()) {
                System.err.println("ERROR: " + error);
            }
        }
    }
}
 
開發者ID:afsalashyana,項目名稱:FakeImageDetection,代碼行數:21,代碼來源:MetadataProcessor.java

示例9: extractMetadata

import com.drew.metadata.Directory; //導入方法依賴的package包/類
static ExtractedMetadata extractMetadata(Metadata metadata, String uri, Logger logger) throws Exception {
	ExtractedMetadata propsVals = new ExtractedMetadata();
       for (Directory directory : metadata.getDirectories()) {
           if (null != logger) logger.info ("  found metadata group: '" + directory.getName() + "'");
           for (Tag tag : directory.getTags()) {
               if (null != logger) logger.info("   found metadata tag: '" + tag.getTagName() + "' -> '" + tag.getDescription() + "' [" + tag.getTagType() + "]");
               String predicate = EXIF_NS + tag.getTagName().toLowerCase().replaceAll("[ /()&<>]","_");
               propsVals.addPropertyValue(predicate, tag.getDescription());
           }
       }
       
       return propsVals;
}
 
開發者ID:zepheira,項目名稱:jpeg2rdf,代碼行數:14,代碼來源:Extractor.java

示例10: convert

import com.drew.metadata.Directory; //導入方法依賴的package包/類
@PUT
@Path("pic")
@Consumes("image/*")
@Produces("text/plain")
public String convert(File img) throws /*FileNotFoundException,*/ IOException, ImageProcessingException {
	Metadata meta = ImageMetadataReader.readMetadata(img);

	StringBuilder sb = new StringBuilder();

	for (Directory directory : meta.getDirectories()) {
		sb.append(directory.getName()).append(":\n");
		for (Tag tag : directory.getTags()) {
			sb.append(tag).append('\n');
		}
	}
	return sb.toString();
}
 
開發者ID:jakobwenzel,項目名稱:rallye-server,代碼行數:18,代碼來源:Debug.java

示例11: writeDataToFile

import com.drew.metadata.Directory; //導入方法依賴的package包/類
public void writeDataToFile(File file, ReadableMap options, int jpegQualityPercent) throws IOException {
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(toJpeg(currentRepresentation, jpegQualityPercent));
    fos.close();

    try {
        ExifInterface exif = new ExifInterface(file.getAbsolutePath());

        // copy original exif data to the output exif...
        // unfortunately, this Android ExifInterface class doesn't understand all the tags so we lose some
        for (Directory directory : originalImageMetaData().getDirectories()) {
            for (Tag tag : directory.getTags()) {
                int tagType = tag.getTagType();
                Object object = directory.getObject(tagType);
                exif.setAttribute(tag.getTagName(), object.toString());
            }
        }

        writeLocationExifData(options, exif);

        if(hasBeenReoriented)
            rewriteOrientation(exif);

        exif.saveAttributes();
    } catch (ImageProcessingException | IOException e) {
        Log.e(TAG, "failed to save exif data", e);
    }
}
 
開發者ID:jonathan68,項目名稱:react-native-camera,代碼行數:29,代碼來源:MutableImage.java

示例12: writeDataToFile

import com.drew.metadata.Directory; //導入方法依賴的package包/類
public void writeDataToFile(File file, ReadableMap options, int jpegQualityPercent) throws IOException {
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(toJpeg(currentRepresentation, jpegQualityPercent));
    fos.close();

    try {
        ExifInterface exif = new ExifInterface(file.getAbsolutePath());

        // copy original exif data to the output exif...
        // unfortunately, this Android ExifInterface class doesn't understand all the tags so we lose some
        for (Directory directory : originalImageMetaData().getDirectories()) {
            for (Tag tag : directory.getTags()) {
                int tagType = tag.getTagType();
                Object object = directory.getObject(tagType);
                exif.setAttribute(tag.getTagName(), object.toString());
            }
        }

        writeLocationExifData(options, exif);

        if(hasBeenReoriented)
            rewriteOrientation(exif);

        exif.saveAttributes();
    } catch (ImageProcessingException  | IOException e) {
        Log.e(TAG, "failed to save exif data", e);
    }
}
 
開發者ID:entria,項目名稱:react-native-camera-face-detector,代碼行數:29,代碼來源:MutableImage.java

示例13: printAllTags

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

示例14: print

import com.drew.metadata.Directory; //導入方法依賴的package包/類
private static void print(Metadata metadata)
{
    System.out.println("-------------------------------------");

    // Iterate over the data and print to System.out

    //
    // A Metadata object contains multiple Directory objects
    //
    for (Directory directory : metadata.getDirectories()) {

        //
        // Each Directory stores values in Tag objects
        //
        for (Tag tag : directory.getTags()) {
            System.out.println(tag);
        }

        //
        // Each Directory may also contain error messages
        //
        if (directory.hasErrors()) {
            for (String error : directory.getErrors()) {
                System.err.println("ERROR: " + error);
            }
        }
    }
}
 
開發者ID:MPDL,項目名稱:LabCam,代碼行數:29,代碼來源:DeviceStatus.java

示例15: getImageTiffMetadata

import com.drew.metadata.Directory; //導入方法依賴的package包/類
public static void getImageTiffMetadata(File tifffile) throws ImageProcessingException, IOException {
	// works for tiff but has many unknown tags
	com.drew.metadata.Metadata drewmetadata = null;
	drewmetadata = ImageMetadataReader.readMetadata(tifffile);
	if (drewmetadata != null) {
		for (Directory directory : drewmetadata.getDirectories()) {
			System.out.println("directory: " + directory);
			for (Tag tag : directory.getTags()) {
				System.out.println("  tag: " + tag);
			}
		}
	}
}
 
開發者ID:friesey,項目名稱:preservation-tools,代碼行數:14,代碼來源:TiffTestClass.java


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