Composite tags: bit depth and pixel aspect ratio

Started by blue-j, October 15, 2020, 12:47:27 AM

Previous topic - Next topic

blue-j

Hi all!  I'm about to embark on making composite tags for bit depth and PAR (pixel aspect ratio), but thought I'd check in to see if anyone has already paved the way on these?  Also, if you are interested, I can share them here as well.  Lemme know.

- J

Phil Harvey

There are already standard tags for these.  I'm not sure what you're trying to do.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

I think I misunderstood what composite tags were.  I was trying to make a single field that would populate if a value were present in a list of fields defined in config.  But maybe that logic is best down outside of ET?  - J

StarGeek

Quote from: blue-j on October 18, 2020, 04:11:08 PM
I think I misunderstood what composite tags were.  I was trying to make a single field that would populate if a value were present in a list of fields defined in config. 

You can do that.  One example would be the Composite:GPSLatitude tag.  It is populated by combining the GPS:GPSLatitude and GPS:GPSLatitudeRef tags. See the Composite tags page for other examples.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

It sounds like you understood the Composite tags properly.  I just wasn't understanding what you were trying to do.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

Is there a way to prescribe a cascading priority among the Desired fields?  Do they cascade in importance, first one found is used?  Not sure how this works, tried to find the documentation, read the sample config.  (I try not to ask unless I've tried to figure it out already and failed, to honor your time).

For example, say we wanted a composite field for x resolution, composed of these possible fields:

file:xresolution
exif:xresolution
xmp-photoshop:xresolution
jfif:xresolution

and whichever one was populated first, as it went down the list, would be used...?  Is this possible?

-J

StarGeek

Quote from: blue-j on October 18, 2020, 09:19:54 PM
Is there a way to prescribe a cascading priority among the Desired fields?  Do they cascade in importance, first one found is used?

You have to decide that in the code.  A good example would be the time_zone.config.  Listing just the first few lines
                # TimeZone from MakeNotes (camera setting)
                return TimeZoneString($val[0] + ($val[1] ? 60 : 0)) if defined $val[0];

                # TimeZone from QuickTime (camera setting)
                return TimeZoneString($val[2]) if $val[2];


If it can get the time zone from the MakerNotes, it returns that.  If not the, then the QuickTime:TimeZone, etc...
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

blue-j

Joy!  Thank you for sharing your knowledge.  This is very helpful, and having an example to look at is very helpful.  Much thanks!!  : )

- J

blue-j

How does this look?

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        # Combine fields reporting Pixel Aspect Ratio
        PAR => {
            Desire => {
                # PAR information tags ordered by precedence
                0 => 'Photoshop:PixelAspectRatio',
                1 => 'OpenEXR:PixelAspectRatio',
                2 => 'Radiance:PixelAspectRatio',
                3 => 'GIF:PixelAspectRatio',
                4 => 'MakerNotes:PixelAspectRatio',
            },
            RawConv => q{
                # PAR from Photoshop
                return PARString($val[0]) if $val[0];

                # PAR from OpenEXR
                return PARString($val[1]) if $val[1];

                # PAR from Radiance
                return PARString($val[2]) if $val[2];

                # PAR from GIF
                return PARString($val[3]) if $val[3];   
               
                # PAR from Maker Notes
                return PARString($val[4]) if $val[4];               
                }
                return undef;
            },
        },
    },
);

Phil Harvey

Aside from the fact that PARString is not defined, this looks good.

But you may do it more succinctly.  The entire RawConv may be replace by this:

            RawConv => 'PARString($val[0] || $val[1] || $val[2] || $val[3] || $val[4])',

(As long as PARString returns undef for a false input.)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

Dang it, I just can't get it working.

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        # Combine fields reporting Pixel Aspect Ratio
        PAR => {
            Desire => {
                # PAR information tags ordered by precedence
                0 => 'Photoshop:PixelAspectRatio',
                1 => 'OpenEXR:PixelAspectRatio',
                2 => 'Radiance:PixelAspectRatio',
                3 => 'GIF:PixelAspectRatio',
                4 => 'MakerNotes:PixelAspectRatio',
            },
        RawConv => 'PAR($val[0] || $val[1] || $val[2] || $val[3] || $val[4])',                }
                return undef;
        },
    },
);


I apologize for troubling anyone - I really tried to make it work and tried a number of combos.  - J

Phil Harvey

What are you trying to do with the PAR() function in your conversion?  I think there is a basic misunderstanding here.  Also, there are structural problems in your config file.

I think you might want just this:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        # Combine fields reporting Pixel Aspect Ratio
        PAR => {
            Desire => {
                # PAR information tags ordered by precedence
                0 => 'Photoshop:PixelAspectRatio',
                1 => 'OpenEXR:PixelAspectRatio',
                2 => 'Radiance:PixelAspectRatio',
                3 => 'GIF:PixelAspectRatio',
                4 => 'MakerNotes:PixelAspectRatio',
            },
            ValueConv => '$val[0] || $val[1] || $val[2] || $val[3] || $val[4]',
        },
    },
);


Also, I am using ValueConv here because I don't think you want to deal with the raw values of some of these tags.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

You're very kind to take the time to help me.  Thank you!  This works like a charm, and will inform my future efforts!  : )

- J