Package com.drew.metadata.exif

Examples of com.drew.metadata.exif.ExifDirectory.containsTag()


    public void testGetThumbnailData() throws Exception
    {
        File file = new File("src/com/drew/metadata/exif/test/withExif.jpg");
        Metadata metadata = JpegMetadataReader.readMetadata(file);
        ExifDirectory exifDirectory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class);
        assertTrue(exifDirectory.containsTag(ExifDirectory.TAG_THUMBNAIL_DATA));
        byte[] thumbData = exifDirectory.getThumbnailData();
        try {
            // attempt to read the thumbnail -- it should be a legal Jpeg file
            new JpegSegmentReader(thumbData);
        } catch (JpegProcessingException e) {
View Full Code Here


    public void testWriteThumbnail() throws Exception
    {
        File file = new File("src/com/drew/metadata/exif/test/manuallyAddedThumbnail.jpg");
        Metadata metadata = JpegMetadataReader.readMetadata(file);
        ExifDirectory exifDirectory = (ExifDirectory)metadata.getDirectory(ExifDirectory.class);
        assertTrue(exifDirectory.containsTag(ExifDirectory.TAG_THUMBNAIL_DATA));

        File thumbnailFile = File.createTempFile("thumbnail", ".jpg");
        try {
            exifDirectory.writeThumbnail(thumbnailFile.getAbsolutePath());
            assertTrue(new File(thumbnailFile.getAbsolutePath()).exists());
View Full Code Here

        assertFalse(new ImageMetadataExtractor.ExifHandler().supports(JpegCommentDirectory.class));
    }
   
    public void testExifHandlerParseDate() throws MetadataException {
        ExifDirectory exif = mock(ExifDirectory.class);
        when(exif.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)).thenReturn(true);
        when(exif.getDate(ExifDirectory.TAG_DATETIME_ORIGINAL)).thenReturn(
                new GregorianCalendar(2000, 0, 1, 0, 0, 0).getTime()); // jvm default timezone as in Metadata Extractor
        Metadata metadata = new Metadata();
       
        new ImageMetadataExtractor.ExifHandler().handle(exif, metadata);
View Full Code Here

                metadata.get(TikaCoreProperties.CREATED));
    }

    public void testExifHandlerParseDateFallback() throws MetadataException {
        ExifDirectory exif = mock(ExifDirectory.class);
        when(exif.containsTag(ExifDirectory.TAG_DATETIME)).thenReturn(true);
        when(exif.getDate(ExifDirectory.TAG_DATETIME)).thenReturn(
                new GregorianCalendar(1999, 0, 1, 0, 0, 0).getTime()); // jvm default timezone as in Metadata Extractor
        Metadata metadata = new Metadata();
       
        new ImageMetadataExtractor.ExifHandler().handle(exif, metadata);
View Full Code Here

                metadata.get(TikaCoreProperties.CREATED));
    }
   
    public void testExifHandlerParseDateError() throws MetadataException {
        ExifDirectory exif = mock(ExifDirectory.class);
        when(exif.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)).thenReturn(true);
        when(exif.getDate(ExifDirectory.TAG_DATETIME_ORIGINAL)).thenThrow(
                new MetadataException("Tag 'X' cannot be cast to a java.util.Date."));
        Metadata metadata = new Metadata();
       
        new ImageMetadataExtractor.ExifHandler().handle(exif, metadata);
View Full Code Here

        assertFalse(new ImageMetadataExtractor.ExifHandler().supports(JpegCommentDirectory.class));
    }
   
    public void testExifHandlerParseDate() throws MetadataException {
        ExifDirectory exif = mock(ExifDirectory.class);
        when(exif.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)).thenReturn(true);
        when(exif.getDate(ExifDirectory.TAG_DATETIME_ORIGINAL)).thenReturn(
                new GregorianCalendar(2000, 0, 1, 0, 0, 0).getTime()); // jvm default timezone as in Metadata Extractor
        Metadata metadata = new Metadata();
       
        new ImageMetadataExtractor.ExifHandler().handle(exif, metadata);
View Full Code Here

        assertEquals("Should be ISO date without time zone", "2000-01-01T00:00:00", metadata.get(DublinCore.DATE));
    }

    public void testExifHandlerParseDateFallback() throws MetadataException {
        ExifDirectory exif = mock(ExifDirectory.class);
        when(exif.containsTag(ExifDirectory.TAG_DATETIME)).thenReturn(true);
        when(exif.getDate(ExifDirectory.TAG_DATETIME)).thenReturn(
                new GregorianCalendar(1999, 0, 1, 0, 0, 0).getTime()); // jvm default timezone as in Metadata Extractor
        Metadata metadata = new Metadata();
       
        new ImageMetadataExtractor.ExifHandler().handle(exif, metadata);
View Full Code Here

        assertEquals("Should try EXIF Date/Time if Original is not set", "1999-01-01T00:00:00", metadata.get(DublinCore.DATE));
    }
   
    public void testExifHandlerParseDateError() throws MetadataException {
        ExifDirectory exif = mock(ExifDirectory.class);
        when(exif.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)).thenReturn(true);
        when(exif.getDate(ExifDirectory.TAG_DATETIME_ORIGINAL)).thenThrow(
                new MetadataException("Tag 'X' cannot be cast to a java.util.Date."));
        Metadata metadata = new Metadata();
       
        new ImageMetadataExtractor.ExifHandler().handle(exif, metadata);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.