gpt4 book ai didi

com.twelvemonkeys.imageio.metadata.xmp.XMPReader.read()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 20:13:05 27 4
gpt4 key购买 nike

本文整理了Java中com.twelvemonkeys.imageio.metadata.xmp.XMPReader.read()方法的一些代码示例,展示了XMPReader.read()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMPReader.read()方法的具体详情如下:
包路径:com.twelvemonkeys.imageio.metadata.xmp.XMPReader
类名称:XMPReader
方法名:read

XMPReader.read介绍

暂无

代码示例

代码示例来源:origin: haraldk/TwelveMonkeys

Directory parseDirectory() throws IOException {
    // Chop off potential trailing null-termination/padding that SAX parsers don't like...
    int len = data.length;
    for (; len > 0; len--) {
      if (data[len - 1] != 0) {
        break;
      }
    }

    return new XMPReader().read(new ByteArrayImageInputStream(data, 0, len));
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFSeq() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-seq-example.xml"));
  assertEquals(1, directory.size());
  assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(Arrays.asList("XMP", "metadata", "ISO standard")));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFBag() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-bag-example.xml"));
  assertEquals(1, directory.size());
  assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(Arrays.asList("XMP", "metadata", "ISO standard"))); // Order does not matter
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCompoundDirectoryContentDC() throws IOException {
  Directory directory = createReader().read(getDataAsIIS());
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // dc|http://purl.org/dc/elements/1.1/
  Directory dc = compound.getDirectory(2);
  assertEquals(2, dc.size());
  assertThat(dc.getEntryById("http://purl.org/dc/elements/1.1/description"), hasValue(Collections.singletonMap("x-default", "Picture 71146")));
  assertThat(dc.getEntryById("http://purl.org/dc/elements/1.1/format"), hasValue("image/jpeg"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFAttributeSyntaxCompoundDirectoryContentDC() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // dc|http://purl.org/dc/elements/1.1/
  Directory dc = getDirectoryByNS(compound, XMP.NS_DC);
  assertEquals(1, dc.size());
  assertThat(dc.getEntryById("http://purl.org/dc/elements/1.1/format"), hasValue("image/jpeg"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCompoundDirectory() throws IOException {
  Directory directory = createReader().read(getDataAsIIS());
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  assertEquals(6, compound.directoryCount());
  int size = 0;
  for (int i = 0; i < compound.directoryCount(); i++) {
    Directory sub = compound.getDirectory(i);
    assertNotNull(sub);
    size += sub.size();
  }
  assertEquals(directory.size(), size);
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFAttributeSyntaxCompound() throws IOException {
  // Alternate RDF syntax, using attribute values instead of nested tags
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  assertEquals(6, compound.directoryCount());
  int size = 0;
  for (int i = 0; i < compound.directoryCount(); i++) {
    Directory sub = compound.getDirectory(i);
    assertNotNull(sub);
    size += sub.size();
  }
  assertEquals(directory.size(), size);
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFAttributeSyntaxCompoundDirectoryContentPhotoshop() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // photoshop|http://ns.adobe.com/photoshop/1.0/
  Directory photoshop = getDirectoryByNS(compound, XMP.NS_PHOTOSHOP);
  assertEquals(3, photoshop.size());
  assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/ColorMode"), hasValue("1"));
  assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/ICCProfile"), hasValue("Dot Gain 20%"));
  assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/History"), hasValue(""));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFAlt() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-alt-example.xml"));
  assertEquals(1, directory.size());
  assertThat(directory.getEntryById("http://purl.org/dc/elements/1.1/subject"), hasValue(new HashMap<String, String>() {{
    put("x-default", "One");
    put("en-us", "One");
    put("de", "Ein");
    put("no-nb", "En");
  }}));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCompoundDirectoryContentEXIF() throws IOException {
  Directory directory = createReader().read(getDataAsIIS());
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // exif|http://ns.adobe.com/exif/1.0/
  Directory exif = compound.getDirectory(5);
  assertEquals(4, exif.size());
  assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/ColorSpace"), hasValue("-1")); // SIC. Same as unsigned short 65535, meaning "uncalibrated"?
  assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/PixelXDimension"), hasValue("3601"));
  assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/PixelYDimension"), hasValue("4176"));
  assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/NativeDigest"), hasValue("36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;297AD344CC15F29D5283460ED026368F"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFAttributeSyntaxCompoundDirectoryContentXAP() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // xap|http://ns.adobe.com/xap/1.0/
  Directory xap = getDirectoryByNS(compound, XMP.NS_XAP);
  assertEquals(4, xap.size());
  assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/ModifyDate"), hasValue("2008-07-16T14:44:49-07:00"));
  assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/CreatorTool"), hasValue("Adobe Photoshop CS3 Windows"));
  assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/CreateDate"), hasValue("2008-07-16T14:44:49-07:00"));
  assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/MetadataDate"), hasValue("2008-07-16T14:44:49-07:00"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCompoundDirectoryContentMM() throws IOException {
  Directory directory = createReader().read(getDataAsIIS());
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // xapMM|http://ns.adobe.com/xap/1.0/mm/
  Directory mm = compound.getDirectory(1);
  assertEquals(3, mm.size());
  assertThat(mm.getEntryById("http://ns.adobe.com/xap/1.0/mm/DocumentID"), hasValue("uuid:54A8D5F8654711DD9226A85E1241887A"));
  assertThat(mm.getEntryById("http://ns.adobe.com/xap/1.0/mm/InstanceID"), hasValue("uuid:54A8D5F9654711DD9226A85E1241887A"));
  assertThat(mm.getEntryById("http://ns.adobe.com/xap/1.0/mm/DerivedFrom"), hasValue(
      new RDFDescription(Arrays.asList(
          // stRef|http://ns.adobe.com/xap/1.0/sType/ResourceRef#
          new XMPEntry("http://ns.adobe.com/xap/1.0/sType/ResourceRef#instanceID", "instanceID", "uuid:3B52F3610F49DD118831FCA29C13B8DE"),
          new XMPEntry("http://ns.adobe.com/xap/1.0/sType/ResourceRef#documentID", "documentID", "uuid:3A52F3610F49DD118831FCA29C13B8DE")
      ))
  ));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCompoundDirectoryContentPhotoshop() throws IOException {
  Directory directory = createReader().read(getDataAsIIS());
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // photoshop|http://ns.adobe.com/photoshop/1.0/
  Directory photoshop = compound.getDirectory(0);
  assertEquals(4, photoshop.size());
  assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/DateCreated"), hasValue("2008-07-01"));
  assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/ColorMode"), hasValue("4"));
  assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/ICCProfile"), hasValue("U.S. Web Coated (SWOP) v2"));
  assertThat(photoshop.getEntryById("http://ns.adobe.com/photoshop/1.0/History"), hasValue(""));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCompoundDirectoryContentXAP() throws IOException {
  Directory directory = createReader().read(getDataAsIIS());
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // xap|http://ns.adobe.com/xap/1.0/
  Directory xap = compound.getDirectory(4);
  assertEquals(4, xap.size());
  assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/ModifyDate"), hasValue("2008-08-06T12:43:05+10:00"));
  assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/CreatorTool"), hasValue("Adobe Photoshop CS2 Macintosh"));
  assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/CreateDate"), hasValue("2008-08-06T12:43:05+10:00"));
  assertThat(xap.getEntryById("http://ns.adobe.com/xap/1.0/MetadataDate"), hasValue("2008-08-06T12:43:05+10:00"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
  public void testRDFAttributeSyntaxCompoundDirectoryContentEXIF() throws IOException {
    Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));

    assertThat(directory, instanceOf(CompoundDirectory.class));
    CompoundDirectory compound = (CompoundDirectory) directory;

    // exif|http://ns.adobe.com/exif/1.0/
    Directory exif = getDirectoryByNS(compound, XMP.NS_EXIF);
    assertEquals(4, exif.size());
    assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/ColorSpace"), hasValue("-1")); // SIC. Same as unsigned short 65535, meaning "uncalibrated"?
    assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/PixelXDimension"), hasValue("426"));
    assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/PixelYDimension"), hasValue("550"));
    assertThat(exif.getEntryById("http://ns.adobe.com/exif/1.0/NativeDigest"), hasValue("36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;A7F21D25E2C562F152B2C4ECC9E534DA"));
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFAttributeSyntaxCompoundDirectoryContentMM() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // xapMM|http://ns.adobe.com/xap/1.0/mm/
  Directory mm = getDirectoryByNS(compound, XMP.NS_XAP_MM);
  assertEquals(3, mm.size());
  assertThat(directory.getEntryById("http://ns.adobe.com/xap/1.0/mm/DocumentID"), hasValue("uuid:6DCA50CC7D53DD119F20F5A7EA4C9BEC"));
  assertThat(directory.getEntryById("http://ns.adobe.com/xap/1.0/mm/InstanceID"), hasValue("uuid:6ECA50CC7D53DD119F20F5A7EA4C9BEC"));
  // Custom test, as NamedNodeMap does not preserve order (tests can't rely on XML impl specifics)
  Entry derivedFrom = directory.getEntryById("http://ns.adobe.com/xap/1.0/mm/DerivedFrom");
  assertNotNull(derivedFrom);
  assertThat(derivedFrom.getValue(), instanceOf(RDFDescription.class));
  // stRef|http://ns.adobe.com/xap/1.0/sType/ResourceRef#
  RDFDescription stRef = (RDFDescription) derivedFrom.getValue();
  assertThat(stRef.getEntryById("http://ns.adobe.com/xap/1.0/sType/ResourceRef#instanceID"), hasValue("uuid:74E1C905B405DD119306A1902BA5AA28"));
  assertThat(stRef.getEntryById("http://ns.adobe.com/xap/1.0/sType/ResourceRef#documentID"), hasValue("uuid:7A6C79768005DD119306A1902BA5AA28"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFAttributeSyntaxCompoundDirectoryContentTIFF() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // tiff|http://ns.adobe.com/tiff/1.0/
  Directory tiff = getDirectoryByNS(compound, XMP.NS_TIFF);
  assertEquals(5, tiff.size());
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/Orientation"), hasValue("1"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/XResolution"), hasValue("720000/10000"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/YResolution"), hasValue("720000/10000"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/ResolutionUnit"), hasValue("2"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/NativeDigest"), hasValue("256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;C08D8E93274C4BEE83E86CF999955A87"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCompoundDirectoryContentTIFF() throws IOException {
  Directory directory = createReader().read(getDataAsIIS());
  assertThat(directory, instanceOf(CompoundDirectory.class));
  CompoundDirectory compound = (CompoundDirectory) directory;
  // tiff|http://ns.adobe.com/tiff/1.0/
  Directory tiff = compound.getDirectory(3);
  assertEquals(12, tiff.size());
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/ImageWidth"), hasValue("3601"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/ImageLength"), hasValue("4176"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/BitsPerSample"), hasValue(Arrays.asList("8", "8", "8")));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/Compression"), hasValue("1"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/PhotometricInterpretation"), hasValue("2"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/SamplesPerPixel"), hasValue("3"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/PlanarConfiguration"), hasValue("1"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/XResolution"), hasValue("3000000/10000"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/YResolution"), hasValue("3000000/10000"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/ResolutionUnit"), hasValue("2"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/Orientation"), hasValue("1"));
  assertThat(tiff.getEntryById("http://ns.adobe.com/tiff/1.0/NativeDigest"), hasValue("256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;C21EE6D33E4CCA3712ECB1F5E9031A49"));
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testDirectoryContent() throws IOException {
  Directory directory = createReader().read(getDataAsIIS());

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRDFAttributeSyntax() throws IOException {
  Directory directory = createReader().read(getResourceAsIIS("/xmp/rdf-attribute-shorthand.xml"));

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com