热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javax.imageio.metadata.IIOMetadataNode.getAttribute()方法的使用及代码示例

本文整理了Java中javax.imageio.metadata.IIOMetadataNode.getAttribute()方法的一些代码示例,展示了II

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

IIOMetadataNode.getAttribute介绍

暂无

代码示例

代码示例来源:origin: org.springframework.boot/spring-boot

private int getDelayTime(ImageReader reader, int imageIndex) throws IOException {
IIOMetadata metadata = reader.getImageMetadata(imageIndex);
IIOMetadataNode root = (IIOMetadataNode) metadata
.getAsTree(metadata.getNativeMetadataFormatName());
IIOMetadataNode extension = findNode(root, "GraphicControlExtension");
String attribute = (extension != null) ? extension.getAttribute("delayTime")
: null;
return (attribute != null) ? Integer.parseInt(attribute) * 10 : 0;
}

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

int compOnents= Integer.parseInt(startOfFrame.getAttribute("numFrameComponents"));
int transform = Integer.parseInt(adobe.getAttribute("transform"));
int cid0 = Integer.parseInt(((IIOMetadataNode) componentSpecs.item(0)).getAttribute("componentId"));
int cid1 = Integer.parseInt(((IIOMetadataNode) componentSpecs.item(1)).getAttribute("componentId"));
int cid2 = Integer.parseInt(((IIOMetadataNode) componentSpecs.item(2)).getAttribute("componentId"));
int transform = Integer.parseInt(adobe.getAttribute("transform"));
int cid0 = Integer.parseInt(((IIOMetadataNode) componentSpecs.item(0)).getAttribute("componentId"));
int cid1 = Integer.parseInt(((IIOMetadataNode) componentSpecs.item(1)).getAttribute("componentId"));
int cid2 = Integer.parseInt(((IIOMetadataNode) componentSpecs.item(2)).getAttribute("componentId"));
int cid3 = Integer.parseInt(((IIOMetadataNode) componentSpecs.item(3)).getAttribute("componentId"));

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

protected final void writeComments(final IIOMetadata metadata, final ImageWriterSpi provider) throws IOException {
// TODO: Only write creator if not already present
imageOutput.write(String.format("# CREATOR: %s %s\n", provider.getVendorName(), provider.getDescription(Locale.getDefault())).getBytes(UTF8));
// Comments from metadata
if (metadata != null && metadata.isStandardMetadataFormatSupported()) {
IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);
NodeList textEntries = root.getElementsByTagName("TextEntry");
for (int i = 0; i // TODO: Write on the format "# KEYWORD: value" (if keyword != comment)?
IIOMetadataNode textEntry = (IIOMetadataNode) textEntries.item(i);
imageOutput.write(String.format("# %s", textEntry.getAttribute("value")).getBytes(UTF8));
}
}
}

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

private void forceComponentIdInRange(final IIOMetadataNode component, final String attributeName) {
String attribute = component.getAttribute(attributeName);
if (attribute != null) {
try {
int compOnentId= Integer.parseInt(attribute);
if (componentId <0) {
// Metadata doesn't like negative component ids/specs
// We'll convert to the positive value it probably should have been
compOnentId= ((byte) componentId) & 0xff;
component.setAttribute(attributeName, String.valueOf(componentId));
}
}
catch (NumberFormatException ignore) {
if ("scanComponentSpec".equals(component.getNodeName())) {
reader.processWarningOccurred("Bad SOS component selector: " + attribute);
}
else {
reader.processWarningOccurred("Bad SOF component id: " + attribute);
}
}
}
}
}

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

Object actualUserObject = ((IIOMetadataNode) actualTree).getUserObject();
assertNotNull(String.format("%s: User object missing for <%s>", message, expectedTree.getNodeName()), actualUserObject);
assertEqualUserObjects(String.format("%s: User objects for <%s MarkerTag\"%s\"> differ", message, expectedTree.getNodeName(), ((IIOMetadataNode) expectedTree).getAttribute("MarkerTag")), expectedUserObject, actualUserObject);

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

@Test
public void testReadUnicodeLayerName() throws IOException {
PSDImageReader imageReader = createReader();
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/psd/long-layer-names.psd"))) {
imageReader.setInput(stream);
IIOMetadata metadata = imageReader.getImageMetadata(0);
IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(PSDMetadata.NATIVE_METADATA_FORMAT_NAME);
NodeList layerInfo = root.getElementsByTagName("LayerInfo");
assertEquals(1, layerInfo.getLength()); // Sanity
assertEquals("If_The_Layer_Name_Is_Really_Long_Oh_No_What_Do_I_Do", ((IIOMetadataNode) layerInfo.item(0)).getAttribute("name"));
}
}
}

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

@Test
public void testTranscodeWithMetadataCMYKtoCMYK() throws IOException {
ImageWriter writer = createImageWriter();
ImageReader reader = ImageIO.getImageReader(writer);
ByteArrayOutputStream stream = transcode(reader, getClassLoaderResource("/jpeg/cmyk-sample-multiple-chunk-icc.jpg"), writer, ColorSpace.TYPE_CMYK);
reader.reset();
reader.setInput(new ByteArrayImageInputStream(stream.toByteArray()));
BufferedImage image = reader.read(0);
assertNotNull(image);
assertEquals(100, image.getWidth());
assertEquals(100, image.getHeight());
IIOMetadata metadata = reader.getImageMetadata(0);
IIOMetadataNode standard = (IIOMetadataNode) metadata.getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);
NodeList colorSpaceType = standard.getElementsByTagName("ColorSpaceType");
assertEquals(1, colorSpaceType.getLength());
assertEquals("CMYK", ((IIOMetadataNode) colorSpaceType.item(0)).getAttribute("name"));
}

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

if (csType.getAttribute("name") != null) {
chroma.appendChild(csType);

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

@Test
public void testImageMetadata1ChannelGrayWithBogusAdobeYCC() throws IOException {
JPEGImageReader reader = createReader();
try {
// Any sample should do here
reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/invalid-adobe-ycc-gray-with-metadata.jpg")));
IIOMetadata metadata = reader.getImageMetadata(0);
IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);
IIOMetadataNode chroma = getSingleElementByName(root, "Chroma");
IIOMetadataNode numChannels = getSingleElementByName(chroma, "NumChannels");
assertEquals("1", numChannels.getAttribute("value"));
IIOMetadataNode colorSpaceType = getSingleElementByName(chroma, "ColorSpaceType");
assertEquals("GRAY", colorSpaceType.getAttribute("name"));
}
finally {
reader.dispose();
}
}

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

if (csType.getAttribute("name") != null) {
chroma.appendChild(csType);

代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.imageio/imageio-tiff

private boolean needsCSConversion(final int photometricInterpretation, final IIOMetadata imageMetadata) throws IOException {
if (imageMetadata == null) {
// Assume we're ok
return false;
}
IIOMetadataNode stdTree = (IIOMetadataNode) imageMetadata.getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);
NodeList csTypes = stdTree.getElementsByTagName("ColorSpaceType");
if (csTypes != null && csTypes.getLength() > 0) {
IIOMetadataNode csType = (IIOMetadataNode) csTypes.item(0);
String csName = csType.getAttribute("name");
if ("YCbCr".equals(csName) && photometricInterpretation == TIFFExtension.PHOTOMETRIC_YCBCR
|| "RGB".equals(csName) && photometricInterpretation == TIFFBaseline.PHOTOMETRIC_RGB
|| "GRAY".equals(csName) && photometricInterpretation == TIFFBaseline.PHOTOMETRIC_BLACK_IS_ZERO) {
return false;
}
else {
// CMYK, or may happen because the JPEG stream is not subsampled,
// fooling the JPEGImageReader to believe the data is RGB, while it is YCbCr
if (DEBUG) {
System.out.println("Incompatible JPEG CS/PhotometricInterpretation: " + csName + "/" + photometricInterpretation);
}
return true;
}
}
// We don't really know, assume it's ok...
return false;
}

代码示例来源:origin: org.apache.xmlgraphics/xmlgraphics-commons

private double getHorizontalPixelSize(IIOMetadata meta) {
double result = 0;
IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(STANDARD_METADATA_FORMAT);
IIOMetadataNode dim = getChildNode(root, DIMENSION);
if (dim != null) {
IIOMetadataNode horz = getChildNode(dim, HORIZONTAL_PIXEL_SIZE);
if (horz != null) {
result = Double.parseDouble(horz.getAttribute("value"));
}
}
return result;
}

代码示例来源:origin: com.twelvemonkeys.imageio/imageio-jpeg

private void forceComponentIdInRange(final IIOMetadataNode component, final String attributeName) {
String attribute = component.getAttribute(attributeName);
if (attribute != null) {
try {
int compOnentId= Integer.parseInt(attribute);
if (componentId <0) {
// Metadata doesn't like negative component ids/specs
// We'll convert to the positive value it probably should have been
compOnentId= ((byte) componentId) & 0xff;
component.setAttribute(attributeName, String.valueOf(componentId));
}
}
catch (NumberFormatException ignore) {
if ("scanComponentSpec".equals(component.getNodeName())) {
reader.processWarningOccurred("Bad SOS component selector: " + attribute);
}
else {
reader.processWarningOccurred("Bad SOF component id: " + attribute);
}
}
}
}
}

代码示例来源:origin: com.talanlabs/jlegofy

private static void toGif(String src, String dst, Double precision) throws IOException, JLegofyException {
ImageReader reader = ImageIO.getImageReadersByFormatName("gif").next();
ImageInputStream ciis = ImageIO.createImageInputStream(new File(src));
reader.setInput(ciis, false);
int noi = reader.getNumImages(true);
ImageOutputStream cios = ImageIO.createImageOutputStream(new File(dst));
GifSequenceWriter g = new GifSequenceWriter(cios, BufferedImage.TYPE_INT_RGB, 50, true);
int timeBetweenFramesMS = 50;
for (int i = 0; i BufferedImage image = reader.read(i);
IIOMetadata metadata = reader.getImageMetadata(i);
IIOMetadataNode tree = (IIOMetadataNode) metadata.getAsTree(metadata.getNativeMetadataFormatName());
NodeList children = tree.getChildNodes();
for (int j = 0; j IIOMetadataNode nodeItem = (IIOMetadataNode) children.item(j);
if ("GraphicControlExtension".equals(nodeItem.getNodeName())) {
timeBetweenFramesMS = Integer.parseInt(nodeItem.getAttribute("delayTime")) * 10;
}
}
g.writeToSequence(new JLegofyEngine().toLegofy(image, precision), timeBetweenFramesMS);
}
cios.close();
}
}

代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.imageio/imageio-jpeg

Object actualUserObject = ((IIOMetadataNode) actualTree).getUserObject();
assertNotNull(String.format("%s: User object missing for <%s>", message, expectedTree.getNodeName()), actualUserObject);
assertEqualUserObjects(String.format("%s: User objects for <%s MarkerTag\"%s\"> differ", message, expectedTree.getNodeName(), ((IIOMetadataNode) expectedTree).getAttribute("MarkerTag")), expectedUserObject, actualUserObject);

代码示例来源:origin: stackoverflow.com

System.out.println(graphicsControlExtensionNode.getAttribute("delayTime"));

代码示例来源:origin: com.twelvemonkeys.imageio/imageio-psd

@Test
public void testReadUnicodeLayerName() throws IOException {
PSDImageReader imageReader = createReader();
try (ImageInputStream stream = ImageIO.createImageInputStream(getClassLoaderResource("/psd/long-layer-names.psd"))) {
imageReader.setInput(stream);
IIOMetadata metadata = imageReader.getImageMetadata(0);
IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(PSDMetadata.NATIVE_METADATA_FORMAT_NAME);
NodeList layerInfo = root.getElementsByTagName("LayerInfo");
assertEquals(1, layerInfo.getLength()); // Sanity
assertEquals("If_The_Layer_Name_Is_Really_Long_Oh_No_What_Do_I_Do", ((IIOMetadataNode) layerInfo.item(0)).getAttribute("name"));
}
}
}

代码示例来源:origin: com.twelvemonkeys.imageio/imageio-jpeg

@Test
public void testTranscodeWithMetadataCMYKtoCMYK() throws IOException {
ImageWriter writer = createImageWriter();
ImageReader reader = ImageIO.getImageReader(writer);
ByteArrayOutputStream stream = transcode(reader, getClassLoaderResource("/jpeg/cmyk-sample-multiple-chunk-icc.jpg"), writer, ColorSpace.TYPE_CMYK);
reader.reset();
reader.setInput(new ByteArrayImageInputStream(stream.toByteArray()));
BufferedImage image = reader.read(0);
assertNotNull(image);
assertEquals(100, image.getWidth());
assertEquals(100, image.getHeight());
IIOMetadata metadata = reader.getImageMetadata(0);
IIOMetadataNode standard = (IIOMetadataNode) metadata.getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);
NodeList colorSpaceType = standard.getElementsByTagName("ColorSpaceType");
assertEquals(1, colorSpaceType.getLength());
assertEquals("CMYK", ((IIOMetadataNode) colorSpaceType.item(0)).getAttribute("name"));
}

代码示例来源:origin: com.twelvemonkeys.imageio/imageio-jpeg

@Test
public void testImageMetadata1ChannelGrayWithBogusAdobeYCC() throws IOException {
JPEGImageReader reader = createReader();
try {
// Any sample should do here
reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/invalid-adobe-ycc-gray-with-metadata.jpg")));
IIOMetadata metadata = reader.getImageMetadata(0);
IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);
IIOMetadataNode chroma = getSingleElementByName(root, "Chroma");
IIOMetadataNode numChannels = getSingleElementByName(chroma, "NumChannels");
assertEquals("1", numChannels.getAttribute("value"));
IIOMetadataNode colorSpaceType = getSingleElementByName(chroma, "ColorSpaceType");
assertEquals("GRAY", colorSpaceType.getAttribute("name"));
}
finally {
reader.dispose();
}
}

代码示例来源:origin: com.github.lafa.twelvemonkeyspurejava.imageio/imageio-jpeg

@Test
public void testImageMetadata1ChannelGrayWithBogusAdobeYCC() throws IOException {
JPEGImageReader reader = createReader();
try {
// Any sample should do here
reader.setInput(ImageIO.createImageInputStream(getClassLoaderResource("/jpeg/invalid-adobe-ycc-gray-with-metadata.jpg")));
IIOMetadata metadata = reader.getImageMetadata(0);
IIOMetadataNode root = (IIOMetadataNode) metadata.getAsTree(IIOMetadataFormatImpl.standardMetadataFormatName);
IIOMetadataNode chroma = getSingleElementByName(root, "Chroma");
IIOMetadataNode numChannels = getSingleElementByName(chroma, "NumChannels");
assertEquals("1", numChannels.getAttribute("value"));
IIOMetadataNode colorSpaceType = getSingleElementByName(chroma, "ColorSpaceType");
assertEquals("GRAY", colorSpaceType.getAttribute("name"));
}
finally {
reader.dispose();
}
}

推荐阅读
  • 本文深入解析了JDK 8中HashMap的源代码,重点探讨了put方法的工作机制及其内部参数的设定原理。HashMap允许键和值为null,但键为null的情况只能出现一次,因为null键在内部通过索引0进行存储。文章详细分析了capacity(容量)、size(大小)、loadFactor(加载因子)以及红黑树转换阈值的设定原则,帮助读者更好地理解HashMap的高效实现和性能优化策略。 ... [详细]
  • 本文详细介绍了 PHP 中对象的生命周期、内存管理和魔术方法的使用,包括对象的自动销毁、析构函数的作用以及各种魔术方法的具体应用场景。 ... [详细]
  • 本文详细介绍了 Pentaho Kettle 中 RowMetaInterface.writeMeta 方法的使用,并提供了多个代码示例,帮助开发者更好地理解和应用该方法。 ... [详细]
  • JUC(三):深入解析AQS
    本文详细介绍了Java并发工具包中的核心类AQS(AbstractQueuedSynchronizer),包括其基本概念、数据结构、源码分析及核心方法的实现。 ... [详细]
  • 本文详细介绍了在 CentOS 7 系统中配置 fstab 文件以实现开机自动挂载 NFS 共享目录的方法,并解决了常见的配置失败问题。 ... [详细]
  • com.sun.javadoc.PackageDoc.exceptions()方法的使用及代码示例 ... [详细]
  • 零拷贝技术是提高I/O性能的重要手段,常用于Java NIO、Netty、Kafka等框架中。本文将详细解析零拷贝技术的原理及其应用。 ... [详细]
  • 在多线程并发环境中,普通变量的操作往往是线程不安全的。本文通过一个简单的例子,展示了如何使用 AtomicInteger 类及其核心的 CAS 无锁算法来保证线程安全。 ... [详细]
  • com.hazelcast.config.MapConfig.isStatisticsEnabled()方法的使用及代码示例 ... [详细]
  • 在机器学习领域,深入探讨了概率论与数理统计的基础知识,特别是这些理论在数据挖掘中的应用。文章重点分析了偏差(Bias)与方差(Variance)之间的平衡问题,强调了方差反映了不同训练模型之间的差异,例如在K折交叉验证中,不同模型之间的性能差异显著。此外,还讨论了如何通过优化模型选择和参数调整来有效控制这一平衡,以提高模型的泛化能力。 ... [详细]
  • 优化后的标题:深入探讨网关安全:将微服务升级为OAuth2资源服务器的最佳实践
    本文深入探讨了如何将微服务升级为OAuth2资源服务器,以订单服务为例,详细介绍了在POM文件中添加 `spring-cloud-starter-oauth2` 依赖,并配置Spring Security以实现对微服务的保护。通过这一过程,不仅增强了系统的安全性,还提高了资源访问的可控性和灵活性。文章还讨论了最佳实践,包括如何配置OAuth2客户端和资源服务器,以及如何处理常见的安全问题和错误。 ... [详细]
  • 本文介绍了如何利用ObjectMapper实现JSON与JavaBean之间的高效转换。ObjectMapper是Jackson库的核心组件,能够便捷地将Java对象序列化为JSON格式,并支持从JSON、XML以及文件等多种数据源反序列化为Java对象。此外,还探讨了在实际应用中如何优化转换性能,以提升系统整体效率。 ... [详细]
  • 在Ubuntu上安装MySQL时解决缺少libaio.so.1错误及libaio在MySQL中的重要性分析
    在Ubuntu系统上安装MySQL时,遇到了缺少libaio.so.1的错误。本文详细介绍了如何解决这一问题,并深入探讨了libaio库在MySQL性能优化中的重要作用。对于初学者而言,理解这些依赖关系和配置步骤是成功安装和运行MySQL的关键。通过本文的指导,读者可以顺利解决相关问题,并更好地掌握MySQL在Linux环境下的部署与管理。 ... [详细]
  • 数据库多表联合查询:内连接与外连接详解
    在数据库的多表查询中,内连接和外连接是两种常用的技术手段。内连接用于检索多个表中相互匹配的记录,即只有当两个表中的记录满足特定的连接条件时,这些记录才会被包含在查询结果中。相比之下,外连接则不仅返回匹配的记录,还可以选择性地返回不匹配的记录,具体取决于左外连接、右外连接或全外连接的选择。本文将详细解析这两种连接方式的使用场景及其语法结构,帮助读者更好地理解和应用多表查询技术。 ... [详细]
  • Android中将独立SO库封装进JAR包并实现SO库的加载与调用
    在Android开发中,将独立的SO库封装进JAR包并实现其加载与调用是一个常见的需求。本文详细介绍了如何将SO库嵌入到JAR包中,并确保在外部应用调用该JAR包时能够正确加载和使用这些SO库。通过这种方式,开发者可以更方便地管理和分发包含原生代码的库文件,提高开发效率和代码复用性。文章还探讨了常见的问题及其解决方案,帮助开发者避免在实际应用中遇到的坑。 ... [详细]
author-avatar
minoz-uuuu
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有