Regenerating Shotwell thumbnails

When reinstalling, upgrading or moving settings, thumbnails may be missing in Shotwell. The problem can look like this:

shotwell_missing_thumbs

Each time you import photos, Shotwell will generate thumbnails in two different sizes. If you loose them, you have the problem that they are regenerated on-demand, everytime you scroll by an image. That stinks.

Requirements

You need to do apt-get install sqlite3 imagemagick to fetch requirements.

Source

Here's a script that will regenerate everything, and it's tested on Shotwell 0.18.0. View / fork Gist souce.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash  
# Based on http://gagor.pl/2014/01/regenerate-thumbnails-in-shotwell-for-last-month/  
THUMB_ROOT=~/.cache/shotwell/thumbs  
# Remove " > date('now','start of month','-1 month')" if you want to re-generate everything  
sqlite3 ~/.local/share/shotwell/data/photo.db \  
  "select id||' '||filename from PhotoTable where date(timestamp,'unixepoch','localtime') > date('now','start of month','-1 month') order by timestamp desc" |  
while read id filename; do  
  tf1=$(printf $THUMB_ROOT/thumbs128/thumb%016x.jpg $id);  
  tf2=$(printf $THUMB_ROOT/thumbs360/thumb%016x.jpg $id);  
  if [ -e "$tf1" ]  
  then  
    echo "Skipping $filename"  
  else  
    echo -n "Generating thumb for $filename";  
    #echo $tf1  
    convert "$filename" -quality 60 -auto-orient -thumbnail 128x128 $tf1  
    convert "$filename" -quality 60 -auto-orient -thumbnail 360x360 $tf2  
    echo  
  fi  
done