Using a bash script to fetch statistics out of your darktable library

I’m using darktable as my main digital workflow software in order to develop digital camera (DSLR) raw images.

Darktable itself maintains a sqlite based library for all images consisting

  • camera maker + model
  • width+height
  • lens used
  • aperture
  • exposure
  • datetime the image was taken
  • the cameras iso setting
  • focal length

I was interested to see what my most images focal length was so i wrote a simple bash script to query darktables library and summarize/group by given key-indicators.

I present dt-stat.sh v1.0.

This is free software. Its under GPLv2.

If you use this script, feel free to drop me a line: christian@christianroessler.net

Usage

Make the downloaded script executable

$ chmod +x dt-stat.sh

Make sure you have sqlite3 executable installed

$ which sqlite3
/usr/bin/sqlite3

$ sqlite3 --version
3.8.1 2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a

Make sure your darktable library is located in the hardcoded folder

$ ls -lah ~/.config/darktable/*.db
-rw-r--r-- 1 croessler croessler 6.2M Mar  7 22:32 /home/croessler/.config/darktable/library.db

Overview

Simply execute the script to see a short help/overview of possible commands/parameters

$ ./dt-stat.sh

You will be preented with a help-screen as there are parameters missing:

Usage: ./dt-stat.sh [-h|--help] [OPTION]
List the number of Images in the darktable library.
The darktable library is assumed to be located in ~/.config/darktable/library.db

-h|--help         show help

Possible [OPTION]s
  model           filter by the Camera Model
  lens            filter by lenses used
  exposure        filter by the exposure
  aperture        filter by aperture
  iso             filter by ISO used
  focal_length    filter by lens focal length

dt-stat.sh is written by Christian Rößler
http://www.christianroessler.net    christian@christianroessler.net

dt-stat.sh 1.0

Invalid number of parameters

You may apply a single OPTION at a time. The following is a sample output directly from my darktable (1.4.1) library consisting of over 11.000 images.

Count by Camera Maker+Model

$ ./dt-stat.sh model
MODEL                                                                   COUNT     
----------------------------------------------------------------------  ----------
                                                                        533       
Nokia 6300                                                              29        
Samsung Techwin <Samsung NV3, Samsung VLUU NV3>                         64        
OLYMPUS CORPORATION C5060WZ                                             811       
Canon Canon DIGITAL IXUS 700                                            132       
Canon Canon EOS 400D DIGITAL                                            200       
Canon Canon EOS 5D Mark II                                              1006      
Canon Canon EOS-1Ds Mark II                                             1         
Canon Canon EOS-1Ds Mark III                                            13        
SONY DSC-P120                                                           115       
SONY DSC-P52                                                            1         
SONY DSC-V1                                                             1         
Unknown DigitalCam Pro                                                  64        
CASIO COMPUTER CO.,LTD. EX-Z150                                         357       
CASIO COMPUTER CO.,LTD EX-Z50                                           109       
FUJIFILM FinePix F31fd                                                  6         
FUJIFILM FinePixS1Pro                                                   1396      
HP HP psc1310                                                           1         
KONICA KD-300Z                                                          17        
NIKON CORPORATION NIKON D300S                                           6896      
NIKON CORPORATION NIKON D80                                             60        
Apple iPhone 4                                                          1       

Count by lens

$ ./dt-stat.sh lens
LENS                                                                    COUNT     
----------------------------------------------------------------------  ----------
                                                                        4648      
(0)                                                                     12        
(65535)                                                                 132       
181                                                                     5         
Canon EF 24-105mm f/4L IS                                               909       
Canon EF 28-80mm f/3.5-5.6                                              108       
Canon EF 50mm f/1.8 MkII                                                7         
Canon EF-S 18-55mm f/3.5-5.6                                            87        
Manual Lens No CPU                                                      33        
Nikon AF Nikkor 180mm f/2.8 IF-ED                                       4         
Nikon AF Nikkor 50mm f/1.8D                                             48        
Nikon AF Zoom-Nikkor 28-100mm f/3.5-5.6G                                20        
Nikon AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED                     3596      
Nikon AF-S DX Zoom-Nikkor 18-70mm f/3.5-4.5G IF-ED                      14        
Nikon AF-S Nikkor 28mm f/1.8G                                           163       
Nikon AF-S Nikkor 50mm f/1.8G                                           343       
Sigma 20mm F1.8 EX DG Aspherical RF                                     14        
Sigma 70-200mm F2.8 EX APO DG Macro HSM II                              1626      
Tamron AF 70-300mm F/4-5.6 Di LD Macro 1:2                              20        
Tokina AT-X 840 AF-II (80-400mm f/4.5-5.6)                              24    

Count by exposure

$ ./dt-stat.sh exposure
EXPOSURE                                                                COUNT     
----------------------------------------------------------------------  ----------
                                                                        567       
1/-2                                                                    1         
1/-1                                                                    3         
1/0                                                                     172       
1/1                                                                     112       
1/2                                                                     113       
1/3                                                                     179       
1/4                                                                     228       
1/5                                                                     265       
1/6                                                                     370       
1/7                                                                     217       
1/8                                                                     586       
1/9                                                                     168       
1/10                                                                    141       
1/12                                                                    42        
1/13                                                                    140       
1/15                                                                    138       
1/17                                                                    1         
1/20                                                                    143       
1/24                                                                    5         
1/25                                                                    133       
1/30                                                                    172       
1/40                                                                    153       
1/45                                                                    54        
1/50                                                                    172       
1/60                                                                    1258      
1/80                                                                    352       
1/85                                                                    1         
1/90                                                                    3         
1/100                                                                   414       
1/120                                                                   1         
1/125                                                                   427       
1/160                                                                   710       
1/170                                                                   1         
1/200                                                                   643       
1/250                                                                   743       
1/320                                                                   752       
1/400                                                                   646       
1/500                                                                   473       
1/640                                                                   282       
1/800                                                                   162       
1/1000                                                                  136       
1/1250                                                                  116       
1/1600                                                                  92        
1/2000                                                                  100       
1/2500                                                                  91        
1/3200                                                                  59        
1/4000                                                                  37        
1/5000                                                                  17        
1/6400                                                                  9         
1/8000                                                                  13       

Count by aperture

$ ./dt-stat.sh aperture
APERTURE                                                                COUNT     
----------------------------------------------------------------------  ----------
f/0.0                                                                   600       
f/1.2                                                                   1         
f/1.4                                                                   2         
f/1.6                                                                   1         
f/1.8                                                                   318       
f/2.0                                                                   10        
f/2.2                                                                   3         
f/2.5                                                                   3         
f/2.6                                                                   128       
f/2.8                                                                   553       
f/3.0                                                                   17        
f/3.1                                                                   13        
f/3.2                                                                   201       
f/3.4                                                                   20        
f/3.5                                                                   424       
f/3.6                                                                   228       
f/3.7                                                                   73        
f/3.8                                                                   98        
f/3.9                                                                   32        
f/4.0                                                                   1021      
f/4.1                                                                   29        
f/4.2                                                                   146       
f/4.3                                                                   22        
f/4.4                                                                   14        
f/4.5                                                                   936       
f/4.6                                                                   15        
f/4.7                                                                   19        
f/4.8                                                                   392       
f/4.9                                                                   32        
f/5.0                                                                   571       
f/5.2                                                                   28        
f/5.3                                                                   302       
f/5.4                                                                   7         
f/5.5                                                                   17        
f/5.6                                                                   983       
f/5.8                                                                   16        
f/5.9                                                                   85        
f/6.0                                                                   22        
f/6.2                                                                   23        
f/6.3                                                                   374       
f/6.4                                                                   1         
f/6.5                                                                   20        
f/6.7                                                                   21        
f/6.9                                                                   9         
f/7.1                                                                   510       
f/7.3                                                                   25        
f/7.5                                                                   14        
f/7.7                                                                   22        
f/7.8                                                                   46        
f/8.0                                                                   759       
f/8.2                                                                   27        
f/8.4                                                                   4         
f/8.5                                                                   31        
f/8.7                                                                   37        
f/9.0                                                                   733       
f/9.1                                                                   14        
f/9.2                                                                   31        
f/9.5                                                                   42        
f/9.8                                                                   23        
f/10.0                                                                  595       
f/10.1                                                                  18        
f/10.3                                                                  32        
f/10.6                                                                  37        
f/11.0                                                                  395       
f/11.1                                                                  9         
f/11.3                                                                  31        
f/11.6                                                                  34        
f/11.9                                                                  15        
f/12.3                                                                  17        
f/12.6                                                                  6         
f/12.8                                                                  5         
f/13.0                                                                  243       
f/13.4                                                                  5         
f/13.8                                                                  5         
f/14.0                                                                  105       
f/14.2                                                                  6         
f/14.6                                                                  4         
f/15.0                                                                  4         
f/15.4                                                                  4         
f/16.0                                                                  32        
f/16.5                                                                  1         
f/17.5                                                                  5         
f/18.0                                                                  25        
f/20.0                                                                  11        
f/22.0                                                                  16        
f/25.0                                                                  4         
f/26.9                                                                  1     

Count by ISO

$ ./dt-stat.sh iso
ISO                                                                     COUNT     
----------------------------------------------------------------------  ----------
0                                                                       676       
50                                                                      125       
53                                                                      42        
56                                                                      2         
62                                                                      6         
64                                                                      236       
68                                                                      2         
75                                                                      3         
80                                                                      578       
81                                                                      3         
82                                                                      1         
83                                                                      2         
85                                                                      1         
86                                                                      1         
87                                                                      3         
90                                                                      1         
93                                                                      3         
94                                                                      1         
96                                                                      2         
98                                                                      3         
100                                                                     583       
101                                                                     1         
102                                                                     4         
106                                                                     1         
108                                                                     1         
109                                                                     1         
111                                                                     1         
113                                                                     14        
116                                                                     1         
118                                                                     1         
119                                                                     1         
120                                                                     1         
125                                                                     43        
126                                                                     24        
129                                                                     1         
133                                                                     1         
135                                                                     1         
137                                                                     1         
138                                                                     1         
140                                                                     1         
142                                                                     1         
144                                                                     1         
159                                                                     94        
160                                                                     4         
182                                                                     1         
186                                                                     1         
187                                                                     1         
190                                                                     1         
192                                                                     1         
200                                                                     2200      
201                                                                     1         
211                                                                     1         
214                                                                     1         
218                                                                     1         
238                                                                     1         
240                                                                     2         
250                                                                     540       
276                                                                     1         
278                                                                     1         
280                                                                     1         
320                                                                     1424      
343                                                                     1         
360                                                                     1         
400                                                                     1831      
500                                                                     589       
640                                                                     519       
800                                                                     590       
1000                                                                    321       
1250                                                                    460       
1400                                                                    1         
1600                                                                    271       
2000                                                                    185       
2200                                                                    1         
2500                                                                    141       
3200                                                                    119       
5000                                                                    19        
6400                                                                    111 

Count by focal length

$ ./dt-stat.sh focal_length
FOCAL_LENGTH                                                            COUNT     
----------------------------------------------------------------------  ----------
0mm                                                                     600       
3mm                                                                     1         
4mm                                                                     90        
5mm                                                                     316       
6mm                                                                     91        
7mm                                                                     339       
8mm                                                                     53        
9mm                                                                     88        
10mm                                                                    65        
11mm                                                                    68        
12mm                                                                    43        
13mm                                                                    63        
14mm                                                                    42        
15mm                                                                    28        
16mm                                                                    24        
17mm                                                                    23        
18mm                                                                    1216      
19mm                                                                    2         
20mm                                                                    26        
21mm                                                                    82        
22mm                                                                    290       
23mm                                                                    13        
24mm                                                                    737       
25mm                                                                    73        
26mm                                                                    106       
27mm                                                                    1         
28mm                                                                    833       
30mm                                                                    239       
31mm                                                                    7         
32mm                                                                    142       
33mm                                                                    20        
34mm                                                                    98        
35mm                                                                    161       
37mm                                                                    4         
38mm                                                                    161       
39mm                                                                    1         
40mm                                                                    144       
41mm                                                                    4         
42mm                                                                    110       
43mm                                                                    3         
44mm                                                                    44        
45mm                                                                    126       
46mm                                                                    1         
47mm                                                                    60        
48mm                                                                    136       
50mm                                                                    602       
52mm                                                                    133       
54mm                                                                    40        
55mm                                                                    47        
57mm                                                                    19        
58mm                                                                    132       
60mm                                                                    8         
61mm                                                                    1         
62mm                                                                    155       
63mm                                                                    57        
65mm                                                                    7         
66mm                                                                    188       
67mm                                                                    11        
70mm                                                                    413       
72mm                                                                    29        
73mm                                                                    12        
75mm                                                                    93        
77mm                                                                    23        
78mm                                                                    18        
79mm                                                                    25        
80mm                                                                    86        
82mm                                                                    30        
84mm                                                                    369       
85mm                                                                    64        
86mm                                                                    23        
88mm                                                                    6         
90mm                                                                    55        
92mm                                                                    91        
93mm                                                                    1         
95mm                                                                    3         
96mm                                                                    1         
97mm                                                                    1         
98mm                                                                    45        
100mm                                                                   96        
105mm                                                                   765       
112mm                                                                   42        
118mm                                                                   3         
120mm                                                                   54        
130mm                                                                   47        
133mm                                                                   1         
135mm                                                                   61        
145mm                                                                   47        
154mm                                                                   10        
160mm                                                                   72        
168mm                                                                   4         
170mm                                                                   29        
180mm                                                                   20        
183mm                                                                   2         
185mm                                                                   27        
200mm                                                                   912       
220mm                                                                   3         
224mm                                                                   3         
240mm                                                                   1         
244mm                                                                   3         
270mm                                                                   5         
299mm                                                                   1         
300mm                                                                   13        
400mm                                                                   30