Package com.drew.metadata

Examples of com.drew.metadata.Directory


                @SuppressWarnings("unchecked")
                final
                Iterator<Directory> directories = metadata.getDirectoryIterator();
                final HashMap<String, String> props = new HashMap<String, String>();
                while (directories.hasNext()) {
                    final Directory directory = directories.next();
                    @SuppressWarnings("unchecked")
                    final
                    Iterator<Tag> tags = directory.getTagIterator();
                    while (tags.hasNext()) {
                        final Tag tag = tags.next();
                        try {
                            props.put(tag.getTagName(), tag.getDescription());
                            ii.info.append(tag.getTagName() + ": " + tag.getDescription() + " .\n");
View Full Code Here


{
    @Test
    public void testGetDirectoryName() throws Exception
    {
        Metadata metadata = new Metadata();
        Directory subIFDDirectory = metadata.getOrCreateDirectory(ExifSubIFDDirectory.class);
        Directory ifd0Directory = metadata.getOrCreateDirectory(ExifIFD0Directory.class);
        Directory thumbDirectory = metadata.getOrCreateDirectory(ExifThumbnailDirectory.class);

        Assert.assertFalse(subIFDDirectory.hasErrors());

        Assert.assertEquals("Exif IFD0", ifd0Directory.getName());
        Assert.assertEquals("Exif SubIFD", subIFDDirectory.getName());
        Assert.assertEquals("Exif Thumbnail", thumbDirectory.getName());
    }
View Full Code Here

    public void testLoadJpegWithNoExifData() throws Exception
    {
        byte[] badExifData = new byte[]{ 1,2,3,4,5,6,7,8,9,10 };
        Metadata metadata = new Metadata();
        new ExifReader().extract(new ByteArrayReader(badExifData), metadata);
        Directory directory = metadata.getDirectory(ExifSubIFDDirectory.class);

        Assert.assertNotNull(directory);
        Assert.assertEquals(0, directory.getTagCount());
    }
View Full Code Here

    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.
        Directory directory = readDirectoryFromJpegFile("Tests/com/drew/metadata/exif/crash01.jpg", ExifSubIFDDirectory.class);

        Assert.assertTrue(directory.getTagCount() > 0);
    }
View Full Code Here

    }

    @Test
    public void testDateTime() throws Exception
    {
        Directory directory = readDirectoryFromJpegFile("Tests/com/drew/metadata/exif/manuallyAddedThumbnail.jpg", ExifIFD0Directory.class);

        Assert.assertEquals("2002:11:27 18:00:35", directory.getString(ExifIFD0Directory.TAG_DATETIME));
    }
View Full Code Here

    }

    @Test
    public void testThumbnailXResolution() throws Exception
    {
        Directory directory = readDirectoryFromJpegFile("Tests/com/drew/metadata/exif/manuallyAddedThumbnail.jpg", ExifThumbnailDirectory.class);

        Rational rational = directory.getRational(ExifThumbnailDirectory.TAG_X_RESOLUTION);
        Assert.assertNotNull(rational);
        Assert.assertEquals(72, rational.getNumerator());
        Assert.assertEquals(1, rational.getDenominator());
    }
View Full Code Here

    }

    @Test
    public void testThumbnailYResolution() throws Exception
    {
        Directory directory = readDirectoryFromJpegFile("Tests/com/drew/metadata/exif/manuallyAddedThumbnail.jpg", ExifThumbnailDirectory.class);

        Rational rational = directory.getRational(ExifThumbnailDirectory.TAG_Y_RESOLUTION);
        Assert.assertNotNull(rational);
        Assert.assertEquals(72, rational.getNumerator());
        Assert.assertEquals(1, rational.getDenominator());
    }
View Full Code Here

    }

    @Test
    public void testThumbnailOffset() throws Exception
    {
        Directory directory = readDirectoryFromJpegFile("Tests/com/drew/metadata/exif/manuallyAddedThumbnail.jpg", ExifThumbnailDirectory.class);

        Assert.assertEquals(192, directory.getInt(ExifThumbnailDirectory.TAG_THUMBNAIL_OFFSET));
    }
View Full Code Here

    }

    @Test
    public void testThumbnailLength() throws Exception
    {
        Directory directory = readDirectoryFromJpegFile("Tests/com/drew/metadata/exif/manuallyAddedThumbnail.jpg", ExifThumbnailDirectory.class);

        Assert.assertEquals(2970, directory.getInt(ExifThumbnailDirectory.TAG_THUMBNAIL_LENGTH));
    }
View Full Code Here

    }

    @Test
    public void testThumbnailCompression() throws Exception
    {
        Directory directory = readDirectoryFromJpegFile("Tests/com/drew/metadata/exif/manuallyAddedThumbnail.jpg", ExifThumbnailDirectory.class);

        // 6 means JPEG compression
        Assert.assertEquals(6, directory.getInt(ExifThumbnailDirectory.TAG_THUMBNAIL_COMPRESSION));
    }
View Full Code Here

TOP

Related Classes of com.drew.metadata.Directory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.