Changeset 8243 in josm for trunk/src/com/drew/imaging/jpeg


Ignore:
Timestamp:
2015-04-21T00:42:50+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #11359 - update to metadata-extractor 2.8.1

Location:
trunk/src/com/drew/imaging/jpeg
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/imaging/jpeg/JpegMetadataReader.java

    r8132 r8243  
    3535//import com.drew.metadata.adobe.AdobeJpegReader;
    3636import com.drew.metadata.exif.ExifReader;
     37import com.drew.metadata.file.FileMetadataReader;
    3738//import com.drew.metadata.icc.IccReader;
    3839import com.drew.metadata.iptc.IptcReader;
     
    7980    public static Metadata readMetadata(@NotNull File file, @Nullable Iterable<JpegSegmentMetadataReader> readers) throws JpegProcessingException, IOException
    8081    {
    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);
    8686        } finally {
    87             if (inputStream != null)
    88                 inputStream.close();
     87            inputStream.close();
    8988        }
     89        new FileMetadataReader().read(file, metadata);
     90        return metadata;
    9091    }
    9192
     
    123124        for (JpegSegmentMetadataReader reader : readers) {
    124125            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);
    130127            }
    131128        }
  • trunk/src/com/drew/imaging/jpeg/JpegSegmentMetadataReader.java

    r8132 r8243  
    1616
    1717    /**
    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.
    2619     *
    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.
    2822     * @param metadata The {@link Metadata} object into which extracted values should be merged.
    2923     * @param segmentType The {@link JpegSegmentType} being read.
    3024     */
    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);
    3226}
Note: See TracChangeset for help on using the changeset viewer.