Bug 388936

Summary: User Selectable Thumbnail Format
Product: [Applications] digikam Reporter: aerysl
Component: Database-ThumbsAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: aerysl, caulier.gilles
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: All   
Latest Commit: Version Fixed/Implemented In: 7.0.0
Sentry Crash Report:

Description aerysl 2018-01-14 00:36:48 UTC
Currently behind the scenes Digikam supports a number of different filetypes(https://cgit.kde.org/digikam.git/tree/libs/database/thumbsdb/thumbsdb.h?id=adbe3e2c132c4ffbf17bdffc2e14aaa91868ca18) for the thumbnails to be stored within the database. However, while the pipeline has the required code for all the types, the hardcoded default is PGF (https://cgit.kde.org/digikam.git/tree/libs/threadimageio/thumbnailcreator.cpp?id=adbe3e2c132c4ffbf17bdffc2e14aaa91868ca18 - line 737). I propose that the thumbnail type be user selecteble. I imagine this could be done in one of many ways, three of which I describe:

1. As an setting in the digikamrc config file. This would likely require less work, but to maintain a consistent thumbnail type would require all Digikam clients accessing the same database to have the same setting in the config.

2. Add the type as a setting in the Setting table of the database. This would allow all clients accessing the database to use the same type, allowing a homogenous thumbnail database of user configurable type.

3. A much less elegant solution would be to add a compile-time option to set the dbInfo.type variable.

I'm not terribly familiar with the coding of Digikam, but if a Contributer thinks option 1 is the way to go I should be able to make a patch to submit.
Comment 1 caulier.gilles 2018-01-14 01:58:25 UTC
Can you give me a very good reason to provide a way to change the database image format in thumbnail database ?

- PGF is used because it use wavelets compression to optimize space, quality, speed.
- the other format support provided in digiKam core for thumbs database is present for testing only. It's a legacy of test done many years ago when we choose the right one.
- there is currently no mechanism to detect the thumb format stored in DB. including this king of control will slow down the thumb extraction, and we won't to complex this task.

For me PGF is prefect and there is no reason to changes it. The only possible way to change the format id to use a new compression which provide a better optimisation than PGF. Perhaps HEIF, WepP, or JPEGXR, but none provide an easy to use through a small library under Linux as PGF. There are also patents problem in background...

Gilles Caulier
Comment 2 aerysl 2018-01-14 02:32:46 UTC
(In reply to caulier.gilles from comment #1)
> Can you give me a very good reason to provide a way to change the database
> image format in thumbnail database ?
> 
> - PGF is used because it use wavelets compression to optimize space,
> quality, speed.
> - the other format support provided in digiKam core for thumbs database is
> present for testing only. It's a legacy of test done many years ago when we
> choose the right one.
> - there is currently no mechanism to detect the thumb format stored in DB.
> including this king of control will slow down the thumb extraction, and we
> won't to complex this task.
> 
> For me PGF is prefect and there is no reason to changes it. The only
> possible way to change the format id to use a new compression which provide
> a better optimisation than PGF. Perhaps HEIF, WepP, or JPEGXR, but none
> provide an easy to use through a small library under Linux as PGF. There are
> also patents problem in background...
> 
> Gilles Caulier

One use case that I can think of (and am currently working on, as a personal project), is that the I'd like to be able to use my Digikam database on other platforms (say my Android phone, or via HTTP), so I have been working on a PHP frontend of sorts. As such I have done local builds with JPEG thumbnails (simply changing the previously mentioned line, and regenerating all my thumbnails), so I can directly serve the thumbnails in the database extremely quickly. I imagine others may find this useful, but it is a pretty niche case.

I definitely agree with PGF being a great format for use within Digikam, but unfortunately I could not find many other libraries to interface with them.

I'm using the MySQL (MariaDB) backend, but it appears to me the "type" field in the "Thumbnails" table corresponds with the type - and have had success using JPEG based thumbnails. However, I am completely ignorant of how performant this is, and any other considerations involved, and my observations may be completely incorrect.

Thanks
Comment 3 caulier.gilles 2018-01-14 02:42:26 UTC
>One use case that I can think of (and am currently working on, as a personal project), >is that the I'd like to be able to use my Digikam database on other platforms (say my >Android phone, or via HTTP), so I have been working on a PHP frontend of sorts. 

I recommend to take a look to the new database sharing feature introduced with 5.8.0 based on DLNA/UPNP. you have plenty of application under Android that permit to read digiKam database without to reinvent the wheel. DLNA and UPNP are standardized and sound adapted for your use.

Gilles Caulier
Comment 4 caulier.gilles 2020-06-09 11:56:17 UTC
In response to comment 2 : on my github account, i created a PGF to PNG converter not depending of digiKam libraries. It's a stand alone CLI tool that you can use with database thumbnail blobs recorded in PGF format.

https://github.com/cgilles/digikam-pgf-database

Gilles Caulier
Comment 5 caulier.gilles 2020-06-09 13:56:01 UTC
As you have now the capabilty to easily convert database thumbnails blobs from PGF to PNG on the command line, i close this file as we will not change the database structures / implementations to be able to change thumbnail storing.

PGF compress well, is used since a while, and perfect for digiKam internal use.

Gilles Caulier