Need help searching photos by exif data

I am trying to find an easy way, with a GUI, to find all photos, for instance, shot with a certain lens, or at a specific shutter speed, or some other info that is available in the file exif.

Naturally, I turned to Digikam, and while it is able to do this if I only specify the lens model, I think am am missing something, because it seems to go crazy every time I tell it to look in a specific folder and show me photos shot with a certain lens. It will then tell me there are no files matching that query. Odd!

I also gave Shotwell a try but it doesn’t seem to be able to search by camera model, or lens model…

Not on my computer now so I can’t recite details but you can use exiftool or exiv2 to create a detailed list. Whether grepped in-situ or turned into a text file (or csv) you can essentially create a full database of all your images’ metadata. Then just browse / search as needed.

Also, I don’t think it’s recursive but, e.g., ART’s file browser can filter by metadata tags.

1 Like

hi, did you try Ansel?

image

digiKam works for me. I thought I was able to reproduce the issue, but only because I accidentally selected the wrong folder at first (one that didn’t have pictures shot with the lens I was searching for). Once I chose the right folder the files I expected to see were shown. I even went further and added aperture settings to the search and it worked as expected. I’m using version 8.1.0 in case that’s relevant.

It appears it is not able to search recursively?

I have a folder structure like this Fuji Jpegs/2023/2023-09/2023-09-01 and if I search in the root forlder of Fuji Jpegs nothing comes up, but if I choose the folder with pictures in it, like, say 2023-09-01, results will appear.

Can I make it search recursively?

I don’t think there’s an option to search recursively, but you can select all subfolders using the right-click context menu on the root folder:
image
Maybe that will work for you?

I have no idea if this is of any help, but below is a simple bash script I wrote to extract various tags and send them to STDOUT in CSV format. As with anything I’ve written I’m sure it can be vastly improved and certainly, it was a quick hack even by my low standards (not to mention since retirement from IT I’m way out of practice / memory). And these days I’m on Windows, so this was run from WSL.

But it works …or at least, worked for me. :slight_smile:

It just does a recursive find from the current directory, feeds all files found with the extension matching $infileext and outputs the values of the EXIF tags inside the do loop. Redirect that to a file then import into a spreadsheet and Bob’s yer uncle.

Per the usage prompt it uses exiv2 so that needs to be on your $PATH. If you’re not shooting Canon (*.CR2 / *.CR3) you’ll need to edit the value of $infileext to match your raw file extension(s). Also, you can edit / add / delete the tags in the do loop to match what you want to retrieve.

I guess if you get it really tweaked to your satisfaction, make a cron job and run it nightly against a directory above all your images, so you’ll always have a current database. It’s trivial to create a data / time based file name so you’ll have unique versions.

Disclaimer - I’m no expert at exiv2 nor metadata in general. I just poked around long enough to get what I needed.

Usage

$ cd /photos
$ /scriptdir/mkimgcsv.sh > images.csv

Here’s how a sample run looks in LibreOffice Calc:

Script

#!/usr/bin/bash

# It emits CSV with basic image info for each raw file found in the folder and below.
#
# View the tags available with `exiv2 -pt IMAGE.CR3`

scriptname=$(basename $0)
infileext="CR(2|3)"
indir="."
noheadopt="--noheader"
fieldstartchar=61
header="\"Filename\",\"Filepath\",\"Timestamp\",\"Lens\",\"Focal length\",\"Aperture\",\"ISO\",\"Shutter speed\",\"AEC\",\"Mode\""

if [ "$1" == "--help" ]
then
    echo ""
    echo "Invokes exiv2 against all *.${infileext} files in the current directory and below,"
    echo "printing CSV output of EXIF info to stdout. '$noheadopt' (optional) suppresses"
    echo "the header line. exiv2 must be installed and on the path. You must have r-x"
    echo "access to the specified directory and r-- to the files in it."
    echo ""
    echo "usage: $scriptname [ --noheader | --help ]"
    echo ""
    
    exit
fi

if [ "$1" != "$noheadopt" ]
then
    echo "$header"
fi

find "$indir" | egrep "${infileext}$" | while read infile 
do
    rawfname=$(echo "$infile" | awk -F/ '{print $NF}')

    # EXIF tags 
    tstamp=$(exiv2 -q -K Exif.Image.DateTime $infile | cut -c ${fieldstartchar}-)
    lens=$(exiv2 -q -K Exif.CanonCs.LensType $infile | cut -c ${fieldstartchar}- | tr -d '/')
    flen=$(exiv2 -q -K Exif.Photo.FocalLength $infile | cut -c ${fieldstartchar}-)
    fnum=$(exiv2 -q -K Exif.Photo.FNumber $infile | cut -c ${fieldstartchar}-)
    ISO=$(exiv2 -q -K Exif.Photo.ISOSpeedRatings $infile | cut -c ${fieldstartchar}-)
    exptime=$(exiv2 -q -K Exif.Photo.ExposureTime $infile | cut -c ${fieldstartchar}-)
    expbias=$(exiv2 -q -K Exif.Photo.ExposureBiasValue $infile | cut -c ${fieldstartchar}-)
    expprog=$(exiv2 -q -K Exif.Photo.ExposureProgram $infile | cut -c ${fieldstartchar}-)
     
    outstr="\"${rawfname}\",\"${infile}\",\"${tstamp}\",\"${lens}\",\"${flen}\",\"${fnum}\",${ISO},\"${exptime}\",\"${expbias}\",\"${expprog}\""
     
    echo "$outstr"
done
1 Like