Search for TIF grayscale images

Started by w64bit, October 03, 2020, 08:23:08 AM

Previous topic - Next topic

w64bit

Hello,
Is there any way to search for TIF grayscale images in a folder (with all subfolders) and make a list of them (path+name)?
Thank you

Phil Harvey

Sure.  You'll have to figure out some tags that are unique for TIFF grayscale images, then a command something like this:

exiftool -if "$sometag eq 'something' and $someothertag eq 'something else'" -filepath -s3 DIR

- Phil
...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 ($).

w64bit

Tried
"C:\Users\PC\Desktop\exiftool(-k).exe" -if "$File Type eq 'TIFF' and $Bits Per Sample eq '8'" -filepath -s3 "C:\Users\PC\Desktop\"
and it displays
1 directories scanned
0 image files read

StarGeek

Quote from: w64bit on October 03, 2020, 10:41:21 AM
"$File Type eq 'TIFF' and $Bits Per Sample eq '8'"

Tag names do not have spaces in them.  See FAQ #2.

One additional thing to watch for is images that appear to be grayscale but are saved as if they were RGB.  This is pretty common among jpegs.
* 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).

w64bit

I found the BitsPerSample tag ID
"C:\Users\USER\Desktop\exiftool(-k).exe" -if "$0x0102 eq 8" -filepath -s3 -ext tif "C:\Users\USER\Desktop\*"
2 files failed condition
even if one of them is not

StarGeek

You can't use the tag id.  Use the tag name.  Also the string after eq needs to be in single quotes if in CMD.
exiftool -if "$BitsPerSample eq '8' " -ext tif -filepath C:\Users\USER\Desktop\
* 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).

w64bit

#6
Thank you. I added * and -r
exiftool -if "$BitsPerSample eq '8'" -ext tif -filepath -s3 "C:\Users\USER\Desktop\*" -r

Is it possible that ExifTool to create one TXT file with a list of all found files (path+name)?
I tried -w file.txt but it creates one txt file for any tif file found.

Also, how can I found the...
Quote... images that appear to be grayscale but are saved as if they were RGB.

StarGeek

Quote from: w64bit on October 03, 2020, 01:33:24 PM
Thank you. I added * and -r

The asterisk isn't necessary and if you try to use it as part of a file name while recursing into subdirectories, i.e. *.jpg, you won't get the results you expect.  See Common Mistake #2

QuoteIs it possible that ExifTool to create one TXT file with a list of all found files (path+name)?
I tried -w file.txt but it creates one txt file for any tif file found.

Yes, the -w (textout) option won't work.  As it says:
   It is not possible to specify a simple filename as an argument -- creating a single output file from multiple source files is typically done by shell redirection

Just use your command and redirect the output into a file
exiftool -if "$BitsPerSample eq '8'" -ext tif -filepath -s3 C:\Users\USER\Desktop -r >C:\Users\USER\Desktop\list.txt

QuoteAlso, how can I found the...
Quote... images that appear to be grayscale but are saved as if they were RGB.

You pretty much can't with exiftool.  For example, see this attached image.  It looks like a greyscale tiff but it has full RGB bit planes

C:\>exiftool -g1 -a -s -bits* C:\Users\Bryan\Downloads\gradient_range2.tif
---- IFD0 ----
BitsPerSample                   : 8 8 8
* 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).

Luuk2005

Greetings, Im steal this from the voidtools forum, because its almost like the exact same question!
exiftool -r -q -ext tiff -ext tif -if "$FileType eq 'TIFF' and $PhotometricInterpretation#<2" -p \"$FilePath\" C:/DirPath >MyGrayScales.txt

Im not have the .tiff files for testing, but if someone please recommend for testing, its much appreciated. Also, if someone please can post website where to find many different filetypes with many different metada, that is very much to be appreciated. Im already downloaded StarGeek's metadata-template.args and its very helpful, but also I love to have one test folder with many, many different filetypes, but with much different metadata in each, so it makes a good test folder, because in my files, I always delete the metadata so its not helpul.
Windows8.1-64bit,  exiftool-v12.92(standalone),  sed-v4.0.7

Phil Harvey

There is a number of test files in the t/images directory of the full ExifTool distribution.  They are also on github here.

- Phil
...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 ($).