Package com.drew.metadata

Examples of com.drew.metadata.Metadata


        assertTrue(exifDir.containsTag(ExifDirectory.TAG_APERTURE));
    }

    public void testGetNonExistantTag() throws Exception
    {
        Metadata metadata = new Metadata();
        Directory exifDir = metadata.getDirectory(ExifDirectory.class);
        assertEquals(null, exifDir.getString(ExifDirectory.TAG_APERTURE));
    }
View Full Code Here


        assertEquals(null, exifDir.getString(ExifDirectory.TAG_APERTURE));
    }

    public void testHasErrors() throws Exception
    {
        Metadata metadata = JpegMetadataReader.readMetadata(new File("src/com/drew/metadata/exif/test/badExif.jpg"));
        assertTrue("exif error", metadata.getDirectory(ExifDirectory.class).hasErrors());
        metadata = JpegMetadataReader.readMetadata(new File("src/com/drew/metadata/exif/test/withExif.jpg"));
        assertTrue("no errors", !metadata.getDirectory(ExifDirectory.class).hasErrors());
    }
View Full Code Here

        assertTrue("no errors", !metadata.getDirectory(ExifDirectory.class).hasErrors());
    }

    public void testGetErrors() throws Exception
    {
        Metadata metadata = JpegMetadataReader.readMetadata(new File("src/com/drew/metadata/exif/test/badExif.jpg"));
        Iterator errors = metadata.getDirectory(ExifDirectory.class).getErrors();
        assertTrue(errors.hasNext());
        String error = (String) errors.next();
        assertEquals("Exif data segment must contain at least 14 bytes", error);
        assertTrue(!errors.hasNext());
    }
View Full Code Here

        assertTrue(!errors.hasNext());
    }

    public void testGetErrorCount() throws Exception
    {
        Metadata metadata = JpegMetadataReader.readMetadata(new File("src/com/drew/metadata/exif/test/badExif.jpg"));
        assertEquals(1, metadata.getDirectory(ExifDirectory.class).getErrorCount());
    }
View Full Code Here

        assertEquals(1, metadata.getDirectory(ExifDirectory.class).getErrorCount());
    }

    public void testMetadataSerializable() throws Exception
    {
        Metadata metadata = JpegMetadataReader.readMetadata(new File("src/com/drew/metadata/test/withIptcExifGps.jpg"));
        new ObjectOutputStream(new NullOutputStream()).writeObject(metadata);
    }
View Full Code Here

        new ObjectOutputStream(new NullOutputStream()).writeObject(metadata);
    }

    public void testSerializeAndRestore() throws Exception
    {
        Metadata metadataWrite = JpegMetadataReader.readMetadata(new File("src/com/drew/metadata/test/withIptcExifGps.jpg"));
        Metadata metadataRead;
        File ser = File.createTempFile("test", "ser");
        try {
            // write the ser object
            new ObjectOutputStream(new FileOutputStream(ser)).writeObject(metadataWrite);
            // read the ser object
            metadataRead = (Metadata)new ObjectInputStream(new FileInputStream(ser)).readObject();
            // make sure they're equivalent
            // TODO should compare the two objects via iteration of directories and tags
            assertTrue(metadataRead.containsDirectory(ExifDirectory.class));
            assertTrue(metadataRead.containsDirectory(IptcDirectory.class));
        } finally {
            ser.delete();
        }
    }
View Full Code Here

    /**
     * Performs the Exif data extraction, returning a new instance of <code>Metadata</code>.
     */
    public Metadata extract()
    {
        return extract(new Metadata());
    }
View Full Code Here

    public void testDescription_City() throws Exception
    {
        File iptcFile = new File("src/com/drew/metadata/iptc/test/withIptc.jpg");
        MetadataReader reader = new IptcReader(iptcFile);
        Metadata metadata = reader.extract();
        assertTrue(metadata.containsDirectory(IptcDirectory.class));
        Directory directory = metadata.getDirectory(IptcDirectory.class);
        assertEquals("City", directory.getDescription(IptcDirectory.TAG_CITY));
    }
View Full Code Here

    public void testDescription_Caption() throws Exception
    {
        File iptcFile = new File("src/com/drew/metadata/iptc/test/withIptc.jpg");
        MetadataReader reader = new IptcReader(iptcFile);
        Metadata metadata = reader.extract();
        assertTrue(metadata.containsDirectory(IptcDirectory.class));
        Directory directory = metadata.getDirectory(IptcDirectory.class);
        assertEquals("Caption", directory.getDescription(IptcDirectory.TAG_CAPTION));
    }
View Full Code Here

    public void testDescription_Category() throws Exception
    {
        File iptcFile = new File("src/com/drew/metadata/iptc/test/withIptc.jpg");
        MetadataReader reader = new IptcReader(iptcFile);
        Metadata metadata = reader.extract();
        assertTrue(metadata.containsDirectory(IptcDirectory.class));
        Directory directory = metadata.getDirectory(IptcDirectory.class);
        assertEquals("Supl. Category2 Supl. Category1 Cat", directory.getDescription(IptcDirectory.TAG_CATEGORY));
    }
View Full Code Here

TOP

Related Classes of com.drew.metadata.Metadata

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.