ExifTool Forum

ExifTool => Newbies => Topic started by: j99mac on October 05, 2021, 09:44:27 AM

Title: make command to write to resolution
Post by: j99mac on October 05, 2021, 09:44:27 AM
I looking to make an if then statement
if xresolution=300 then make yresolution= 300

This is what I have so far

exiftool -if '$ xresolution eq "300"' –EXIF: yresolution="300"

would this work? need some help
Title: Re: make command to write to resolution
Post by: StarGeek on October 05, 2021, 10:51:11 AM
Remove the space between –EXIF: and yresolution="300" and it should work.  Test it out to see if it does what you want.

Title: Re: make command to write to resolution
Post by: j99mac on October 05, 2021, 11:13:36 AM
I just ran the Command
exiftool -if '$ xresolution eq "300"' –EXIF:yresolution="300"

and got warning" Tag 'EXIF:yresolution' is not dfined
Nothing to do.
Title: Re: make command to write to resolution
Post by: StarGeek on October 05, 2021, 11:25:12 AM
Works here
C:\>exiftool -G -a -s -*resolution y:\!temp\Test4.jpg
[EXIF]          XResolution                     : 300
[EXIF]          YResolution                     : 200

C:\>exiftool -P -overwrite_original -if "$XResolution eq '300' " -EXIF:YResolution="300" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G -a -s -*resolution y:\!temp\Test4.jpg
[EXIF]          XResolution                     : 300
[EXIF]          YResolution                     : 300


Looking closer, you're using an –, not a hyphen.  Also, no space between $ and XResolution.
Title: Re: make command to write to resolution
Post by: j99mac on October 05, 2021, 11:41:10 AM
I am running the command on a unix computer

exiftool -P -overwrite_original -if "$XResolution eq '300' " -EXIF:YResolution="300" /home/pi/Dsktop/

get
0 images files read

to I have the location of the files in the wrong place?
Title: Re: make command to write to resolution
Post by: StarGeek on October 05, 2021, 01:10:52 PM
Swap double/single quotes on Linux/Mac.  Using double quotes around a dollar sign $ will cause the shell to interpret it as the start of a shell variable instead of an exiftool tag.  So use
-if '$XResolution eq "300" '

Quote from: j99mac on October 05, 2021, 11:41:10 AMto I have the location of the files in the wrong place?

Files and options, with limited exceptions, can be anywhere in the command.  Exceptions include the -Config option (https://exiftool.org/exiftool_pod.html#config-CFGFILE), which must be first in the command.  And you can not put things between options that require a second parameter, such as -if EXPR.
Title: Re: make command to write to resolution
Post by: j99mac on October 05, 2021, 01:22:04 PM
this is what I am putting in

exiftool -P -overwrite_original -if '$XResolution eq "300" ' '-EXIF:YResolution="300" '

still giving an error
this is the error
Not a floating point number for IFD0:YResolution
Title: Re: make command to write to resolution
Post by: StarGeek on October 05, 2021, 01:55:14 PM
By adding quotes around the assignment part, you are now trying to set EXIF:YResolution to a value of "300" (quotes included).

Use this
exiftool -P -overwrite_original -if '$XResolution eq "300" ' -EXIF:YResolution=300 file.jpg
Title: Re: make command to write to resolution
Post by: j99mac on October 05, 2021, 02:56:53 PM
Thank you this worked