Ignore:
Timestamp:
2016-08-20T20:58:03+02:00 (10 years ago)
Author:
Don-vip
Message:

update to metadata-extractor 2.9.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/metadata/exif/ExifTiffHandler.java

    r8243 r10862  
    11/*
    2  * Copyright 2002-2015 Drew Noakes
     2 * Copyright 2002-2016 Drew Noakes
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    2626import com.drew.lang.SequentialByteArrayReader;
    2727import com.drew.lang.annotations.NotNull;
     28import com.drew.lang.annotations.Nullable;
    2829import com.drew.metadata.Directory;
    2930import com.drew.metadata.Metadata;
     
    4748    private final boolean _storeThumbnailBytes;
    4849
    49     public ExifTiffHandler(@NotNull Metadata metadata, boolean storeThumbnailBytes)
     50    public ExifTiffHandler(@NotNull Metadata metadata, boolean storeThumbnailBytes, @Nullable Directory parentDirectory)
    5051    {
    5152        super(metadata, ExifIFD0Directory.class);
    5253        _storeThumbnailBytes = storeThumbnailBytes;
     54
     55        if (parentDirectory != null)
     56            _currentDirectory.setParent(parentDirectory);
    5357    }
    5458
     
    6569    }
    6670
    67     public boolean isTagIfdPointer(int tagType)
    68     {
    69         if (tagType == ExifIFD0Directory.TAG_EXIF_SUB_IFD_OFFSET && _currentDirectory instanceof ExifIFD0Directory) {
     71    public boolean tryEnterSubIfd(int tagId)
     72    {
     73        if (tagId == ExifDirectoryBase.TAG_SUB_IFD_OFFSET) {
    7074            pushDirectory(ExifSubIFDDirectory.class);
    7175            return true;
    72         } else if (tagType == ExifIFD0Directory.TAG_GPS_INFO_OFFSET && _currentDirectory instanceof ExifIFD0Directory) {
    73             pushDirectory(GpsDirectory.class);
    74             return true;
    75         } else if (tagType == ExifSubIFDDirectory.TAG_INTEROP_OFFSET && _currentDirectory instanceof ExifSubIFDDirectory) {
    76             pushDirectory(ExifInteropDirectory.class);
    77             return true;
     76        }
     77
     78        if (_currentDirectory instanceof ExifIFD0Directory) {
     79            if (tagId == ExifIFD0Directory.TAG_EXIF_SUB_IFD_OFFSET) {
     80                pushDirectory(ExifSubIFDDirectory.class);
     81                return true;
     82            }
     83
     84            if (tagId == ExifIFD0Directory.TAG_GPS_INFO_OFFSET) {
     85                pushDirectory(GpsDirectory.class);
     86                return true;
     87            }
     88        }
     89
     90        if (_currentDirectory instanceof ExifSubIFDDirectory) {
     91            if (tagId == ExifSubIFDDirectory.TAG_INTEROP_OFFSET) {
     92                pushDirectory(ExifInteropDirectory.class);
     93                return true;
     94            }
     95        }
     96
     97        if (_currentDirectory instanceof OlympusMakernoteDirectory) {
     98            if (tagId == OlympusMakernoteDirectory.TAG_EQUIPMENT) {
     99                pushDirectory(OlympusEquipmentMakernoteDirectory.class);
     100                return true;
     101            }
     102
     103            if (tagId == OlympusMakernoteDirectory.TAG_CAMERA_SETTINGS) {
     104                pushDirectory(OlympusCameraSettingsMakernoteDirectory.class);
     105                return true;
     106            }
    78107        }
    79108
     
    96125        // NOTE have seen the CanonMakernoteDirectory IFD have a follower pointer, but it points to invalid data.
    97126        return false;
     127    }
     128
     129    @Nullable
     130    public Long tryCustomProcessFormat(final int tagId, final int formatCode, final long componentCount)
     131    {
     132        if (formatCode == 13)
     133            return componentCount * 4;
     134
     135        return null;
    98136    }
    99137
     
    115153            if (reader.getInt8(tagOffset) == 0x1c) {
    116154                final byte[] iptcBytes = reader.getBytes(tagOffset, byteCount);
    117                 new IptcReader().extract(new SequentialByteArrayReader(iptcBytes), _metadata, iptcBytes.length);
     155                new IptcReader().extract(new SequentialByteArrayReader(iptcBytes), _metadata, iptcBytes.length, _currentDirectory);
    118156                return true;
    119157            }
     
    129167            // after the extraction process, if we have the correct tags, we may be able to store thumbnail information
    130168            ExifThumbnailDirectory thumbnailDirectory = _metadata.getFirstDirectoryOfType(ExifThumbnailDirectory.class);
    131             if (thumbnailDirectory != null && thumbnailDirectory.containsTag(ExifThumbnailDirectory.TAG_THUMBNAIL_COMPRESSION)) {
     169            if (thumbnailDirectory != null && thumbnailDirectory.containsTag(ExifThumbnailDirectory.TAG_COMPRESSION)) {
    132170                Integer offset = thumbnailDirectory.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_OFFSET);
    133171                Integer length = thumbnailDirectory.getInteger(ExifThumbnailDirectory.TAG_THUMBNAIL_LENGTH);
     
    164202        final String firstSevenChars = reader.getString(makernoteOffset, 7);
    165203        final String firstEightChars = reader.getString(makernoteOffset, 8);
     204        final String firstTenChars = reader.getString(makernoteOffset, 10);
    166205        final String firstTwelveChars = reader.getString(makernoteOffset, 12);
    167206
    168207        boolean byteOrderBefore = reader.isMotorolaByteOrder();
    169208
    170         if ("OLYMP".equals(firstFiveChars) || "EPSON".equals(firstFiveChars) || "AGFA".equals(firstFourChars)) {
     209        if ("OLYMP\0".equals(firstSixChars) || "EPSON".equals(firstFiveChars) || "AGFA".equals(firstFourChars)) {
    171210            // Olympus Makernote
    172211            // Epson and Agfa use Olympus makernote standard: http://www.ozhiker.com/electronics/pjmt/jpeg_info/
    173212            pushDirectory(OlympusMakernoteDirectory.class);
    174213            TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 8, tiffHeaderOffset);
     214        } else if ("OLYMPUS\0II".equals(firstTenChars)) {
     215            // Olympus Makernote (alternate)
     216            // Note that data is relative to the beginning of the makernote
     217            // http://exiv2.org/makernote.html
     218            pushDirectory(OlympusMakernoteDirectory.class);
     219            TiffReader.processIfd(this, reader, processedIfdOffsets, makernoteOffset + 12, makernoteOffset);
    175220        } else if (cameraMake != null && cameraMake.toUpperCase().startsWith("MINOLTA")) {
    176221            // Cases seen with the model starting with MINOLTA in capitals seem to have a valid Olympus makernote
Note: See TracChangeset for help on using the changeset viewer.