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/HP.pm

    r16842 r24107  
    1313use Image::ExifTool qw(:DataAccess :Utils);
    1414
    15 $VERSION = '1.01';
     15$VERSION = '1.02';
    1616
    1717sub ProcessHP($$$);
     18sub ProcessTDHD($$$);
    1819
    1920# HP EXIF-format maker notes (or is it Vivitar?)
     
    2324        These tables list tags found in the maker notes of some Hewlett-Packard
    2425        camera models.
    25        
     26
    2627        The first table lists tags found in the EXIF-format maker notes of the
    2728        PhotoSmart 720 (also used by the Vivitar ViviCam 3705, 3705B and 3715).
     
    4344   'PreviewImage' => {
    4445        Name => 'PreviewImage',
    45         ValueConv => '$self->ValidateImage(\$val,$tag)',
     46        RawConv => '$self->ValidateImage(\$val,$tag)',
    4647    },
    4748   'Serial Number' => 'SerialNumber',
     
    110111    },
    111112);
     113
     114# proprietary format TDHD data written by Photosmart R837 (ref PH)
     115%Image::ExifTool::HP::TDHD = (
     116    PROCESS_PROC => \&ProcessTDHD,
     117    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
     118    NOTES => q{
     119        These tags are extracted from the APP6 "TDHD" segment of Photosmart R837
     120        JPEG images.  Many other unknown tags exist in is data, and can be seen with
     121        the Unknown (-u) option.
     122    },
     123    # (all subdirectories except TDHD and LSLV are automatically recognized
     124    # by their "type" word of 0x10001)
     125    TDHD => {
     126        Name => 'TDHD',
     127        SubDirectory => { TagTable => 'Image::ExifTool::HP::TDHD' },
     128    },
     129    LSLV => {
     130        Name => 'LSLV',
     131        SubDirectory => { TagTable => 'Image::ExifTool::HP::TDHD' },
     132    },
     133    FWRV => 'FirmwareVersion',
     134    CMSN => 'SerialNumber', # (unverified)
     135    # LTEM - some temperature?
     136);
     137
     138#------------------------------------------------------------------------------
     139# Process HP APP6 TDHD metadata (ref PH)
     140# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
     141# Returns: 1 on success
     142sub ProcessTDHD($$$)
     143{
     144    my ($exifTool, $dirInfo, $tagTablePtr) = @_;
     145    my $dataPt = $$dirInfo{DataPt};
     146    my $dataPos = $$dirInfo{DataPos};
     147    my $pos = $$dirInfo{DirStart};
     148    my $dirEnd = $pos + $$dirInfo{DirLen};
     149    my $unknown = $exifTool->Options('Unknown') || $exifTool->Options('Verbose');
     150    $exifTool->VerboseDir('TDHD', undef, $$dirInfo{DirLen});
     151    SetByteOrder('II');
     152    while ($pos + 12 < $dirEnd) {
     153        my $tag = substr($$dataPt, $pos, 4);
     154        my $type = Get32u($dataPt, $pos + 4);
     155        my $size = Get32u($dataPt, $pos + 8);
     156        $pos += 12;
     157        last if $size < 0 or $pos + $size > $dirEnd;
     158        if ($type == 0x10001) {
     159            # this is a subdirectory containing more tags
     160            my %dirInfo = (
     161                DataPt   => $dataPt,
     162                DataPos  => $dataPos,
     163                DirStart => $pos,
     164                DirLen   => $size,
     165            );
     166            $exifTool->ProcessDirectory(\%dirInfo, $tagTablePtr);
     167        } else {
     168            if (not $$tagTablePtr{$tag} and $unknown) {
     169                my $name = $tag;
     170                $name =~ tr/-_A-Za-z0-9//dc;    # remove invalid characters
     171                my %tagInfo = (
     172                    Name => "HP_TDHD_$name",
     173                    Unknown => 1,
     174                );
     175                # guess format based on data size
     176                if ($size == 1) {
     177                    $tagInfo{Format} = 'int8u';
     178                } elsif ($size == 2) {
     179                    $tagInfo{Format} = 'int16u';
     180                } elsif ($size == 4) {
     181                    $tagInfo{Format} = 'int32s';
     182                } elsif ($size > 80) {
     183                    $tagInfo{Binary} = 1;
     184                }
     185                Image::ExifTool::AddTagToTable($tagTablePtr, $tag, \%tagInfo);
     186            }
     187            $exifTool->HandleTag($tagTablePtr, $tag, undef,
     188                DataPt  => $dataPt,
     189                DataPos => $dataPos,
     190                Start   => $pos,
     191                Size    => $size,
     192            );
     193        }
     194        $pos += $size;
     195    }
     196    return 1;
     197}
    112198
    113199#------------------------------------------------------------------------------
     
    164250=head1 AUTHOR
    165251
    166 Copyright 2003-2007, Phil Harvey (phil at owl.phy.queensu.ca)
     252Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
    167253
    168254This library is free software; you can redistribute it and/or modify it
Note: See TracChangeset for help on using the changeset viewer.