Last change
on this file since 2474 was 1169, checked in by stoecker, 15 years ago |
removed usage of tab stops
|
-
Property svn:eol-style
set to
native
|
File size:
1.3 KB
|
Line | |
---|
1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import java.io.File;
|
---|
5 | import java.text.ParseException;
|
---|
6 | import java.util.Date;
|
---|
7 | import java.util.Iterator;
|
---|
8 |
|
---|
9 | import com.drew.imaging.jpeg.JpegMetadataReader;
|
---|
10 | import com.drew.metadata.Directory;
|
---|
11 | import com.drew.metadata.Metadata;
|
---|
12 | import com.drew.metadata.Tag;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Read out exif file information from a jpeg file
|
---|
16 | * @author Imi
|
---|
17 | */
|
---|
18 | public class ExifReader {
|
---|
19 |
|
---|
20 | @SuppressWarnings("unchecked") public static Date readTime(File filename) throws ParseException {
|
---|
21 | Date date = null;
|
---|
22 | try {
|
---|
23 | Metadata metadata = JpegMetadataReader.readMetadata(filename);
|
---|
24 | for (Iterator<Directory> dirIt = metadata.getDirectoryIterator(); dirIt.hasNext();) {
|
---|
25 | for (Iterator<Tag> tagIt = dirIt.next().getTagIterator(); tagIt.hasNext();) {
|
---|
26 | Tag tag = tagIt.next();
|
---|
27 | if (tag.getTagType() == 0x9003)
|
---|
28 | return DateParser.parse(tag.getDescription());
|
---|
29 | if (tag.getTagType() == 0x132 || tag.getTagType() == 0x9004)
|
---|
30 | date = DateParser.parse(tag.getDescription());
|
---|
31 | }
|
---|
32 | }
|
---|
33 | } catch (ParseException e) {
|
---|
34 | throw e;
|
---|
35 | } catch (Exception e) {
|
---|
36 | e.printStackTrace();
|
---|
37 | }
|
---|
38 | return date;
|
---|
39 | }
|
---|
40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.