Write Thumbnail Files Named With Image File's Name

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Write Thumbnail Files Named With Image File's Name

papertape
Dmitri Popov's script extracts thumbnail images from the thumbnails database, and writes files named thumbnail-NN.pgf.  The NN is the "id" from the thumbnails database.

I wish to write thumbnail image files named with the associated full image file's name, instead of with the "id" in the thumbnails database, i.e. Picture.tif.pgf, instead of thumbnail-NN.pgf.

There are two databases of interest: the thumbnails database at thumbnails-digikam.db, and the image info database at digikam4.db.

The key line in my Windows version of the script is
sqlite3 %databasepath% "SELECT writefile('%outputfolder%\\thumbnail-' || id || '.pgf', data) from Thumbnails;"

That "id" is a column in the thumbnails database (%databasepath%), table "Thumbnails".

In the digikam4.db database, table "Images" has columns named "id" and "name".
For a given "id", this command gets the image's file name:
sqlite3 digikam4.db "SELECT writefile('out.txt', name) FROM Images WHERE id=<NN>;"

Can someone help me figure out how to combine the sqlite3 commands to get the "id" from the thumbnails database, and then use it to get the image file name from digikam4.db, so that I can write thumbnail files named with the image's filename?

(Dmitri Popov's script is at https://github.com/cgilles/digikam-pgf-database/blob/master/export_thumbnails.sh)