16

For some unknown reason all thumbnails are lost in my Shotwell, instead all icons are grey. The images themselves are all okay and I can open them all in Shotwell.

There are only empty folders in .shotwell/thumbs/ so it looks like the thumbnails don't doesn't get generated at all.

I have also tried to re-install Shotwell (by purge it first) without any change.

How do I make Shotwell regenerate all the thumbnails?

7 Answers 7

15

This shell script will regenerate your thumbnails of sizes 128px and 360px so you'll see at least something in viewer.

sqlite3 ~/.local/share/shotwell/data/photo.db \
  "select id||' '||filename from PhotoTable order by timestamp desc" | 
  while read id filename; do
    for size in 128 360; do
      tf=$(printf ~/.cache/shotwell/thumbs/thumbs${size}/thumb%016x.jpg $id);
      test -e "$tf" ||  {
        echo -n "Generating thumb for $filename ($tf)";
        convert "$filename" -auto-orient -thumbnail ${size}x${size} $tf
        echo
      }
    done
  done
5
  • If your pics have exif thumbnails then you may replace convert line with this: tf_src="$(exiv2 -vf -et "$filename" | grep -o "to file .*" | cut -f3- -d" ")" && mv "$tf_src" $tf
    – lkp
    Mar 24, 2011 at 17:33
  • The problem with this solution is that any transformations the user has made to the photos -- rotation, crop, color correction -- won't be reflected in the thumbnails. Shotwell stores all thumbnails fully transformed.
    – Jim Nelson
    Aug 1, 2011 at 22:14
  • This script assumes you're at the top of your home directory, but otherwise works like a charm. Thanks!
    – Reece
    Nov 14, 2011 at 3:57
  • bitbucket.org/reece/reece-base/src/tip/bin/… builds also creates the 360x360 thumbs.
    – Reece
    Nov 14, 2011 at 3:58
  • 1
    Nowadays, you can also just delete ~/.cache/shotwell/thumbs, and Shotwell 0.22.x will regenerate them as needed.
    – Lambart
    Jan 26, 2019 at 5:09
7

An easy way for Shotwell to regenerate thumbnails (this is a workaround):

  1. Go to your Photos page.
  2. Edit -> Select All
  3. Ctrl+R (rotate)
  4. When finished rotating, Ctrl+Z (undo).

This will force Shotwell to regenerate all photos and honor any transformations it has stored for them.

As phq mentioned, there is an outstanding bug to fix this so you won't need this workaround. Until then, this is the recommended way to solve this problem. The script posted above will not honor transformations, meaning it's possible for your thumbnails to not look like your photos in Shotwell.

1
  • Just a side note as it's still the same in Shotwell 0.13.1 - horizontal flip seems to be a little faster transformation (tested on 1500 8mpix photos).
    – cprn
    Jan 30, 2013 at 22:55
5

I just used the shell script given in this answer, but I have about 22000 thumbnails to generate.

So here is a bash version of this script, using ~/.shotwell instead of ~/.local/shotwell (which is what I have) and using as many cores as my processor have (8 times faster in my case!):

#!/bin/bash

# under linux, use this to launch as many convert as your processor core number
#MAX_PROCESSES=`cat /proc/cpuinfo |grep ^processor | wc -l`
# or use a static value
MAX_PROCESSES=4

sqlite3 ~/.shotwell/data/photo.db "select id||' '||filename from PhotoTable order by timestamp desc" | 
  while read id filename; do
      for size in 128 360; do
      tf=$(printf ~/.shotwell/thumbs/thumbs${size}/thumb%016x.jpg $id);
      test -e "$tf" ||  {
              echo "Generating thumb for $filename ($tf)";
              convert "$filename" -auto-orient -thumbnail ${size}x${size} $tf &
          RUNNING="`jobs -p |wc -l`"
          while [ "$RUNNING" -ge "$MAX_PROCESSES" ]
          do
          sleep 0.3
          RUNNING="`jobs -p |wc -l`"
          done
      }
      done
  done
5

Update With shotwell 0.18 thumbnails are now generated when manually viewed.

Don't remove .shotwell/thumbs!

According to this bug in launchpad, thumbnails are only generated on import.

Thumbnails are only generated at import. If the thumbnails are removed from disk they are not regenerated.

1
  • 1
    With Shotwell 0.22 (i.e., Ubuntu 16.04) you can just delete ~/.cache/shotwell/thumbs, and Shotwell will regenerate them as needed.
    – Lambart
    Jan 26, 2019 at 5:11
3

Shotwell version 0.13.11 on Ubuntu 12.10 Thumbnails seem no longuer to be located in .shotwell/thumbs but now in .cache/shotwell You may check user has full rigths to read thumbs. Having access to pictures but not to thumbs may cause grey thumbs.

3
  • You have not addressed the question about regenerating thumbs.
    – hultqvist
    Apr 16, 2013 at 8:43
  • 1
    @phq if you would've read the question, you'd see that the question is not necessarily to actually regenerate the thubs, but how to get the thumbs back for which the OP hypothetize the thumbs are missing, and thus propose the regeneration as a fix. In case that the thumbs are actually there, but in a different folder or with the wrong permission, this answer is actually spot on. On top of that, even if you'd only accept answers that foolishly deal only with the subject of the question, please keep in mind that this answer is still useful as a comment (that phq wouldn't have been able to..
    – berdario
    Sep 12, 2014 at 10:05
  • ...post as a true comment, due to his low reputations score)
    – berdario
    Sep 12, 2014 at 10:05
2

For version 0.26.3 (up-to-date as of Nov. 2017), with Shotwell closed, just delete the thumbnails in

  • /home/user_name/.cache/shotwell/thumbs/thumbs128 and in
  • /home/user_name/.cache/shotwell/thumbs/thumbs360

and fire up Shotwell, again.

2

Shotwell 0.28.4 (Braunschweig) will sometimes not create video thumbnails. The following script derived from the accepted answer fixes this:

#!/bin/bash
declare -A default_thumbnail_sizes
declare -A default_thumbnail_checksums
default_thumbnail_sizes[128]="3038"
default_thumbnail_checksums[128]="dc292dd5c9eacadee4fa02c2062d364d8a3a42cb4a58b99abb42dd1950803e4d"
default_thumbnail_sizes[360]="12333"
default_thumbnail_checksums[360]="1f5859761cbbc44f7444b5a61ffd7b2dfe560017d8376905df67db51a4641926"

sqlite3 ~/.local/share/shotwell/data/photo.db \
  "select id||' '||filename from VideoTable" |
  while read id filename
  do
    for size in 128 360
    do
      tf=$(printf ~/.cache/shotwell/thumbs/thumbs${size}/video-%016x.jpg $id);
      exit_code="$?"
      if [[ "$exit_code" != "0" ]]
      then
        echo $id
        continue
      fi

      if [[ -e "$tf" ]]
      then
        tfilelength=$(stat -c '%s' $tf)
        if [[ "$tfilelength" != ${default_thumbnail_sizes[$size]} ]]
        then
          continue
        fi

        tchecksum=$(sha256sum $tf)
        if [[ "$tchecksum" != ${default_thumbnail_checksums[$size]}* ]]
        then
          continue
        fi
      fi

      echo -n "$filename --> $tf";
      ttf=/tmp/$(basename "$tf")
      rm -f "$ttf"
      ffmpeg -i "$filename" -loglevel quiet -vf "thumbnail,scale=${size}:-1" -frames:v 1 "$ttf"
      exit_code="$?"
      if [[ -e "$ttf" && $exit_code == "0" ]]
      then
        echo ": SUCCESS"
        mv -f -v "$ttf" "$tf"
        echo
      else
        echo ": FAILED ($exit_code)"
        echo
      fi
    done
  done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .