Java Code Examples for javax.imageio.metadata.IIOMetadataNode#getAttribute()

The following examples show how to use javax.imageio.metadata.IIOMetadataNode#getAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ITXtTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 2
Source File: ITXtTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 3
Source File: ITXtTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 4
Source File: ITXtTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 5
Source File: ITXtTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 6
Source File: JpegMetadataColorSpaceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws IOException {
    String fileName = "nomarkers.jpg";
    String sep = System.getProperty("file.separator");
    String dir = System.getProperty("test.src", ".");
    String filePath = dir+sep+fileName;
    System.out.println("Test file: " + filePath);
    File file = new File(filePath);
    ImageInputStream stream = ImageIO.createImageInputStream(file);
    Iterator<ImageReader> readers = ImageIO.getImageReaders(stream);

    if(readers.hasNext()) {
        ImageReader reader = readers.next();
        reader.setInput(stream);
        IIOMetadata metadata = reader.getImageMetadata(0);

        IIOMetadataNode standardTree = (IIOMetadataNode)
            metadata.getAsTree
            (IIOMetadataFormatImpl.standardMetadataFormatName);
        IIOMetadataNode colorSpaceType = (IIOMetadataNode)
            standardTree.getElementsByTagName("ColorSpaceType").item(0);
        String colorSpaceName = colorSpaceType.getAttribute("name");
        if(colorSpaceName.equals("RGB"))
            throw new RuntimeException("Identified incorrect ColorSpace");
    }
}
 
Example 7
Source File: ITXtTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 8
Source File: ITXtTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 9
Source File: ITXtTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 10
Source File: ITXtTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 11
Source File: ITXtTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 12
Source File: ITXtTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 13
Source File: ITXtTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 14
Source File: ITXtTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static ITXtTest getFromNode(IIOMetadataNode n) {
    ITXtTest t = new ITXtTest();

    if (!"iTXt".equals(n.getNodeName())) {
        throw new RuntimeException("Invalid node");
    }
    IIOMetadataNode e = (IIOMetadataNode)n.getFirstChild();
    if (!"iTXtEntry".equals(e.getNodeName())) {
        throw new RuntimeException("Invalid entry node");
    }
    t.keyword = e.getAttribute("keyword");
    t.isCompressed =
        Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
    t.compression =
        Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
    t.language = e.getAttribute("languageTag");
    t.trasKeyword = e.getAttribute("translatedKeyword");
    t.text = e.getAttribute("text");

    return t;
}
 
Example 15
Source File: ExifReader.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("nls")
private void parseExifMeta( IIOMetadata exifMeta ) {
    outTags = new HashMap<String, ExifTag>();

    IIOMetadataNode root = (IIOMetadataNode) exifMeta.getAsTree("com_sun_media_imageio_plugins_tiff_image_1.0");

    NodeList imageDirectories = root.getElementsByTagName("TIFFIFD");
    for( int i = 0; i < imageDirectories.getLength(); i++ ) {
        IIOMetadataNode directory = (IIOMetadataNode) imageDirectories.item(i);

        NodeList tiffTags = directory.getElementsByTagName("TIFFField");
        for( int j = 0; j < tiffTags.getLength(); j++ ) {
            IIOMetadataNode tag = (IIOMetadataNode) tiffTags.item(j);

            String tagNumber = tag.getAttribute("number");
            String tagName = tag.getAttribute("name");
            String tagValue;

            StringBuilder tmp = new StringBuilder();
            IIOMetadataNode values = (IIOMetadataNode) tag.getFirstChild();

            if ("TIFFUndefined".equals(values.getNodeName())) {
                tmp.append(values.getAttribute("value"));
            } else {
                NodeList tiffNumbers = values.getChildNodes();
                for( int k = 0; k < tiffNumbers.getLength(); k++ ) {
                    tmp.append(((IIOMetadataNode) tiffNumbers.item(k)).getAttribute("value"));
                    tmp.append(",");
                }
                tmp.deleteCharAt(tmp.length() - 1);
            }

            tagValue = tmp.toString();

            ExifTag exifTag = new ExifTag(tagName, tagNumber, tagValue);
            outTags.put(tagName, exifTag);
        }
    }
}