Changeset 8243 in josm for trunk/src/com/drew/imaging/jpeg
- Timestamp:
- 2015-04-21T00:42:50+02:00 (10 years ago)
- Location:
- trunk/src/com/drew/imaging/jpeg
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/imaging/jpeg/JpegMetadataReader.java
r8132 r8243 35 35 //import com.drew.metadata.adobe.AdobeJpegReader; 36 36 import com.drew.metadata.exif.ExifReader; 37 import com.drew.metadata.file.FileMetadataReader; 37 38 //import com.drew.metadata.icc.IccReader; 38 39 import com.drew.metadata.iptc.IptcReader; … … 79 80 public static Metadata readMetadata(@NotNull File file, @Nullable Iterable<JpegSegmentMetadataReader> readers) throws JpegProcessingException, IOException 80 81 { 81 InputStream inputStream = null; 82 try 83 { 84 inputStream = new FileInputStream(file); 85 return readMetadata(inputStream, readers); 82 InputStream inputStream = new FileInputStream(file); 83 Metadata metadata; 84 try { 85 metadata = readMetadata(inputStream, readers); 86 86 } finally { 87 if (inputStream != null) 88 inputStream.close(); 87 inputStream.close(); 89 88 } 89 new FileMetadataReader().read(file, metadata); 90 return metadata; 90 91 } 91 92 … … 123 124 for (JpegSegmentMetadataReader reader : readers) { 124 125 for (JpegSegmentType segmentType : reader.getSegmentTypes()) { 125 for (byte[] segmentBytes : segmentData.getSegments(segmentType)) { 126 if (reader.canProcess(segmentBytes, segmentType)) { 127 reader.extract(segmentBytes, metadata, segmentType); 128 } 129 } 126 reader.readJpegSegments(segmentData.getSegments(segmentType), metadata, segmentType); 130 127 } 131 128 } -
trunk/src/com/drew/imaging/jpeg/JpegSegmentMetadataReader.java
r8132 r8243 16 16 17 17 /** 18 * Gets a value indicating whether the supplied byte data can be processed by this reader. This is not a guarantee 19 * that no errors will occur, but rather a best-effort indication of whether the parse is likely to succeed. 20 * Implementations are expected to check things such as the opening bytes, data length, etc. 21 */ 22 public boolean canProcess(@NotNull final byte[] segmentBytes, @NotNull final JpegSegmentType segmentType); 23 24 /** 25 * Extracts metadata from a JPEG segment's byte array and merges it into the specified {@link Metadata} object. 18 * Extracts metadata from all instances of a particular JPEG segment type. 26 19 * 27 * @param segmentBytes The byte array from which the metadata should be extracted. 20 * @param segments A sequence of byte arrays from which the metadata should be extracted. These are in the order 21 * encountered in the original file. 28 22 * @param metadata The {@link Metadata} object into which extracted values should be merged. 29 23 * @param segmentType The {@link JpegSegmentType} being read. 30 24 */ 31 public void extract(@NotNull final byte[] segmentBytes, @NotNull final Metadata metadata, @NotNull final JpegSegmentType segmentType);25 public void readJpegSegments(@NotNull final Iterable<byte[]> segments, @NotNull final Metadata metadata, @NotNull final JpegSegmentType segmentType); 32 26 }
Note:
See TracChangeset
for help on using the changeset viewer.