<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#------------------------------------------------------------------------------
# File:         Leaf.pm
#
# Description:  Read Creo Leaf EXIF meta information
#
# Revisions:    09/28/2005  - P. Harvey Created
#------------------------------------------------------------------------------

package Image::ExifTool::Leaf;

use strict;
use vars qw($VERSION);
use Image::ExifTool qw(:DataAccess :Utils);
use Image::ExifTool::Exif;

$VERSION = '1.05';

sub ProcessLeaf($$$);

%Image::ExifTool::Leaf::Main = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Camera' },
    NOTES =&gt; q{
        These tags are found in .MOS images from Leaf digital camera backs as
        written by Creo Leaf Capture.  They exist within the Leaf-specific directory
        structure of EXIF tag 0x8606.  The tables below list observed Leaf tags,
        however ExifTool will extract any tags found in the Leaf directories even if
        they don't appear in these tables.
    },
    icc_camera_profile =&gt; {
        Name =&gt; 'ICC_Profile',
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::ICC_Profile::Main',
        },
    },
    icc_rgb_ws_profile =&gt; {
        Name =&gt; 'RGB_Profile',
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::ICC_Profile::Main',
        },
    },
    camera_profile =&gt; {
        Name =&gt; 'CameraProfile',
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::CameraProfile',
        },
    },
    JPEG_preview_data =&gt; {
        %Image::ExifTool::previewImageTagInfo,
    },
    JPEG_preview_info =&gt; 'PreviewInfo',
    icc_camera_to_tone_space_flow =&gt; {
        Name =&gt; 'ToneSpaceFlow',
        Description =&gt; 'ICC To Tone Space Flow',
        Format =&gt; 'int16u',
    },
    icc_camera_to_tone_matrix =&gt; {
        Name =&gt; 'ToneMatrix',
        Description =&gt; 'ICC To Tone Matrix',
        Format =&gt; 'int8u',
        Binary =&gt; 1,
    },
    PDA_histogram_data =&gt; {
        Name =&gt; 'PDAHistogram',
        Binary =&gt; 1,
    },
    pattern_ratation_angle =&gt; {
        Name =&gt; 'PatternAngle',
        Description =&gt; 'Pattern Rotation Angle',
        Format =&gt; 'int16u',
        Notes =&gt; '"ratation" is not a typo',
    },
    back_serial_number =&gt; {
        Name =&gt; 'BackSerial',
        Description =&gt; 'Back Serial Number',
        PrintConv =&gt; '$val =~ s/ .*//s; $val',
    },
    image_offset =&gt; { Format =&gt; 'int16u' },
);

%Image::ExifTool::Leaf::CameraProfile = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Camera' },
    CamProf_version =&gt; 'CameraProfileVersion',
    CamProf_name    =&gt; 'CameraName',
    CamProf_type    =&gt; 'CameraType',
    CamProf_back_type =&gt; 'CameraBackType',
    CamProf_back_type =&gt; {
        Name =&gt; 'CameraBackType',
    },
    CamProf_capture_profile =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::CaptureProfile',
        },
    },
    CamProf_image_profile =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::ImageProfile',
        },
    },
);

%Image::ExifTool::Leaf::CaptureProfile = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Image' },
    CaptProf_version        =&gt; {},
    CaptProf_name           =&gt; {},
    CaptProf_type           =&gt; {},
    CaptProf_back_type      =&gt; {},
    CaptProf_serial_number  =&gt; {
        Name =&gt; 'CaptureSerial',
        Description =&gt; 'Capture Serial Number',
        PrintConv =&gt; '$val =~ s/ .*//s; $val',
    },
    CaptProf_image_offset       =&gt; {},
    CaptProf_luminance_consts   =&gt; {},
    CaptProf_xy_offset_info     =&gt; 'XYOffsetInfo',
    CaptProf_color_matrix       =&gt; {},
    CaptProf_reconstruction_type=&gt; {},
    CaptProf_image_fields       =&gt; {},
    CaptProf_image_bounds       =&gt; {},
    CaptProf_number_of_planes   =&gt; {},
    CaptProf_raw_data_rotation  =&gt; {},
    CaptProf_color_averages     =&gt; {},
    CaptProf_mosaic_pattern     =&gt; {},
    CaptProf_dark_correction_type=&gt;{},
    CaptProf_right_dark_rect    =&gt; {},
    CaptProf_left_dark_rect     =&gt; {},
    CaptProf_center_dark_rect   =&gt; {},
    CaptProf_CCD_rect           =&gt; {},
    CaptProf_CCD_valid_rect     =&gt; {},
    CaptProf_CCD_video_rect     =&gt; {},
);

%Image::ExifTool::Leaf::ImageProfile = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Image' },
    ImgProf_version         =&gt; {},
    ImgProf_name            =&gt; {},
    ImgProf_type            =&gt; {},
    ImgProf_back_type       =&gt; {},
    ImgProf_shoot_setup =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::ShootSetup',
        },
    },
    ImgProf_image_status    =&gt; {},
    ImgProf_rotation_angle  =&gt; {},
);

%Image::ExifTool::Leaf::ShootSetup = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Image' },
    ShootObj_version        =&gt; {},
    ShootObj_name           =&gt; {},
    ShootObj_type           =&gt; {},
    ShootObj_back_type      =&gt; {},
    ShootObj_capture_setup =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::CaptureSetup',
        },
    },
    ShootObj_color_setup =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::ColorSetup',
        },
    },
    ShootObj_save_setup =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::SaveSetup',
        },
    },
    ShootObj_camera_setup =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::CameraSetup',
        },
    },
    ShootObj_look_header =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::LookHeader',
        },
    },
);

%Image::ExifTool::Leaf::CaptureSetup = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Image' },
    CaptureObj_version      =&gt; {},
    CaptureObj_name         =&gt; {},
    CaptureObj_type         =&gt; {},
    CaptureObj_back_type    =&gt; {},
    CaptureObj_neutals =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::Neutrals',
        },
    },
    CaptureObj_selection =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::Selection',
        },
    },
    CaptureObj_tone_curve =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::ToneCurve',
        },
    },
    CaptureObj_sharpness =&gt; {
        SubDirectory =&gt; {
            TagTable =&gt; 'Image::ExifTool::Leaf::Sharpness',
        },
    },
    CaptureObj_single_quality =&gt; {},
    CaptureObj_Multi_quality  =&gt; {},
);

%Image::ExifTool::Leaf::Neutrals = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Image' },
    NeutObj_version         =&gt; {},
    NeutObj_name            =&gt; {},
    NeutObj_type            =&gt; {},
    NeutObj_back_type       =&gt; {},
    NeutObj_neutrals        =&gt; {},
    NeutObj_color_casts     =&gt; {},
    NeutObj_shadow_end_points    =&gt; {},
    NeutObj_highlight_end_points =&gt; {},
);

%Image::ExifTool::Leaf::Selection = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Image' },
    SelObj_version          =&gt; {},
    SelObj_name             =&gt; {},
    SelObj_type             =&gt; {},
    SelObj_back_type        =&gt; {},
    SelObj_rect             =&gt; {},
    SelObj_resolution       =&gt; {},
    SelObj_scale            =&gt; {},
    SelObj_locks            =&gt; {},
    SelObj_orientation      =&gt; {},
);

%Image::ExifTool::Leaf::ToneCurve = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Image' },
    ToneObj_version         =&gt; {},
    ToneObj_name            =&gt; {},
    ToneObj_type            =&gt; {},
    ToneObj_back_type       =&gt; {},
    ToneObj_npts            =&gt; {},
    ToneObj_tones           =&gt; {},
    ToneObj_gamma           =&gt; {},
);

%Image::ExifTool::Leaf::Sharpness = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Image' },
    SharpObj_version        =&gt; {},
    SharpObj_name           =&gt; {},
    SharpObj_type           =&gt; {},
    SharpObj_back_type      =&gt; {},
    SharpObj_sharp_method   =&gt; {},
    SharpObj_data_len       =&gt; {},
    SharpObj_sharp_info     =&gt; {},
);

%Image::ExifTool::Leaf::ColorSetup = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Image' },
    ColorObj_version        =&gt; {},
    ColorObj_name           =&gt; {},
    ColorObj_type           =&gt; {},
    ColorObj_back_type      =&gt; {},
    ColorObj_has_ICC        =&gt; {},
    ColorObj_input_profile  =&gt; {},
    ColorObj_output_profile =&gt; {},
    ColorObj_color_mode     =&gt; {},
    ColorObj_color_type     =&gt; {},
);

%Image::ExifTool::Leaf::SaveSetup = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Other' },
    SaveObj_version         =&gt; {},
    SaveObj_name            =&gt; {},
    SaveObj_type            =&gt; {},
    SaveObj_back_type       =&gt; {},
    SaveObj_leaf_auto_active=&gt; {},
    SaveObj_leaf_hot_folder =&gt; {},
    SaveObj_leaf_output_file_type =&gt; {},
    SaveObj_leaf_auto_base_name   =&gt; {},
    SaveObj_leaf_save_selection   =&gt; {},
    SaveObj_leaf_open_proc_HDR    =&gt; {},
    SaveObj_std_auto_active       =&gt; {},
    SaveObj_std_hot_folder        =&gt; {},
    SaveObj_std_output_file_type  =&gt; {},
    SaveObj_std_output_color_mode =&gt; {},
    SaveObj_std_output_bit_depth  =&gt; {},
    SaveObj_std_base_name         =&gt; {},
    SaveObj_std_save_selection    =&gt; {},
    SaveObj_std_oxygen            =&gt; {},
    SaveObj_std_open_in_photoshop =&gt; {},
    SaveObj_std_scaled_output     =&gt; {},
    SaveObj_std_sharpen_output    =&gt; {},
);

%Image::ExifTool::Leaf::CameraSetup = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Camera' },
    CameraObj_version       =&gt; {},
    CameraObj_name          =&gt; {},
    CameraObj_type          =&gt; {},
    CameraObj_back_type     =&gt; {},
    CameraObj_ISO_speed     =&gt; {},
    CameraObj_strobe        =&gt; {},
    CameraObj_camera_type   =&gt; {},
    CameraObj_lens_type     =&gt; {},
    CameraObj_lens_ID       =&gt; {},
);

%Image::ExifTool::Leaf::LookHeader = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Other' },
    LookHead_version        =&gt; {},
    LookHead_name           =&gt; {},
    LookHead_type           =&gt; {},
    LookHead_back_type      =&gt; {},
);

# tag table for any unknown Leaf directories
%Image::ExifTool::Leaf::Unknown = (
    PROCESS_PROC =&gt; \&amp;ProcessLeaf,
    GROUPS =&gt; { 0 =&gt; 'Leaf', 2 =&gt; 'Unknown' },
);

# table for Leaf SubIFD entries
%Image::ExifTool::Leaf::SubIFD = (
    GROUPS =&gt; { 0 =&gt; 'MakerNotes', 1 =&gt; 'LeafSubIFD', 2 =&gt; 'Image'},
    WRITE_PROC =&gt; \&amp;Image::ExifTool::Exif::WriteExif,
    NOTES =&gt; q{
        Leaf writes a TIFF-format sub-IFD inside IFD0 of a MOS image.  No tags in
        this sub-IFD are currently known, except for tag 0x8606 which really
        shouldn't be here anyway (so it doesn't appear in the table below) because
        it duplicates a reference to the same data of tag 0x8606 in IFD0.
    },
);

# prepare Leaf tables by generating tag 'Name' and table 'NOTES'
{
    my @tableList = ( 'Image::ExifTool::Leaf::Main' );
    my ($tag, %doneTable);
    # keep prefix in tag name of common tags
    my %keepPrefix = ( Version=&gt;1, Name=&gt;1, Type=&gt;1, BackType=&gt;1 );
    while (@tableList) {
        my $table = shift @tableList;
        next if $doneTable{$table};
        my $prefix = ($table =~ /::Main$/) ? undef : '';
        $doneTable{$table} = 1;
        no strict 'refs';
        $table = \%$table;
        use strict 'refs';
        foreach $tag (keys %$table) {
            my $tagInfo = $$table{$tag};
            next unless ref $tagInfo eq 'HASH';
            next if $tag eq 'GROUPS';
            if (defined $prefix and not $prefix) {
                ($prefix = $tag) =~ s/_.*//;
            }
            unless ($$tagInfo{Name}) {
                my $name;
                ($name = $tag) =~ s/_(.)/\U$1/g;
                if ($prefix) {
                    $name =~ s/^$prefix//;
                    $name = $prefix . $name if $keepPrefix{$name};
                }
                $$tagInfo{Name} = ucfirst($name);
            }
            next unless $$tagInfo{SubDirectory};
            my $subTable = $tagInfo-&gt;{SubDirectory}-&gt;{TagTable};
            next unless $subTable =~ /::Leaf::/;
            push @tableList, $subTable;
        }
        next unless $prefix;
        $$table{NOTES} = "All B&lt;Tag ID&gt;'s in the following table have a " .
                         "leading '${prefix}_' which\nhas been removed.\n";
    }
}

#------------------------------------------------------------------------------
# Process Leaf information
# Inputs: 0) ExifTool object reference
#         1) Reference to directory information hash
#         2) Pointer to tag table for this directory
# Returns: 1 on success, otherwise returns 0 and sets a Warning
sub ProcessLeaf($$$)
{
    my ($et, $dirInfo, $tagTablePtr) = @_;
    my $dataPt = $$dirInfo{DataPt};
    my $dirStart = $$dirInfo{DirStart} || 0;
    my $dirLen = $$dirInfo{DirLen} || $$dirInfo{DataLen} - $dirStart;
    my $dirEnd = $dirStart + $dirLen;
    my $verbose = $et-&gt;Options('Verbose');
    my $pos = $dirStart;
    my $hdrLen = 52;    # header length for PKTS information
    my $success;

    $verbose and $et-&gt;VerboseDir('Leaf');
    for (;;) {
        last if $pos + $hdrLen &gt; $dirEnd;
        my $header = substr($$dataPt, $pos, $hdrLen);
        last unless substr($header, 0, 4) eq 'PKTS';
        $success = 1;
        my $size = Get32u(\$header, 48);
        $pos += $hdrLen;
        if ($pos + $size &gt; $dirEnd) {
            $et-&gt;Warn('Truncated Leaf data');
            last;
        }
        my $tag = substr($header, 8, 40);
        $tag =~ s/\0.*//s;
        next unless $tag;
        my $tagInfo = $et-&gt;GetTagInfo($tagTablePtr, $tag);
        # generate tag info for unknown tags
        my $val;
        if ($tagInfo and $$tagInfo{Format}) {
            $val = ReadValue($dataPt, $pos, $$tagInfo{Format}, undef, $size);
        } else {
            $val = substr($$dataPt, $pos, $size);
        }
        unless ($tagInfo) {
            my $name = ucfirst($tag);
            $name =~ s/_(.)/\U$1/g;
            if ($val =~ /^PKTS\0\0\0\x01/) {
                # also unpack unknown directories
                $tagInfo = {
                    Name =&gt; $name,
                    SubDirectory =&gt; { TagTable =&gt; 'Image::ExifTool::Leaf::Unknown' },
                };
            } elsif ($tagTablePtr ne \%Image::ExifTool::Leaf::Main or
                     $et-&gt;Options('Unknown'))
            {
                $tagInfo = {
                    Name =&gt; $name,
                    Writable =&gt; 0,
                    PrintConv =&gt; 'length($val) &gt; 60 ? substr($val,0,55) . "[...]" : $val',
                };
                # make tags in main table unknown because they tend to be binary
                $$tagInfo{Unknown} = 1 if $tagTablePtr eq \%Image::ExifTool::Leaf::Main;
            }
            $tagInfo and AddTagToTable($tagTablePtr, $tag, $tagInfo);
        }
        if ($verbose) {
            $et-&gt;VerboseInfo($tag, $tagInfo,
                Table   =&gt; $tagTablePtr,
                Value   =&gt; $val,
                DataPt  =&gt; $dataPt,
                DataPos =&gt; $$dirInfo{DataPos},
                Size    =&gt; $size,
                Start   =&gt; $pos,
            );
        }
        if ($tagInfo) {
            if ($$tagInfo{SubDirectory}) {
                my %subdirInfo = (
                    DataPt =&gt; $dataPt,
                    DirLen =&gt; $size,
                    DirStart =&gt; $pos,
                    DataPos =&gt; $$dirInfo{DataPos},
                    DirName =&gt; 'Leaf PKTS',
                );
                my $subTable = GetTagTable($tagInfo-&gt;{SubDirectory}-&gt;{TagTable});
                $et-&gt;ProcessDirectory(\%subdirInfo, $subTable);
            } else {
                $val =~ tr/\n/ /;   # translate newlines to spaces
                $val =~ s/\0+$//;   # remove null terminators
                $et-&gt;FoundTag($tagInfo, $val);
            }
        }
        $pos += $size;
    }
    $success or $et-&gt;Warn('Bad format Leaf data');
    return $success;
}

1;  # end

__END__

=head1 NAME

Image::ExifTool::Leaf - Read Creo Leaf EXIF meta information

=head1 SYNOPSIS

This module is loaded automatically by Image::ExifTool when required.

=head1 DESCRIPTION

This module contains definitions required by Image::ExifTool to interpret
meta information from Leaf digital camera backs written by Creo Leaf
Capture.

=head1 AUTHOR

Copyright 2003-2015, Phil Harvey (phil at owl.phy.queensu.ca)

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 SEE ALSO

L&lt;Image::ExifTool::TagNames/Leaf Tags&gt;,
L&lt;Image::ExifTool(3pm)|Image::ExifTool&gt;

=cut
</pre></body></html>