Ignore:
Timestamp:
2011-06-01T12:33:42+12:00 (13 years ago)
Author:
sjm84
Message:

Updating the ExifTool perl modules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/cpan/Image/ExifTool/CanonRaw.pm

    r16842 r24107  
    1212#               2) http://www.wonderland.org/crw/
    1313#               3) http://xyrion.org/ciff/CIFFspecV1R04.pdf
     14#               4) Dave Nicholson private communication (PowerShot S30)
    1415#------------------------------------------------------------------------------
    1516
     
    1819use strict;
    1920use vars qw($VERSION $AUTOLOAD %crwTagFormat);
    20 use Image::ExifTool qw(:DataAccess);
     21use Image::ExifTool qw(:DataAccess :Utils);
    2122use Image::ExifTool::Exif;
    2223use Image::ExifTool::Canon;
    2324
    24 $VERSION = '1.42';
     25$VERSION = '1.54';
    2526
    2627sub WriteCRW($$);
     
    132133        },
    133134    },
    134     0x102c => { Name => 'CanonColorInfo2', Writable => 0 },
     135    0x102c => {
     136        Name => 'CanonColorInfo2',
     137        Writable => 0,
     138        # for the S30, the following information has been decoded: (ref 4)
     139        # offset 66: int32u - shutter half press time in ms
     140        # offset 70: int32u - image capture time in ms
     141        # offset 74: int16u - custom white balance flag (0=Off, 512=On)
     142    },
    135143    0x102d => {
    136144        Name => 'CanonCameraSettings',
     
    138146        SubDirectory => {
    139147            TagTable => 'Image::ExifTool::Canon::CameraSettings',
     148        },
     149    },
     150    0x1030 => { #4
     151        Name => 'WhiteSample',
     152        Writable => 0,
     153        SubDirectory => {
     154            Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)',
     155            TagTable => 'Image::ExifTool::CanonRaw::WhiteSample',
    140156        },
    141157    },
     
    152168        {
    153169            Name => 'CustomFunctions10D',
    154             Condition => '$self->{CameraModel} =~ /EOS 10D/',
     170            Condition => '$self->{Model} =~ /EOS 10D/',
    155171            SubDirectory => {
    156172                Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)',
     
    160176        {
    161177            Name => 'CustomFunctionsD30',
    162             Condition => '$self->{CameraModel} =~ /EOS D30\b/',
     178            Condition => '$self->{Model} =~ /EOS D30\b/',
    163179            SubDirectory => {
    164180                Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)',
     
    168184        {
    169185            Name => 'CustomFunctionsD60',
    170             Condition => '$self->{CameraModel} =~ /EOS D60\b/',
     186            Condition => '$self->{Model} =~ /EOS D60\b/',
    171187            SubDirectory => {
    172188                # the stored size in the D60 apparently doesn't include the size word:
     
    241257        ValueConv => '$val / 1000',
    242258        ValueConvInv => '$val * 1000',
    243         PrintConv => '"$val sec"',
    244         PrintConvInv => '$val=~s/\s*sec.*//;$val',
     259        PrintConv => '"$val s"',
     260        PrintConvInv => '$val=~s/\s*s.*//;$val',
    245261    },
    246262    0x1807 => {
     
    250266        PrintConvInv => '$val=~s/\s*mm$//;$val',
    251267    },
    252     0x180b => {
    253         Name => 'SerialNumber',
    254         Writable => 'int32u',
    255         Description => 'Camera Body No.',
    256         PrintConv => 'sprintf("%.10d",$val)',
    257         PrintConvInv => '$val',
    258     },
     268    0x180b => [
     269        {
     270            # D30
     271            Name => 'SerialNumber',
     272            Condition => '$$self{Model} =~ /EOS D30\b/',
     273            Writable => 'int32u',
     274            PrintConv => 'sprintf("%x-%.5d",$val>>16,$val&0xffff)',
     275            PrintConvInv => '$val=~/(.*)-(\d+)/ ? (hex($1)<<16)+$2 : undef',
     276        },
     277        {
     278            # all EOS models (D30, 10D, 300D)
     279            Name => 'SerialNumber',
     280            Condition => '$$self{Model} =~ /EOS/',
     281            Writable => 'int32u',
     282            PrintConv => 'sprintf("%.10d",$val)',
     283            PrintConvInv => '$val',
     284        },
     285        {
     286            # this is not SerialNumber for PowerShot models (but what is it?) - PH
     287            Name => 'UnknownNumber',
     288            Unknown => 1,
     289        },
     290    ],
    259291    0x180e => {
    260292        Name => 'TimeStamp',
     
    281313        Name => 'MeasuredEV',
    282314        Notes => q{
    283             this the Canon name for what should properly be called MeasuredLV, and is
    284             offset by about -5 EV from the calculated LV for most models
     315            this is the Canon name for what could better be called MeasuredLV, and
     316            should be close to the calculated LightValue for a proper exposure with most
     317            models
    285318        },
    286319        Format => 'float',
     320        ValueConv => '$val + 5',
     321        ValueConvInv => '$val - 5',
    287322    },
    288323    0x1817 => {
     
    295330    0x1818 => { #3
    296331        Name => 'ExposureInfo',
     332        Groups => { 1 => 'CIFF' }, # (only so CIFF shows up in group lists)
    297333        Writable => 0,
    298334        SubDirectory => {
     
    314350        Name => 'DecoderTable',
    315351        Writable => 0,
     352        SubDirectory => {
     353            TagTable => 'Image::ExifTool::CanonRaw::DecoderTable',
     354        },
    316355    },
    317356    0x183b => { #PH
     
    334373        Writable => 'resize',  # 'resize' allows this value to change size
    335374        Permanent => 0,
    336         ValueConv => '$self->ValidateImage(\$val,$tag)',
    337         ValueConvInv => '$val',
     375        RawConv => '$self->ValidateImage(\$val,$tag)',
    338376    },
    339377    0x2008 => {
     
    342380        WriteCheck => '$self->CheckImage(\$val)',
    343381        Permanent => 0,
    344         ValueConv => '$self->ValidateImage(\$val,$tag)',
    345         ValueConvInv => '$val',
     382        RawConv => '$self->ValidateImage(\$val,$tag)',
    346383    },
    347384    # the following entries are subdirectories
     
    398435        Name => 'Make',
    399436        Format => 'string[6]',  # "Canon\0"
    400         DataMember => 'CameraMake',
    401         RawConv => '$self->{CameraMake} = $val',
     437        DataMember => 'Make',
     438        RawConv => '$self->{Make} = $val',
    402439    },
    403440    6 => {
    404441        Name => 'Model',
    405         Format => 'string[$size-6]',
     442        Format => 'string', # no size = to the end of the data
    406443        Description => 'Camera Model Name',
    407         DataMember => 'CameraModel',
    408         RawConv => '$self->{CameraModel} = $val',
     444        DataMember => 'Model',
     445        RawConv => '$self->{Model} = $val',
    409446    },
    410447);
     
    425462        ValueConvInv => 'GetUnixTime($val)',
    426463        PrintConv => '$self->ConvertDateTime($val)',
    427         PrintConvInv => '$val',
     464        PrintConvInv => '$self->InverseDateTime($val)',
    428465    },
    429466    1 => { #3
     
    514551    GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
    515552    0 => 'ExposureCompensation',
    516     1 => 'TvValue',
    517     2 => 'AvValue',
     553    1 => {
     554        Name => 'ShutterSpeedValue',
     555        ValueConv => 'abs($val)<100 ? 1/(2**$val) : 0',
     556        ValueConvInv => '$val>0 ? -log($val)/log(2) : -100',
     557        PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
     558        PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
     559    },
     560    2 => {
     561        Name => 'ApertureValue',
     562        ValueConv => '2 ** ($val / 2)',
     563        ValueConvInv => '$val>0 ? 2*log($val)/log(2) : 0',
     564        PrintConv => 'sprintf("%.1f",$val)',
     565        PrintConvInv => '$val',
     566    },
    518567);
    519568
     
    523572    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
    524573    FORMAT => 'int32u',
    525     FIRST_ENTRY => 1,
     574    FIRST_ENTRY => 0,
    526575    GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
    527576    # Note: Don't make these writable (except rotation) because it confuses
     
    541590    5 => 'ColorBitDepth', #3
    542591    6 => 'ColorBW', #3
     592);
     593
     594# ref 4
     595%Image::ExifTool::CanonRaw::DecoderTable = (
     596    PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
     597    WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
     598    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
     599    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
     600    FORMAT => 'int32u',
     601    FIRST_ENTRY => 0,
     602    0 => 'DecoderTableNumber',
     603    2 => 'CompressedDataOffset',
     604    3 => 'CompressedDataLength',
     605);
     606
     607# ref 1/4
     608%Image::ExifTool::CanonRaw::WhiteSample = (
     609    PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
     610    WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
     611    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
     612    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
     613    FORMAT => 'int16u',
     614    FIRST_ENTRY => 1,
     615    1 => 'WhiteSampleWidth',
     616    2 => 'WhiteSampleHeight',
     617    3 => 'WhiteSampleLeftBorder',
     618    4 => 'WhiteSampleTopBorder',
     619    5 => 'WhiteSampleBits',
     620    # this is followed by the encrypted white sample values (ref 1)
    543621);
    544622
     
    576654    $raf->Read($buff, 10 * $entries) == 10 * $entries or return 0;
    577655
    578     $verbose and $exifTool->VerboseDir('Raw', $entries);
     656    $verbose and $exifTool->VerboseDir('CIFF', $entries);
    579657    my $index;
    580658    for ($index=0; $index<$entries; ++$index) {
     
    649727                $value = "Binary data $size bytes";
    650728                if ($tagInfo) {
    651                     if ($exifTool->Options('Binary')) {
     729                    if ($exifTool->Options('Binary') or $verbose) {
    652730                        # read the value anyway
    653731                        unless ($raf->Seek($ptr, 0) and $raf->Read($value, $size) == $size) {
     
    695773            my $newTagTable;
    696774            if ($$subdir{TagTable}) {
    697                 $newTagTable = Image::ExifTool::GetTagTable($$subdir{TagTable});
     775                $newTagTable = GetTagTable($$subdir{TagTable});
    698776                unless ($newTagTable) {
    699777                    warn "Unknown tag table $$subdir{TagTable}\n";
     
    761839
    762840    # set the FileType tag unless already done (ie. APP0 CIFF record in JPEG image)
    763     $exifTool->SetFileType() unless $exifTool->GetValue('FileType');
     841    $exifTool->SetFileType();
    764842
    765843    # build directory information for main raw directory
     
    774852
    775853    # process the raw directory
    776     my $rawTagTable = Image::ExifTool::GetTagTable('Image::ExifTool::CanonRaw::Main');
     854    my $rawTagTable = GetTagTable('Image::ExifTool::CanonRaw::Main');
    777855    unless ($exifTool->ProcessDirectory(\%dirInfo, $rawTagTable)) {
    778856        $exifTool->Warn('CRW file format error');
     
    782860    $buildMakerNotes and SaveMakerNotes($exifTool);
    783861
    784     # process trailers if they exist
    785     my $trailInfo = Image::ExifTool::IdentifyTrailer($raf);
    786     $exifTool->ProcessTrailers($trailInfo) if $trailInfo;
     862    # process trailers if they exist in CRW file (not in CIFF information!)
     863    if ($$exifTool{FILE_TYPE} eq 'CRW') {
     864        my $trailInfo = Image::ExifTool::IdentifyTrailer($raf);
     865        $exifTool->ProcessTrailers($trailInfo) if $trailInfo;
     866    }
    787867
    788868    return 1;
     
    816896=head1 AUTHOR
    817897
    818 Copyright 2003-2007, Phil Harvey (phil at owl.phy.queensu.ca)
     898Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
    819899
    820900This library is free software; you can redistribute it and/or modify it
     
    834914
    835915=back
     916
     917=head1 ACKNOWLEDGEMENTS
     918
     919Thanks to Dave Nicholson for decoding a number of new tags.
    836920
    837921=head1 SEE ALSO
Note: See TracChangeset for help on using the changeset viewer.