0

I just tried to get the embedded color profile of a csv file, which returns no input

$ exiftool -a -S -G0 -ColorSpace -InteropIndex -WhitePoint -PrimaryChromaticities -Gamma -ICC_Profile:all my_data.csv
$ 

and just running exiftool my_data.csv prints stuff and doesn't set an error status code

$ exiftool my_data.csv 
ExifTool Version Number         : 12.05
File Name                       : my_data.csv
Directory                       : .
File Size                       : 84 kB
File Modification Date/Time     : 2021:03:22 19:06:19-04:00
File Access Date/Time           : 2021:03:22 19:06:23-04:00
File Inode Change Date/Time     : 2021:03:22 19:06:19-04:00
File Permissions                : rw-rw-r--
File Type                       : CSV
File Type Extension             : csv
MIME Type                       : text/csv
MIME Encoding                   : us-ascii
Newlines                        : Unix LF
Delimiter                       : Comma
Quoting                         : Double quotes
Column Count                    : 11
Row Count                       : 241
$ echo $?
0
$ 

Can I tell exiftool to error out if the input isn't an image somehow? Do I have to check the File Type and handle it myself or let the error happen later in my code? I don't know what all valid image file types are.

1

Not without editing the source code.

You could exclude file types with the -ext (-extension) option, using two dashes instead of just one. For example, you could add
--ext txt --ext csv
and exiftool will not process files with a CSV or TXT extension.

You could also use the -if option to check if the MIMEType is an image
exiftool -if "$MIMEType=~/^image/" …

If this command is run under Unix/Mac, change the double quotes to single quotes to avoid bash interpretation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.