Changeset 8243 in josm for trunk/src/com/drew/metadata/iptc


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

fix #11359 - update to metadata-extractor 2.8.1

Location:
trunk/src/com/drew/metadata/iptc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/metadata/iptc/IptcDescriptor.java

    r8132 r8243  
    4949            case IptcDirectory.TAG_KEYWORDS:
    5050                return getKeywordsDescription();
     51            case IptcDirectory.TAG_TIME_CREATED:
     52                return getTimeCreatedDescription();
     53            case IptcDirectory.TAG_DIGITAL_TIME_CREATED:
     54                return getDigitalTimeCreatedDescription();
    5155            default:
    5256                return super.getDescription(tagType);
     
    227231    public String getTimeCreatedDescription()
    228232    {
    229         return _directory.getString(IptcDirectory.TAG_TIME_CREATED);
     233        String s = _directory.getString(IptcDirectory.TAG_TIME_CREATED);
     234        if (s == null)
     235            return null;
     236        if (s.length() == 6 || s.length() == 11)
     237            return s.substring(0, 2) + ':' + s.substring(2, 4) + ':' + s.substring(4);
     238        return s;
     239    }
     240
     241    @Nullable
     242    public String getDigitalTimeCreatedDescription()
     243    {
     244        String s = _directory.getString(IptcDirectory.TAG_DIGITAL_TIME_CREATED);
     245        if (s == null)
     246            return null;
     247        if (s.length() == 6 || s.length() == 11)
     248            return s.substring(0, 2) + ':' + s.substring(2, 4) + ':' + s.substring(4);
     249        return s;
    230250    }
    231251
  • trunk/src/com/drew/metadata/iptc/IptcReader.java

    r8132 r8243  
    6363    }
    6464
    65     public boolean canProcess(@NotNull byte[] segmentBytes, @NotNull JpegSegmentType segmentType)
    66     {
    67         // Check whether the first byte resembles
    68         return segmentBytes.length != 0 && segmentBytes[0] == 0x1c;
    69     }
    70 
    71     public void extract(@NotNull byte[] segmentBytes, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType)
    72     {
    73         extract(new SequentialByteArrayReader(segmentBytes), metadata, segmentBytes.length);
     65    public void readJpegSegments(@NotNull Iterable<byte[]> segments, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType)
     66    {
     67        for (byte[] segmentBytes : segments) {
     68            // Ensure data starts with the IPTC marker byte
     69            if (segmentBytes.length != 0 && segmentBytes[0] == 0x1c) {
     70                extract(new SequentialByteArrayReader(segmentBytes), metadata, segmentBytes.length);
     71            }
     72        }
    7473    }
    7574
     
    7978    public void extract(@NotNull final SequentialReader reader, @NotNull final Metadata metadata, long length)
    8079    {
    81         IptcDirectory directory = metadata.getOrCreateDirectory(IptcDirectory.class);
     80        IptcDirectory directory = new IptcDirectory();
     81        metadata.addDirectory(directory);
    8282
    8383        int offset = 0;
Note: See TracChangeset for help on using the changeset viewer.