The GNOME desktop caches thumbnails of images in a directory hierarchy in $HOME/.thumbnails. However, if the original image is deleted, the thumbnail remains in the cache directory. This can lead to a massive waste of a lot of disk space:
$ du -sm ~/.thumbnails 506 ~/.thumbnails even more if you frequently use CDROMs with images on them or create, delete and move around images a lot.
Existing solutions found on the web are based on a rather dumb "find -mtime +n" run that deletes all thumbnails older than n days and even the GNOME solution is based on age and cache size, configurable with gconf-editor:
While this saves disk space it is annoying, as thumbnails of existing images are deleted in favor of younger thumbnails of no longer existing images. This is especially annoying if you have a large archive of images (from a digital camera) and browse directories you haven't viewed quite some time, as all the thumbnails have been deleted and are now recreated.
However, the thumbnails contain the original location of the image they were created from in the comment block. So my script cleanthumbs.py retrieves the location of the original image from all thumbnails and checks for their existance. If the original image is not found, the thumbnail is deleted.
Setting the value of /desktop/gnome/thumbnail_cache/maximum_age to -1 in gconf-editor disables deleting thumbnails by age and if you have quite some disk space and want fast image browsing, also set /desktop/gnome/thumbnail_cache/maximum_size to -1 and run cleanthumbs.py from time to time.