当前位置: 首页>>代码示例>>Java>>正文


Java ExifReader类代码示例

本文整理汇总了Java中com.drew.metadata.exif.ExifReader的典型用法代码示例。如果您正苦于以下问题:Java ExifReader类的具体用法?Java ExifReader怎么用?Java ExifReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExifReader类属于com.drew.metadata.exif包,在下文中一共展示了ExifReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setHits

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
/**
 * @param hits
 * @param progress
 */
public void setHits(ImageSearchHits hits, JProgressBar progress) {
    this.hits = hits;
    icons = new ArrayList<ImageIcon>(hits.length());
    if (progress != null) progress.setString("Searching finished. Loading images for result list.");
    for (int i = 0; i < hits.length(); i++) {
        ImageIcon icon = null;
        try {
            BufferedImage img = null;
            String fileIdentifier = hits.doc(i).getField(DocumentBuilder.FIELD_NAME_IDENTIFIER).stringValue();
            if (!fileIdentifier.startsWith("http:")) {
                // check isf it is a jpg file ...
                if (fileIdentifier.toLowerCase().endsWith(".jpg")) {
                    Metadata metadata = new ExifReader(new FileInputStream(fileIdentifier)).extract();
                    if (metadata.containsDirectory(ExifDirectory.class)) {
                        ExifDirectory exifDirectory = (ExifDirectory) metadata.getDirectory(ExifDirectory.class);
                        if (exifDirectory.containsThumbnail()) {
                            img = ImageIO.read(new ByteArrayInputStream(exifDirectory.getThumbnailData()));
                        }
                    }
                }
                if (img == null) {
                    img = ImageIO.read(new FileInputStream(fileIdentifier));
                }
            } else {
                img = ImageIO.read(new URL(fileIdentifier));
            }
            icon = new ImageIcon(ImageUtils.scaleImage(img, 200));
            if (progress != null) progress.setValue((i * 100) / hits.length());
        } catch (Exception ex) {
            Logger.getLogger("global").log(Level.SEVERE, null, ex);
        }
        icons.add(icon);
    }
    if (progress != null) progress.setValue(100);
    fireTableDataChanged();
}
 
开发者ID:fish2000,项目名称:lire,代码行数:41,代码来源:SearchResultsTableModel.java

示例2: readMetadata

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
@Deprecated
@NotNull
public static Metadata readMetadata(@NotNull InputStream inputStream, boolean waitForBytes) throws IOException
{
    // NOTE this method is very inefficient, as it attempts to read the entire TIFF file into a byte[]
    // TIFF processing requires random access, as directories can be scattered throughout the byte sequence.
    // InputStream does not support seeking backwards, and so is not a viable option for TIFF processing

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    int b;
    // TODO do this in chunks rather than byte-by-byte, and honour 'waitForBytes'
    while((b = inputStream.read()) != -1) {
        out.write(b);
    }
    Metadata metadata = new Metadata();
    new ExifReader().extractTiff(new ByteArrayReader(out.toByteArray()), metadata);
    return metadata;
}
 
开发者ID:mxbossard,项目名称:metadata-extractor-osgi,代码行数:19,代码来源:TiffMetadataReader.java

示例3: testXResolution

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
public void testXResolution() throws Exception
{
    String fileName = "Source/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg";
    Metadata metadata = new ExifReader(new File(fileName)).extract();
    Directory directory = metadata.getDirectory(ExifDirectory.class);
    Rational rational = directory.getRational(ExifDirectory.TAG_X_RESOLUTION);
    assertEquals(72, rational.getNumerator());
    assertEquals(1, rational.getDenominator());
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:10,代码来源:ExifReaderTest.java

示例4: testYResolution

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
public void testYResolution() throws Exception
{
    String fileName = "Source/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg";
    Metadata metadata = new ExifReader(new File(fileName)).extract();
    Directory directory = metadata.getDirectory(ExifDirectory.class);
    Rational rational = directory.getRational(ExifDirectory.TAG_Y_RESOLUTION);
    assertEquals(72, rational.getNumerator());
    assertEquals(1, rational.getDenominator());
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:10,代码来源:ExifReaderTest.java

示例5: readMetadata

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
public static Metadata readMetadata(JPEGDecodeParam decodeParam)
{
  final Metadata metadata = new Metadata();

  /*
   * We should only really be seeing Exif in _data[0]... the 2D array exists because markers can
   * theoretically appear multiple times in the file.
   */
  // TODO test this method
  byte[][] exifSegment = decodeParam
      .getMarkerData(JPEGDecodeParam.APP1_MARKER);
  if (exifSegment != null && exifSegment[0].length > 0)
  {
    new ExifReader(exifSegment[0]).extract(metadata);
  }

  // similarly, use only the first IPTC segment
  byte[][] iptcSegment = decodeParam
      .getMarkerData(JPEGDecodeParam.APPD_MARKER);
  if (iptcSegment != null && iptcSegment[0].length > 0)
  {
    new IptcReader(iptcSegment[0]).extract(metadata);
  }

  // NOTE: Unable to utilise JpegReader for the SOF0 frame here, as the
  // decodeParam doesn't contain the byte[]

  // similarly, use only the first Jpeg Comment segment
  byte[][] jpegCommentSegment = decodeParam
      .getMarkerData(JPEGDecodeParam.COMMENT_MARKER);
  if (jpegCommentSegment != null && jpegCommentSegment[0].length > 0)
  {
    new JpegCommentReader(jpegCommentSegment[0]).extract(metadata);
  }

  return metadata;
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:38,代码来源:JpegMetadataReaderSunUtils.java

示例6: looksOK

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
/**
 * Check whether the exifreader class can be correctly resolved
 * @return true if it looks ok
 */
public boolean looksOK()
{
	try {
		String test = ExifReader.class.getName();
		if (test != null) return true;
	}
	catch (LinkageError le) {}
	return false;
}
 
开发者ID:activityworkshop,项目名称:GpsPrune,代码行数:14,代码来源:ExternalExifLibrary.java

示例7: readMetadata

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
@NotNull
public static Metadata readMetadata(@NotNull File file) throws IOException
{
    Metadata metadata = new Metadata();
    RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r");

    try {
        new ExifReader().extractTiff(new RandomAccessFileReader(randomAccessFile), metadata);
    } finally {
        randomAccessFile.close();
    }

    return metadata;
}
 
开发者ID:byronb92,项目名称:ImageEXIFExtraction,代码行数:15,代码来源:TiffMetadataReader.java

示例8: validateMultipleSegmentRead

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
private void validateMultipleSegmentRead(JpegSegmentReader reader) throws JpegProcessingException
{
    byte[] iptcData = reader.readSegment(JpegSegmentReader.SEGMENT_APPD);
    byte[] exifData = reader.readSegment(JpegSegmentReader.SEGMENT_APP1);
    Assert.assertNotNull(iptcData);
    Assert.assertNotNull(exifData);
    Assert.assertTrue("exif data too short", exifData.length > 4);
    // TODO extracting the data doesn't mean anything in this test case...
    Metadata metadata = new Metadata();
    new ExifReader().extract(new ByteArrayReader(exifData), metadata);
    new IptcReader().extract(new ByteArrayReader(iptcData), metadata);
    Assert.assertEquals("Exif", new String(exifData, 0, 4));
}
 
开发者ID:mxbossard,项目名称:metadata-extractor-osgi,代码行数:14,代码来源:JpegSegmentReaderTest.java

示例9: extractMetadataFeatures

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
/**
 * @param node
 * @param exifTag
 */
public void extractMetadataFeatures(IIOMetadataNode node)
{
  NodeList unknownElements = node.getElementsByTagName(EXIF_ELEMENT_TAG_NAME);
  for (int i = 0; i < unknownElements.getLength(); i++)
  {
    IIOMetadataNode foundUnknownNode = (IIOMetadataNode) unknownElements.item(i);
    if ("225".equals(foundUnknownNode.getAttribute("MarkerTag")))
    {
      boolean dated = false;
      byte[] exifSegment = (byte[]) foundUnknownNode.getUserObject();

      final com.drew.metadata.Metadata exifMetadata = new com.drew.metadata.Metadata();
      new ExifReader(exifSegment).extract(exifMetadata);
      com.drew.metadata.Directory exifDir = exifMetadata.getDirectory(ExifDirectory.class);

      Image image = getDocument();
      boolean mixedIn = image.containsMixin(MM_TAG_CAMERA_SETTINGS);
      if (!mixedIn && !GisFeatures.containsGisMixin(image))
      {
        if (!dated && ORIG_DATE_FEATURE.extract(image, exifDir) == null)
        {
          dated = true;
          DATE_FEATURE.extract(image, exifDir);
        }
        if (!mixedIn && CAMERA_MODEL_FEATURE.getStringValue(exifDir) != null)
        {
          mixedIn = true;
          extractMixin(exifDir, EXIF_METADATA_FEATURES, MM_TAG_CAMERA_SETTINGS);
        }
        com.drew.metadata.Directory gpsDir = exifMetadata.getDirectory(GpsDirectory.class);
        Metadata gpsMixin = GisFeatures.extractMixin(gpsDir, getSemanticsScope(), image);
        Iterator<com.drew.metadata.Tag> gpsList = printDirectory(gpsDir);
        int qq = 33;
      }
    }
  }
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:42,代码来源:ImageParserAwt.java

示例10: readMetadata

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
public static Metadata readMetadata(InputStream in) throws TiffProcessingException
   {
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	int b;
	try {
		while((b = in.read()) != -1) {
			out.write(b);
		}
	} catch (IOException e) {
		throw new TiffProcessingException("Error processing tiff stream", e);
	}
       Metadata metadata = new Metadata();
	new ExifReader(out.toByteArray()).extractTiff(metadata);
	return metadata;
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:16,代码来源:TiffMetadataReader.java

示例11: testWindowsXpFields

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
public void testWindowsXpFields() throws Exception
{
    String fileName = "Source/com/drew/metadata/exif/test/windowsXpFields.jpg";
    Metadata metadata = new ExifReader(new File(fileName)).extract();
    Directory directory = metadata.getDirectory(ExifDirectory.class);
    ExifDescriptor descriptor = new ExifDescriptor(directory);
    assertEquals("Testing artist", descriptor.getDescription(ExifDirectory.TAG_WIN_AUTHOR));
    assertEquals("Testing comments", descriptor.getDescription(ExifDirectory.TAG_WIN_COMMENT));
    assertEquals("Testing keywords", descriptor.getDescription(ExifDirectory.TAG_WIN_KEYWORDS));
    assertEquals("Testing subject", descriptor.getDescription(ExifDirectory.TAG_WIN_SUBJECT));
    assertEquals("Testing title", descriptor.getDescription(ExifDirectory.TAG_WIN_TITLE));
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:13,代码来源:ExifDescriptorTest.java

示例12: setUp

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
protected void setUp() throws Exception
{
    File metadataFile = new File("Source/com/drew/metadata/exif/test/nikonMakernoteType2a.metadata");
    Metadata metadata = new ExifReader(JpegSegmentData.FromFile(metadataFile)).extract();

    _nikonDirectory = (NikonType2MakernoteDirectory)metadata.getDirectory(NikonType2MakernoteDirectory.class);
    _descriptor = new NikonType2MakernoteDescriptor(_nikonDirectory);
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:9,代码来源:NikonType2MakernoteTest1.java

示例13: testLoadFujiFilmJpeg

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
public void testLoadFujiFilmJpeg() throws Exception
    {
        String jpegWithExif = "Source/com/drew/metadata/exif/test/withExif.jpg";
        Metadata metadata = new ExifReader(new File(jpegWithExif)).extract();
        Directory directory = metadata.getDirectory(ExifDirectory.class);
        assertEquals("80", directory.getDescription(ExifDirectory.TAG_ISO_EQUIVALENT));
        // TODO decide if this should still be returned -- it was being calculated upon setting of a related tag
//      assertEquals("F9", directory.getDescription(ExifDirectory.TAG_APERTURE));
    }
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:10,代码来源:ExifReaderTest.java

示例14: testLoadJpegWithBadExifData

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
public void testLoadJpegWithBadExifData() throws Exception
{
    // This test used to ensure an exception was thrown when loading a particular jpeg
    // The intention has since changed, and the API should only throw exceptions in completely
    // fatal situations.  Now, the Metadata object returned has no new tags.
    String jpegBadExif = "Source/com/drew/metadata/exif/test/badExif.jpg"; // Exif data segment doesn't begin with 'Exif'
    Metadata metadata = new ExifReader(new File(jpegBadExif)).extract();
    assertEquals(0, metadata.getDirectory(ExifDirectory.class).getTagCount());
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:10,代码来源:ExifReaderTest.java

示例15: testCrashRegressionTest

import com.drew.metadata.exif.ExifReader; //导入依赖的package包/类
public void testCrashRegressionTest() throws Exception
{
    // this image was created via a resize in ACDSee
    // it seems to have a reference to an IFD starting outside the data segment
    // i've noticed that ACDSee reports a Comment for this image, yet ExifReader doesn't report one
    String fileName = "Source/com/drew/metadata/exif/test/crash01.jpg";
    Metadata metadata = new ExifReader(new File(fileName)).extract();
    assertTrue(metadata.getDirectory(ExifDirectory.class).getTagCount() > 0);
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:10,代码来源:ExifReaderTest.java


注:本文中的com.drew.metadata.exif.ExifReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。