Retrieving metadata

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Retrieving metadata

samR
Hello

is there a way to look for files with a specific value of a field in the metadata? For example, I want to search all the photos in my 'Images' folder that were taken with a given lens. 
The "advance search" in digikam does not seem to allow me to do so...
If not possible in digikam, do you know a tool (under linux) that would allow me to do so? I installed the "exif" program, but it doesn't see this "LensModel" field in the metadata
(note that the field "LensModel" does appear in the metadata in digikam, when I clik on the tab "Notes du fabricant", but not in the "EXIF" tab)

Thank you

Samuel

_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving metadata

Philip Johnsson
Hi

If you want to check it from the command line you can use either exiv2
or exiftool command to list for example lens model. If you don't have
the tools installed then just install them. They comes as packages
with most distros.

With exiv2 try like in this example:

exiv2 -pt PJP_3322.NEF | grep -i lensid

With exiftool try like in this example:

exiftool PJP_3322.NEF | grep -i "lens id"

Hope that helps.

/Philip



On Mon, Oct 24, 2011 at 4:12 PM, Samuel Ronayette <[hidden email]> wrote:

> Hello
>
> is there a way to look for files with a specific value of a field in the
> metadata? For example, I want to search all the photos in my 'Images' folder
> that were taken with a given lens.
> The "advance search" in digikam does not seem to allow me to do so...
> If not possible in digikam, do you know a tool (under linux) that would
> allow me to do so? I installed the "exif" program, but it doesn't see this
> "LensModel" field in the metadata
> (note that the field "LensModel" does appear in the metadata in digikam,
> when I clik on the tab "Notes du fabricant", but not in the "EXIF" tab)
> Thank you
> Samuel
> _______________________________________________
> Digikam-users mailing list
> [hidden email]
> https://mail.kde.org/mailman/listinfo/digikam-users
>
>
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving metadata

Martin Burnicki
In reply to this post by samR
Samuel Ronayette wrote:

> Hello
>
> is there a way to look for files with a specific value of a field in the
> metadata? For example, I want to search all the photos in my 'Images'
> folder that were taken with a given lens.
> The "advance search" in digikam does not seem to allow me to do so...
> If not possible in digikam, do you know a tool (under linux) that would
> allow me to do so? I installed the "exif" program, but it doesn't see this
> "LensModel" field in the metadata
> (note that the field "LensModel" does appear in the metadata in digikam,
> when I clik on the tab "Notes du fabricant", but not in the "EXIF" tab)

The exiftool program can be used to list all metatags from one or more images.

When I started to use this program I stumbled across the fact that the program
distinguishes between "human readable" tag names and "real" tag names. This
may lead to confusion if you want to list all tags first, and then change one
of the listed tags, e.g.:

exiftool img_0235.jpg prints (among others):
..
Lens Model                      : EF-S55-250mm f/4-5.6 IS
..

Please note the tag name listed above contains spaces. As far as I know there
is no way to specify a tag name with space(s), if you only want to display a
specific tag, i.e. what we'll need later.

However, if you call exiftool with parameter -s then it prints the "real tag
names", e.g.:

exiftool -s img_0235.jpg
..
LensModel                       : EF-S55-250mm f/4-5.6 IS
..

So you can use the command

exiftool -LensModel

to print the LensModel tag of every image in the current directory. However,
as far as I know, there is no way to let exiftool print only the names of
every image where a specific tag has a given value.

A one-line script can help to do this. e.g.:

for f in 2011-10-24\ My\ Latest\ Photos/*.jpg ; do exiftool -LensModel "$f"|\
grep -q "EF-S55-250mm" && echo "$f"; done

The script above loops across all .jpg files a given folder, in this
case "2011-10-24 My Latest Photos" (please note the spaces in the directory
name have been escaped in the command, i.e. '\ ').

Then "exiftool -LensModel" is used to print the LensModel tag of an image. The
output is piped to the grep command which checks if the lens model tag
matches "EF-S55-250mm" (in my case), and if it matches it prints the name of
the file. In my case the output looks like:

2011-10-24 My Latest Photos/img_0235.jpg
2011-10-24 My Latest Photos/img_0241.jpg
2011-10-24 My Latest Photos/img_0239.jpg


A limitation of the command above arises if you want to check many files which
are if different nested directories. In this case you can use a 2 step way to
find all files which have the tag with the given value. First create a list
of all image files in the specified directory and all directories below:

find "2011-10-24 My Latest Photos" -iname "*.jpg" > files.txt

Then read the file with the image names line by line and check if the named
image has the tag you are looking for:

while IFS= read -r f; do exiftool -LensModel "$f"|grep -q "EF-S55-250mm" && \
echo "$f"; done < files.txt

In my case the output is:

2011-10-24 My Latest Photos/tmp/img_0241.jpg
2011-10-24 My Latest Photos/tmp/img_0240.jpg
2011-10-24 My Latest Photos/img_0235.jpg
2011-10-24 My Latest Photos/img_0239.jpg
2011-10-24 My Latest Photos/img_0236.jpg

i.e. the latter method als finds images in a different folder and lists the
file and folder name.

If you have to search a large number of image files then these commands may
take some time to execute since the exiftool program is launched for each
images. But anyway, it does what you wants.

Regards,
Martin
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving metadata

Remco Viëtor
In reply to this post by samR
On Monday 24 October 2011 16:12:58 Samuel Ronayette wrote:

> Hello
>
> is there a way to look for files with a specific value of a field in the
> metadata? For example, I want to search all the photos in my 'Images' folder
> that were taken with a given lens.
> The "advance search" in digikam does not seem to allow me to do so...
> If not possible in digikam, do you know a tool (under linux) that would
> allow me to do so? I installed the "exif" program, but it doesn't see this
> "LensModel" field in the metadata
> (note that the field "LensModel" does appear in the metadata in digikam,
> when I clik on the tab "Notes du fabricant", but not in the "EXIF" tab)
>
> Thank you
>
> Samuel

Hmm, if it is in the 'makernotes' ('Notes du fabricant') section, I'm not sure
exiftool can decode the makernotes section, as that section is often very
incompletely (or not) specified by the camera maker (makernotes for Sony only
got added quite recently to Digikam)

On the other hand, if I look in my raw files with exif tool, I get 2 'lens'
tags: 'Lens Type' and 'Lens ID' (using 'exiftool -a -u <file> |grep "Lens" ')
but no 'LensModel' tag. I don't get a 'LensModel' field in digikam either.

Lens type seems to be based on a byte value, and can give me several lens
descriptions (i.e. several lenses use the same ID), Lens ID is in a
'Composite' section of the exiftool output, and can give the exact lens used
(in the file I used here, I used a fixed focus lens, so combining Lens Type
and focal length left only one possible lens).

Hope this helps a bit

Remco
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving metadata

Johnny
Remco Viëtor <[hidden email]> writes:

> On Monday 24 October 2011 16:12:58 Samuel Ronayette wrote:
>>
>> If not possible in digikam, do you know a tool (under linux) that would
>> allow me to do so?
>>
>> (note that the field "LensModel" does appear in the metadata in digikam,

If it is in the metadata in Digikam, I assume it should also be
available in your digikam database. If so, anything (more or less) would
be possible by creating a SQL query. I have used sqliteman [1] when browsing
the digikam database with success to retrieve some custom data. You
would have to find the field "LensModel" by browsing the db tables and
then establish a SQL query based on SELECT, FROM and WHERE (my sql
skills doesn't allow a more accurate description without mucking around
with it, sorry).

Regards


Footnotes:
[1]  http://sqliteman.com/

--
Johnny
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users