- Timestamp:
- 2011-06-01T12:33:42+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cpan/Image/ExifTool/CanonRaw.pm
r16842 r24107 12 12 # 2) http://www.wonderland.org/crw/ 13 13 # 3) http://xyrion.org/ciff/CIFFspecV1R04.pdf 14 # 4) Dave Nicholson private communication (PowerShot S30) 14 15 #------------------------------------------------------------------------------ 15 16 … … 18 19 use strict; 19 20 use vars qw($VERSION $AUTOLOAD %crwTagFormat); 20 use Image::ExifTool qw(:DataAccess );21 use Image::ExifTool qw(:DataAccess :Utils); 21 22 use Image::ExifTool::Exif; 22 23 use Image::ExifTool::Canon; 23 24 24 $VERSION = '1. 42';25 $VERSION = '1.54'; 25 26 26 27 sub WriteCRW($$); … … 132 133 }, 133 134 }, 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 }, 135 143 0x102d => { 136 144 Name => 'CanonCameraSettings', … … 138 146 SubDirectory => { 139 147 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', 140 156 }, 141 157 }, … … 152 168 { 153 169 Name => 'CustomFunctions10D', 154 Condition => '$self->{ CameraModel} =~ /EOS 10D/',170 Condition => '$self->{Model} =~ /EOS 10D/', 155 171 SubDirectory => { 156 172 Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)', … … 160 176 { 161 177 Name => 'CustomFunctionsD30', 162 Condition => '$self->{ CameraModel} =~ /EOS D30\b/',178 Condition => '$self->{Model} =~ /EOS D30\b/', 163 179 SubDirectory => { 164 180 Validate => 'Image::ExifTool::Canon::Validate($dirData,$subdirStart,$size)', … … 168 184 { 169 185 Name => 'CustomFunctionsD60', 170 Condition => '$self->{ CameraModel} =~ /EOS D60\b/',186 Condition => '$self->{Model} =~ /EOS D60\b/', 171 187 SubDirectory => { 172 188 # the stored size in the D60 apparently doesn't include the size word: … … 241 257 ValueConv => '$val / 1000', 242 258 ValueConvInv => '$val * 1000', 243 PrintConv => '"$val s ec"',244 PrintConvInv => '$val=~s/\s*s ec.*//;$val',259 PrintConv => '"$val s"', 260 PrintConvInv => '$val=~s/\s*s.*//;$val', 245 261 }, 246 262 0x1807 => { … … 250 266 PrintConvInv => '$val=~s/\s*mm$//;$val', 251 267 }, 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 ], 259 291 0x180e => { 260 292 Name => 'TimeStamp', … … 281 313 Name => 'MeasuredEV', 282 314 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 285 318 }, 286 319 Format => 'float', 320 ValueConv => '$val + 5', 321 ValueConvInv => '$val - 5', 287 322 }, 288 323 0x1817 => { … … 295 330 0x1818 => { #3 296 331 Name => 'ExposureInfo', 332 Groups => { 1 => 'CIFF' }, # (only so CIFF shows up in group lists) 297 333 Writable => 0, 298 334 SubDirectory => { … … 314 350 Name => 'DecoderTable', 315 351 Writable => 0, 352 SubDirectory => { 353 TagTable => 'Image::ExifTool::CanonRaw::DecoderTable', 354 }, 316 355 }, 317 356 0x183b => { #PH … … 334 373 Writable => 'resize', # 'resize' allows this value to change size 335 374 Permanent => 0, 336 ValueConv => '$self->ValidateImage(\$val,$tag)', 337 ValueConvInv => '$val', 375 RawConv => '$self->ValidateImage(\$val,$tag)', 338 376 }, 339 377 0x2008 => { … … 342 380 WriteCheck => '$self->CheckImage(\$val)', 343 381 Permanent => 0, 344 ValueConv => '$self->ValidateImage(\$val,$tag)', 345 ValueConvInv => '$val', 382 RawConv => '$self->ValidateImage(\$val,$tag)', 346 383 }, 347 384 # the following entries are subdirectories … … 398 435 Name => 'Make', 399 436 Format => 'string[6]', # "Canon\0" 400 DataMember => ' CameraMake',401 RawConv => '$self->{ CameraMake} = $val',437 DataMember => 'Make', 438 RawConv => '$self->{Make} = $val', 402 439 }, 403 440 6 => { 404 441 Name => 'Model', 405 Format => 'string [$size-6]',442 Format => 'string', # no size = to the end of the data 406 443 Description => 'Camera Model Name', 407 DataMember => ' CameraModel',408 RawConv => '$self->{ CameraModel} = $val',444 DataMember => 'Model', 445 RawConv => '$self->{Model} = $val', 409 446 }, 410 447 ); … … 425 462 ValueConvInv => 'GetUnixTime($val)', 426 463 PrintConv => '$self->ConvertDateTime($val)', 427 PrintConvInv => '$ val',464 PrintConvInv => '$self->InverseDateTime($val)', 428 465 }, 429 466 1 => { #3 … … 514 551 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' }, 515 552 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 }, 518 567 ); 519 568 … … 523 572 CHECK_PROC => \&Image::ExifTool::CheckBinaryData, 524 573 FORMAT => 'int32u', 525 FIRST_ENTRY => 1,574 FIRST_ENTRY => 0, 526 575 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' }, 527 576 # Note: Don't make these writable (except rotation) because it confuses … … 541 590 5 => 'ColorBitDepth', #3 542 591 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) 543 621 ); 544 622 … … 576 654 $raf->Read($buff, 10 * $entries) == 10 * $entries or return 0; 577 655 578 $verbose and $exifTool->VerboseDir(' Raw', $entries);656 $verbose and $exifTool->VerboseDir('CIFF', $entries); 579 657 my $index; 580 658 for ($index=0; $index<$entries; ++$index) { … … 649 727 $value = "Binary data $size bytes"; 650 728 if ($tagInfo) { 651 if ($exifTool->Options('Binary') ) {729 if ($exifTool->Options('Binary') or $verbose) { 652 730 # read the value anyway 653 731 unless ($raf->Seek($ptr, 0) and $raf->Read($value, $size) == $size) { … … 695 773 my $newTagTable; 696 774 if ($$subdir{TagTable}) { 697 $newTagTable = Image::ExifTool::GetTagTable($$subdir{TagTable});775 $newTagTable = GetTagTable($$subdir{TagTable}); 698 776 unless ($newTagTable) { 699 777 warn "Unknown tag table $$subdir{TagTable}\n"; … … 761 839 762 840 # set the FileType tag unless already done (ie. APP0 CIFF record in JPEG image) 763 $exifTool->SetFileType() unless $exifTool->GetValue('FileType');841 $exifTool->SetFileType(); 764 842 765 843 # build directory information for main raw directory … … 774 852 775 853 # process the raw directory 776 my $rawTagTable = Image::ExifTool::GetTagTable('Image::ExifTool::CanonRaw::Main');854 my $rawTagTable = GetTagTable('Image::ExifTool::CanonRaw::Main'); 777 855 unless ($exifTool->ProcessDirectory(\%dirInfo, $rawTagTable)) { 778 856 $exifTool->Warn('CRW file format error'); … … 782 860 $buildMakerNotes and SaveMakerNotes($exifTool); 783 861 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 } 787 867 788 868 return 1; … … 816 896 =head1 AUTHOR 817 897 818 Copyright 2003-20 07, Phil Harvey (phil at owl.phy.queensu.ca)898 Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca) 819 899 820 900 This library is free software; you can redistribute it and/or modify it … … 834 914 835 915 =back 916 917 =head1 ACKNOWLEDGEMENTS 918 919 Thanks to Dave Nicholson for decoding a number of new tags. 836 920 837 921 =head1 SEE ALSO
Note:
See TracChangeset
for help on using the changeset viewer.