当前位置: 首页>>代码示例>>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;未经允许,请勿转载。