Setting a parameter/value in a config file

Started by ArchZu, September 06, 2024, 11:05:58 AM

Previous topic - Next topic

ArchZu

in an exiftool .config file, how do I use the parameters entered by the user within it?
I want to do this:

If the user does not type anything, they should keep the "%.3f".
exiftool -config -ImageSize -AspectRatioProportionFactor image.png
Aspect Ratio Proportion Factor  : 0.707
If you enter a number smaller than 3, must keep "%.3f".
exiftool -config -ImageSize -AspectRatioProportionFactor=2 image.png
Aspect Ratio Proportion Factor  : 0.707
If you enter a number greater than 3, must change the 3 to the number entered "%.3f"("%.5f").
exiftool -config -ImageSize -AspectRatioProportionFactor=5 image.png
Aspect Ratio Proportion Factor  : 0.70696
If you enter a number greater than 53, must use 53 for the number entered "%.53f".
exiftool -config -ImageSize -AspectRatioProportionFactor=80 image.png
Aspect Ratio Proportion Factor  : 0.7069555302166476984382370574166998267173767089843750
        AspectRatioProportionFactor => {
            Require => {
                0 => 'ImageWidth',
                1 => 'ImageHeight',
            },
            ValueConv => q{
                my $width = $val[0];
                my $height = $val[1];

                # Dividir o primeiro valor pelo segundo
                return sprintf("%.3f", $width / $height);
            },
        },

[ConfigFile]
Arch Linux (KDE Plasma)

StarGeek

You use the -UserParam option to pass values to your config. Your command would be something like
exiftool -config my.config -AspectRatioProportionFactor -userparam ProportionAccuracy=5 image.png

For an example, see the age.config file. In that file, a date is passed via the -UserParam
exiftool -config age.config -userparam birthday=1990:09:31 -age a.jpg

And the value is accessed by this code
my $bday = $self->Options(UserParam => 'Birthday');
See Options Userparam for the more technical details.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

ArchZu

I will need to type the "UserParam" every time, is it possible to just do -ARPF=4?

exiftool -config aspect_ratio.config -ImageSize -ARPF -UserParam RatioSize=10 9.png
Image Size                      : 2480x3508
Aspect Ratio Proportion Factor  : 0.7069555302


            ValueConv => q{
                my $width = $val[0];
                my $height = $val[1];

                # Dividir o primeiro valor pelo segundo
#                 return sprintf("%.3f", $width / $height);

                # Definir o UserParam
                my $fmt = $self->Options(UserParam => 'RatioLength') or return sprintf("%.3f", $width / $height);
                return sprintf("%.*f", $fmt, $width / $height);
            },
Arch Linux (KDE Plasma)

StarGeek

I'm pretty sure that you would need to use -UserParam every time, and you can't set a tag to a value and also have it return a value. That was the whole point of creating the -UserParam option. See this thread.

If you look at the flowchart on the "Under the Hood" of ExifTool page, you'll see that -TAG=Value starts in the upper left and is only connected with red "write mode" lines. These red lines only go to the bottom right, which is output Image/Metadata files. Only the blue "read mode" lines go to the upper right where Console Output is.

Phil would have to verify this, and he's currently AFK for a couple weeks.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

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