Nautilus: batch thumbnail generation for remote location

I have a fairly large photo collection on a raspberry pi based NAS. Unfortunately RPI ethernet port is not fast enough (100MB/s) for comfortable remote operation, so to be able to use that collection I have to keep local thumbnail directory on my linux box. Gnome nautilus is my tool of choice, but nautilus generates thumbnails only after entering a directory. To make that setup workable I had to:

1. Make sure gnome allows big thumbnails and doesn't expire them: dconf-editor, go to org->gnome->desktop->thumbnail-cache and set maximum-age and maximum-size to -1

2. Generate the thumbnails

Nautilus thumbnails are saved in png files with name like this: 00067ecff5de0e48602327bc987f6d9a.png. The name is md5sum of image path with spaces replaced by %20.  The path is not an absolute path in the system! So for example I have a photo at /run/user/1000/gvfs/sftp:host=192.168.1.231,user=pi/mnt/PhotoArchive/Dump/a_photo.jpg, but the path nautilus uses to generate thumbnail name is sftp://pi@192.168.1.231/mnt/PhotoArchive/Dump/a_photo.jpg (it can be checked in nautilus - just right click on an image and check location). Local files have prefix file://

I had some problems with getting reliable results for a find command run on a remote system, so I decided to create 2 scripts to generate the thumbnails. The first script scans (scan.sh) remote location for images, generates md5sum for the image path and, if there is no thumbnail stored locally, writes the file path to a pipe. Another script (thumbnail.sh) waits for whatever shows up in the pipe and generates the thumbnail. An example usage:

./scan.sh /run/user/1000/gvfs/sftp:host=192.168.1.231,user=pi mnt/ sftp://pi@192.168.1.231

and in a separate terminal:

./thumbnail.sh /run/user/1000/gvfs/sftp\:host\=192.168.1.231\,user\=pi/ sftp://pi@192.168.1.231

Legend:

/run/user/1000/gvfs/sftp\:host\=192.168.1.231\,user\=pi/ <-- I have my NAS mounted at that point ($ROOT_DIRECTORY)

mnt/ <--the scripts scan should scan that directory and all subdirectories ($IMAGE_DIRECTORY)

sftp://pi@192.168.1.231 <-- path prefix used by nautilius for that location to generate md5sum ($PREFIX)

I used those 2 script to generate over 65.000 (6 GB) of thumbnails. The directory where thumbnails are saved is hardcoded in thumbnail.sh (THUMBNAIL_DIR=/home/przemo/.cache/thumbnails/large/) - please update before using the script!

They posted on the same topic

Trackback URL : http://blog.firszt.eu/index.php?trackback/37

This post's comments feed