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

fix #11359 - update to metadata-extractor 2.8.1

File:
1 edited

Legend:

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

    r8132 r8243  
    2222package com.drew.metadata.exif;
    2323
    24 import com.drew.lang.Rational;
    2524import com.drew.lang.annotations.NotNull;
    2625import com.drew.lang.annotations.Nullable;
    27 import com.drew.metadata.TagDescriptor;
    2826
    2927import static com.drew.metadata.exif.ExifThumbnailDirectory.*;
     
    3432 * @author Drew Noakes https://drewnoakes.com
    3533 */
    36 public class ExifThumbnailDescriptor extends TagDescriptor<ExifThumbnailDirectory>
     34public class ExifThumbnailDescriptor extends ExifDescriptorBase<ExifThumbnailDirectory>
    3735{
    38     /**
    39      * Dictates whether rational values will be represented in decimal format in instances
    40      * where decimal notation is elegant (such as 1/2 -> 0.5, but not 1/3).
    41      */
    42     private final boolean _allowDecimalRepresentationOfRationals = true;
    43 
    4436    public ExifThumbnailDescriptor(@NotNull ExifThumbnailDirectory directory)
    4537    {
     
    4739    }
    4840
    49     // Note for the potential addition of brightness presentation in eV:
    50     // Brightness of taken subject. To calculate Exposure(Ev) from BrightnessValue(Bv),
    51     // you must add SensitivityValue(Sv).
    52     // Ev=BV+Sv   Sv=log2(ISOSpeedRating/3.125)
    53     // ISO100:Sv=5, ISO200:Sv=6, ISO400:Sv=7, ISO125:Sv=5.32.
    54 
    55     /**
    56      * Returns a descriptive value of the specified tag for this image.
    57      * Where possible, known values will be substituted here in place of the raw
    58      * tokens actually kept in the Exif segment.  If no substitution is
    59      * available, the value provided by getString(int) will be returned.
    60      *
    61      * @param tagType the tag to find a description for
    62      * @return a description of the image's value for the specified tag, or
    63      *         <code>null</code> if the tag hasn't been defined.
    64      */
    6541    @Override
    6642    @Nullable
     
    6844    {
    6945        switch (tagType) {
    70             case TAG_ORIENTATION:
    71                 return getOrientationDescription();
    72             case TAG_RESOLUTION_UNIT:
    73                 return getResolutionDescription();
    74             case TAG_YCBCR_POSITIONING:
    75                 return getYCbCrPositioningDescription();
    76             case TAG_X_RESOLUTION:
    77                 return getXResolutionDescription();
    78             case TAG_Y_RESOLUTION:
    79                 return getYResolutionDescription();
    8046            case TAG_THUMBNAIL_OFFSET:
    8147                return getThumbnailOffsetDescription();
    8248            case TAG_THUMBNAIL_LENGTH:
    8349                return getThumbnailLengthDescription();
    84             case TAG_THUMBNAIL_IMAGE_WIDTH:
    85                 return getThumbnailImageWidthDescription();
    86             case TAG_THUMBNAIL_IMAGE_HEIGHT:
    87                 return getThumbnailImageHeightDescription();
    88             case TAG_BITS_PER_SAMPLE:
    89                 return getBitsPerSampleDescription();
    9050            case TAG_THUMBNAIL_COMPRESSION:
    9151                return getCompressionDescription();
    92             case TAG_PHOTOMETRIC_INTERPRETATION:
    93                 return getPhotometricInterpretationDescription();
    94             case TAG_ROWS_PER_STRIP:
    95                 return getRowsPerStripDescription();
    96             case TAG_STRIP_BYTE_COUNTS:
    97                 return getStripByteCountsDescription();
    98             case TAG_SAMPLES_PER_PIXEL:
    99                 return getSamplesPerPixelDescription();
    100             case TAG_PLANAR_CONFIGURATION:
    101                 return getPlanarConfigurationDescription();
    102             case TAG_YCBCR_SUBSAMPLING:
    103                 return getYCbCrSubsamplingDescription();
    104             case TAG_REFERENCE_BLACK_WHITE:
    105                 return getReferenceBlackWhiteDescription();
    10652            default:
    10753                return super.getDescription(tagType);
    108         }
    109     }
    110 
    111     @Nullable
    112     public String getReferenceBlackWhiteDescription()
    113     {
    114         int[] ints = _directory.getIntArray(TAG_REFERENCE_BLACK_WHITE);
    115         if (ints == null || ints.length < 6)
    116             return null;
    117         int blackR = ints[0];
    118         int whiteR = ints[1];
    119         int blackG = ints[2];
    120         int whiteG = ints[3];
    121         int blackB = ints[4];
    122         int whiteB = ints[5];
    123         return String.format("[%d,%d,%d] [%d,%d,%d]", blackR, blackG, blackB, whiteR, whiteG, whiteB);
    124     }
    125 
    126     @Nullable
    127     public String getYCbCrSubsamplingDescription()
    128     {
    129         int[] positions = _directory.getIntArray(TAG_YCBCR_SUBSAMPLING);
    130         if (positions == null || positions.length < 2)
    131             return null;
    132         if (positions[0] == 2 && positions[1] == 1) {
    133             return "YCbCr4:2:2";
    134         } else if (positions[0] == 2 && positions[1] == 2) {
    135             return "YCbCr4:2:0";
    136         } else {
    137             return "(Unknown)";
    138         }
    139     }
    140 
    141     @Nullable
    142     public String getPlanarConfigurationDescription()
    143     {
    144         // When image format is no compression YCbCr, this value shows byte aligns of YCbCr
    145         // data. If value is '1', Y/Cb/Cr value is chunky format, contiguous for each subsampling
    146         // pixel. If value is '2', Y/Cb/Cr value is separated and stored to Y plane/Cb plane/Cr
    147         // plane format.
    148         return getIndexedDescription(TAG_PLANAR_CONFIGURATION,
    149             1,
    150             "Chunky (contiguous for each subsampling pixel)",
    151             "Separate (Y-plane/Cb-plane/Cr-plane format)"
    152         );
    153     }
    154 
    155     @Nullable
    156     public String getSamplesPerPixelDescription()
    157     {
    158         String value = _directory.getString(TAG_SAMPLES_PER_PIXEL);
    159         return value == null ? null : value + " samples/pixel";
    160     }
    161 
    162     @Nullable
    163     public String getRowsPerStripDescription()
    164     {
    165         final String value = _directory.getString(TAG_ROWS_PER_STRIP);
    166         return value == null ? null : value + " rows/strip";
    167     }
    168 
    169     @Nullable
    170     public String getStripByteCountsDescription()
    171     {
    172         final String value = _directory.getString(TAG_STRIP_BYTE_COUNTS);
    173         return value == null ? null : value + " bytes";
    174     }
    175 
    176     @Nullable
    177     public String getPhotometricInterpretationDescription()
    178     {
    179         // Shows the color space of the image data components
    180         Integer value = _directory.getInteger(TAG_PHOTOMETRIC_INTERPRETATION);
    181         if (value == null)
    182             return null;
    183         switch (value) {
    184             case 0: return "WhiteIsZero";
    185             case 1: return "BlackIsZero";
    186             case 2: return "RGB";
    187             case 3: return "RGB Palette";
    188             case 4: return "Transparency Mask";
    189             case 5: return "CMYK";
    190             case 6: return "YCbCr";
    191             case 8: return "CIELab";
    192             case 9: return "ICCLab";
    193             case 10: return "ITULab";
    194             case 32803: return "Color Filter Array";
    195             case 32844: return "Pixar LogL";
    196             case 32845: return "Pixar LogLuv";
    197             case 32892: return "Linear Raw";
    198             default:
    199                 return "Unknown colour space";
    20054        }
    20155    }
     
    24195
    24296    @Nullable
    243     public String getBitsPerSampleDescription()
    244     {
    245         String value = _directory.getString(TAG_BITS_PER_SAMPLE);
    246         return value == null ? null : value + " bits/component/pixel";
    247     }
    248 
    249     @Nullable
    250     public String getThumbnailImageWidthDescription()
    251     {
    252         String value = _directory.getString(TAG_THUMBNAIL_IMAGE_WIDTH);
    253         return value == null ? null : value + " pixels";
    254     }
    255 
    256     @Nullable
    257     public String getThumbnailImageHeightDescription()
    258     {
    259         String value = _directory.getString(TAG_THUMBNAIL_IMAGE_HEIGHT);
    260         return value == null ? null : value + " pixels";
    261     }
    262 
    263     @Nullable
    26497    public String getThumbnailLengthDescription()
    26598    {
     
    274107        return value == null ? null : value + " bytes";
    275108    }
    276 
    277     @Nullable
    278     public String getYResolutionDescription()
    279     {
    280         Rational value = _directory.getRational(TAG_Y_RESOLUTION);
    281         if (value == null)
    282             return null;
    283         final String unit = getResolutionDescription();
    284         return value.toSimpleString(_allowDecimalRepresentationOfRationals) +
    285             " dots per " +
    286             (unit == null ? "unit" : unit.toLowerCase());
    287     }
    288 
    289     @Nullable
    290     public String getXResolutionDescription()
    291     {
    292         Rational value = _directory.getRational(TAG_X_RESOLUTION);
    293         if (value == null)
    294             return null;
    295         final String unit = getResolutionDescription();
    296         return value.toSimpleString(_allowDecimalRepresentationOfRationals) +
    297             " dots per " +
    298             (unit == null ? "unit" : unit.toLowerCase());
    299     }
    300 
    301     @Nullable
    302     public String getYCbCrPositioningDescription()
    303     {
    304         return getIndexedDescription(TAG_YCBCR_POSITIONING, 1, "Center of pixel array", "Datum point");
    305     }
    306 
    307     @Nullable
    308     public String getOrientationDescription()
    309     {
    310         return getIndexedDescription(TAG_ORIENTATION, 1,
    311             "Top, left side (Horizontal / normal)",
    312             "Top, right side (Mirror horizontal)",
    313             "Bottom, right side (Rotate 180)",
    314             "Bottom, left side (Mirror vertical)",
    315             "Left side, top (Mirror horizontal and rotate 270 CW)",
    316             "Right side, top (Rotate 90 CW)",
    317             "Right side, bottom (Mirror horizontal and rotate 90 CW)",
    318             "Left side, bottom (Rotate 270 CW)");
    319     }
    320 
    321     @Nullable
    322     public String getResolutionDescription()
    323     {
    324         // '1' means no-unit, '2' means inch, '3' means centimeter. Default value is '2'(inch)
    325         return getIndexedDescription(TAG_RESOLUTION_UNIT, 1, "(No unit)", "Inch", "cm");
    326     }
    327109}
Note: See TracChangeset for help on using the changeset viewer.