Ignore:
Timestamp:
2017-10-30T22:46:09+01:00 (8 years ago)
Author:
Don-vip
Message:

fix #15505 - update to metadata-extractor 2.10.1

File:
1 edited

Legend:

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

    r10862 r13061  
    11/*
    2  * Copyright 2002-2016 Drew Noakes
     2 * Copyright 2002-2017 Drew Noakes
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    2222
    2323import com.drew.lang.ByteArrayReader;
     24import com.drew.lang.Charsets;
    2425import com.drew.lang.RandomAccessReader;
    2526import com.drew.lang.annotations.NotNull;
     
    2930import com.drew.metadata.TagDescriptor;
    3031
     32import java.text.DecimalFormat;
    3133import java.io.IOException;
    3234
     
    4547 * @author Philipp Sandhaus
    4648 */
     49@SuppressWarnings("WeakerAccess")
    4750public class PanasonicMakernoteDescriptor extends TagDescriptor<PanasonicMakernoteDirectory>
    4851{
     
    109112            case TAG_TRANSFORM:
    110113                return getTransformDescription();
    111                         case TAG_TRANSFORM_1:
    112                     return getTransform1Description();
     114            case TAG_TRANSFORM_1:
     115                return getTransform1Description();
    113116            case TAG_INTELLIGENT_EXPOSURE:
    114117                return getIntelligentExposureDescription();
     
    127130            case TAG_FACE_RECOGNITION_INFO:
    128131                return getRecognizedFacesDescription();
    129             case TAG_PRINT_IMAGE_MATCHING_INFO:
    130                 return getPrintImageMatchingInfoDescription();
    131132            case TAG_SCENE_MODE:
    132133                return getSceneModeDescription();
     
    134135                return getFlashFiredDescription();
    135136            case TAG_TEXT_STAMP:
    136                         return getTextStampDescription();
    137                         case TAG_TEXT_STAMP_1:
    138                      return getTextStamp1Description();
    139                         case TAG_TEXT_STAMP_2:
    140                          return getTextStamp2Description();
    141                         case TAG_TEXT_STAMP_3:
    142                              return getTextStamp3Description();
     137                return getTextStampDescription();
     138            case TAG_TEXT_STAMP_1:
     139                return getTextStamp1Description();
     140            case TAG_TEXT_STAMP_2:
     141                return getTextStamp2Description();
     142            case TAG_TEXT_STAMP_3:
     143                return getTextStamp3Description();
    143144            case TAG_MAKERNOTE_VERSION:
    144145                return getMakernoteVersionDescription();
     
    148149                return getInternalSerialNumberDescription();
    149150            case TAG_TITLE:
    150                     return getTitleDescription();
    151                         case TAG_BABY_NAME:
    152                     return getBabyNameDescription();
    153                         case TAG_LOCATION:
    154                     return getLocationDescription();
    155                         case TAG_BABY_AGE:
    156                         return getBabyAgeDescription();
    157                         case TAG_BABY_AGE_1:
    158                         return getBabyAge1Description();
    159                         default:
     151                return getTitleDescription();
     152            case TAG_BRACKET_SETTINGS:
     153                return getBracketSettingsDescription();
     154            case TAG_FLASH_CURTAIN:
     155                return getFlashCurtainDescription();
     156            case TAG_LONG_EXPOSURE_NOISE_REDUCTION:
     157                return getLongExposureNoiseReductionDescription();
     158            case TAG_BABY_NAME:
     159                return getBabyNameDescription();
     160            case TAG_LOCATION:
     161                return getLocationDescription();
     162
     163            case TAG_LENS_FIRMWARE_VERSION:
     164                return getLensFirmwareVersionDescription();
     165            case TAG_INTELLIGENT_D_RANGE:
     166                return getIntelligentDRangeDescription();
     167            case TAG_CLEAR_RETOUCH:
     168                return getClearRetouchDescription();
     169            case TAG_PHOTO_STYLE:
     170                return getPhotoStyleDescription();
     171            case TAG_SHADING_COMPENSATION:
     172                return getShadingCompensationDescription();
     173
     174            case TAG_ACCELEROMETER_Z:
     175                return getAccelerometerZDescription();
     176            case TAG_ACCELEROMETER_X:
     177                return getAccelerometerXDescription();
     178            case TAG_ACCELEROMETER_Y:
     179                return getAccelerometerYDescription();
     180            case TAG_CAMERA_ORIENTATION:
     181                return getCameraOrientationDescription();
     182            case TAG_ROLL_ANGLE:
     183                return getRollAngleDescription();
     184            case TAG_PITCH_ANGLE:
     185                return getPitchAngleDescription();
     186            case TAG_SWEEP_PANORAMA_DIRECTION:
     187                return getSweepPanoramaDirectionDescription();
     188            case TAG_TIMER_RECORDING:
     189                return getTimerRecordingDescription();
     190            case TAG_HDR:
     191                return getHDRDescription();
     192            case TAG_SHUTTER_TYPE:
     193                return getShutterTypeDescription();
     194            case TAG_TOUCH_AE:
     195                return getTouchAeDescription();
     196
     197            case TAG_BABY_AGE:
     198                return getBabyAgeDescription();
     199            case TAG_BABY_AGE_1:
     200                return getBabyAge1Description();
     201            default:
    160202                return super.getDescription(tagType);
    161203        }
    162     }
    163 
    164     @Nullable
    165     public String getPrintImageMatchingInfoDescription()
    166     {
    167         return getByteLengthDescription(TAG_PRINT_IMAGE_MATCHING_INFO);
    168204    }
    169205
     
    279315
    280316    @Nullable
     317    private static String trim(@Nullable String s)
     318    {
     319        return s == null ? null : s.trim();
     320    }
     321
     322    @Nullable
    281323    public String getCountryDescription()
    282324    {
    283         return getAsciiStringFromBytes(TAG_COUNTRY);
     325        return trim(getStringFromBytes(TAG_COUNTRY, Charsets.UTF_8));
    284326    }
    285327
     
    287329    public String getStateDescription()
    288330    {
    289         return getAsciiStringFromBytes(TAG_STATE);
     331        return trim(getStringFromBytes(TAG_STATE, Charsets.UTF_8));
    290332    }
    291333
     
    293335    public String getCityDescription()
    294336    {
    295         return getAsciiStringFromBytes(TAG_CITY);
     337        return trim(getStringFromBytes(TAG_CITY, Charsets.UTF_8));
    296338    }
    297339
     
    299341    public String getLandmarkDescription()
    300342    {
    301         return getAsciiStringFromBytes(TAG_LANDMARK);
    302     }
    303 
    304         @Nullable
     343        return trim(getStringFromBytes(TAG_LANDMARK, Charsets.UTF_8));
     344    }
     345
     346    @Nullable
    305347    public String getTitleDescription()
    306348    {
    307         return getAsciiStringFromBytes(TAG_TITLE);
    308     }
    309 
    310         @Nullable
     349        return trim(getStringFromBytes(TAG_TITLE, Charsets.UTF_8));
     350    }
     351
     352    @Nullable
     353    public String getBracketSettingsDescription()
     354    {
     355        return getIndexedDescription(TAG_BRACKET_SETTINGS,
     356            "No Bracket", "3 Images, Sequence 0/-/+", "3 Images, Sequence -/0/+", "5 Images, Sequence 0/-/+",
     357            "5 Images, Sequence -/0/+", "7 Images, Sequence 0/-/+", "7 Images, Sequence -/0/+");
     358    }
     359
     360    @Nullable
     361    public String getFlashCurtainDescription()
     362    {
     363        return getIndexedDescription(TAG_FLASH_CURTAIN,
     364            "n/a", "1st", "2nd");
     365    }
     366
     367    @Nullable
     368    public String getLongExposureNoiseReductionDescription()
     369    {
     370        return getIndexedDescription(TAG_LONG_EXPOSURE_NOISE_REDUCTION, 1,
     371            "Off", "On");
     372    }
     373
     374    @Nullable
     375    public String getLensFirmwareVersionDescription()
     376    {
     377        // lens version has 4 parts separated by periods
     378        byte[] bytes = _directory.getByteArray(TAG_LENS_FIRMWARE_VERSION);
     379        if (bytes == null)
     380            return null;
     381
     382        StringBuilder sb = new StringBuilder();
     383        for (int i = 0; i < bytes.length; i++) {
     384            sb.append(bytes[i]);
     385            if (i < bytes.length - 1)
     386                sb.append(".");
     387        }
     388        return sb.toString();
     389        //return string.Join(".", bytes.Select(b => b.ToString()).ToArray());
     390    }
     391
     392    @Nullable
     393    public String getIntelligentDRangeDescription()
     394    {
     395        return getIndexedDescription(TAG_INTELLIGENT_D_RANGE,
     396            "Off", "Low", "Standard", "High");
     397    }
     398
     399    @Nullable
     400    public String getClearRetouchDescription()
     401    {
     402        return getIndexedDescription(TAG_CLEAR_RETOUCH,
     403                "Off", "On");
     404
     405    }
     406
     407    @Nullable
     408    public String getPhotoStyleDescription()
     409    {
     410        return getIndexedDescription(TAG_PHOTO_STYLE,
     411            "Auto", "Standard or Custom", "Vivid", "Natural", "Monochrome", "Scenery", "Portrait");
     412    }
     413
     414    @Nullable
     415    public String getShadingCompensationDescription()
     416    {
     417        return getIndexedDescription(TAG_SHADING_COMPENSATION,
     418            "Off", "On");
     419    }
     420
     421    @Nullable
     422    public String getAccelerometerZDescription()
     423    {
     424        Integer value = _directory.getInteger(TAG_ACCELEROMETER_Z);
     425        if (value == null)
     426            return null;
     427
     428        // positive is acceleration upwards
     429        return String.valueOf(value.shortValue());
     430    }
     431
     432    @Nullable
     433    public String getAccelerometerXDescription()
     434    {
     435        Integer value = _directory.getInteger(TAG_ACCELEROMETER_X);
     436        if (value == null)
     437            return null;
     438
     439        // positive is acceleration to the left
     440        return String.valueOf(value.shortValue());
     441    }
     442
     443    @Nullable
     444    public String getAccelerometerYDescription()
     445    {
     446        Integer value = _directory.getInteger(TAG_ACCELEROMETER_Y);
     447        if (value == null)
     448            return null;
     449
     450        // positive is acceleration backwards
     451        return String.valueOf(value.shortValue());
     452    }
     453
     454    @Nullable
     455    public String getCameraOrientationDescription()
     456    {
     457        return getIndexedDescription(TAG_CAMERA_ORIENTATION,
     458                "Normal", "Rotate CW", "Rotate 180", "Rotate CCW", "Tilt Upwards", "Tile Downwards");
     459    }
     460
     461    @Nullable
     462    public String getRollAngleDescription()
     463    {
     464        Integer value = _directory.getInteger(TAG_ROLL_ANGLE);
     465        if (value == null)
     466            return null;
     467
     468        DecimalFormat format = new DecimalFormat("0.#");
     469        // converted to degrees of clockwise camera rotation
     470        return format.format(value.shortValue() / 10.0);
     471    }
     472
     473    @Nullable
     474    public String getPitchAngleDescription()
     475    {
     476        Integer value = _directory.getInteger(TAG_PITCH_ANGLE);
     477        if (value == null)
     478            return null;
     479
     480        DecimalFormat format = new DecimalFormat("0.#");
     481        // converted to degrees of upward camera tilt
     482        return format.format(-value.shortValue() / 10.0);
     483    }
     484
     485    @Nullable
     486    public String getSweepPanoramaDirectionDescription()
     487    {
     488        return getIndexedDescription(TAG_SWEEP_PANORAMA_DIRECTION,
     489                "Off", "Left to Right", "Right to Left", "Top to Bottom", "Bottom to Top");
     490    }
     491
     492    @Nullable
     493    public String getTimerRecordingDescription()
     494    {
     495        return getIndexedDescription(TAG_TIMER_RECORDING,
     496                "Off", "Time Lapse", "Stop-motion Animation");
     497    }
     498
     499    @Nullable
     500    public String getHDRDescription()
     501    {
     502        Integer value = _directory.getInteger(TAG_HDR);
     503        if (value == null)
     504            return null;
     505
     506        switch (value)
     507        {
     508            case 0:
     509                return "Off";
     510            case 100:
     511                return "1 EV";
     512            case 200:
     513                return "2 EV";
     514            case 300:
     515                return "3 EV";
     516            case 32868:
     517                return "1 EV (Auto)";
     518            case 32968:
     519                return "2 EV (Auto)";
     520            case 33068:
     521                return "3 EV (Auto)";
     522            default:
     523                return String.format("Unknown (%d)", value);
     524        }
     525    }
     526
     527    @Nullable
     528    public String getShutterTypeDescription()
     529    {
     530        return getIndexedDescription(TAG_SHUTTER_TYPE,
     531                "Mechanical", "Electronic", "Hybrid");
     532    }
     533
     534    @Nullable
     535    public String getTouchAeDescription()
     536    {
     537        return getIndexedDescription(TAG_TOUCH_AE,
     538                "Off", "On");
     539    }
     540
     541    @Nullable
    311542    public String getBabyNameDescription()
    312543    {
    313         return getAsciiStringFromBytes(TAG_BABY_NAME);
     544        return trim(getStringFromBytes(TAG_BABY_NAME, Charsets.UTF_8));
    314545    }
    315546
     
    317548    public String getLocationDescription()
    318549    {
    319         return getAsciiStringFromBytes(TAG_LOCATION);
     550        return trim(getStringFromBytes(TAG_LOCATION, Charsets.UTF_8));
    320551    }
    321552
Note: See TracChangeset for help on using the changeset viewer.