exiftool-rb/exiftool_vendored.rb

View on GitHub
bin/config_files/depthmap.config

Summary

Maintainability
Test Coverage
#------------------------------------------------------------------------------
# File:         depthmap.config
#
# Description:  Composite tag definitions to extract DepthMap and ConfidenceMap
#               images from Google Dynamic-depth images
#
# Usage:        exiftool -config depthmap.config -W %d%f_%t.%s -depthmap -confidencemap -b DIR
#
# Requires:     ExifTool version 11.88 or later
#
# Revisions:    2020/02/20 - P. Harvey Created
#------------------------------------------------------------------------------

sub GetTrailerImage($$)
{
    my ($val, $type) = @_;
    my @uri = ref $$val[1] ? @{$$val[1]} : $$val[1];
    my @len = ref $$val[2] ? @{$$val[2]} : $$val[2];
    my $start = 0;
    for (my $i=0; $i<@uri; ++$i) {
        if ($uri[$i] =~ /$type/) {
            my $img = substr(${$$val[0]}, $start, $len[$i]);
            return \$img;
        }
        $start += $len[$i];
    }
    return undef;
}

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        DepthMap => {
            Require => {
                0 => 'Trailer',
                1 => 'ContainerDirectoryItemDataURI',
                2 => 'ContainerDirectoryItemLength',
            },
            ValueConv => 'GetTrailerImage(\@val, "depthmap")',
        },
        ConfidenceMap => {
            Require => {
                0 => 'Trailer',
                1 => 'ContainerDirectoryItemDataURI',
                2 => 'ContainerDirectoryItemLength',
            },
            ValueConv => 'GetTrailerImage(\@val, "confidencemap")',
        },
    },
);

%Image::ExifTool::UserDefined::Options = (
    RequestTags => 'Trailer',
);

#------------------------------------------------------------------------------
1;  #end