Bug 416941

Summary: AVIF image support
Product: [Frameworks and Libraries] frameworks-kimageformats Reporter: dnovomesky
Component: generalAssignee: Alex Merry <alex.merry>
Status: RESOLVED FIXED    
Severity: wishlist CC: fischer, joh82875, kde, kde, kdelibs-bugs, matt.scheirer, postix
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: All   
URL: https://github.com/novomesk/qt-avif-image-plugin
Latest Commit: Version Fixed In:
Attachments: Source code of the plugin

Description dnovomesky 2020-01-30 10:05:49 UTC
Hello,
I wish that my favorite KDE applications (dolphin, gwenview, etc.) know AVIF format:
https://aomediacodec.github.io/av1-avif/

There is a library with AVIF support:
https://github.com/AOMediaCodec/libavif

libavif needs libaom (for AV1 stream encoding/decoding) or alternatively (dav1d and rav1e).

I observed that kimageformats support various formats and each format has classes derived from QImageIOPlugin, QImageIOHandler. I believe it should be possible to write similar classes for AVIF format too.

I have some experience with libavif, I created plug-in which works with development GIMP 2.99.1 ( I attached it to case https://gitlab.gnome.org/GNOME/gimp/issues/2668 ).

What do you suggest to do?
Shall I develop the code for kimageformats and attach it here?

Regards,
Daniel
Comment 1 Christoph Feck 2020-02-10 22:09:27 UTC
Thanks for considering adding support for this new format.

QImage I/O plugins are mostly self-contained, so it wouldn't really matter if you develop it as a github project, a separate KDE project, a subproject of (KDE's) kimageformats, or a subproject of (Qt's) qtimageformats.

It mostly depends on the license you plan to use. If you aim for inclusion in Qt, you have less freedom to chose the license compared to a github project, for example.
Comment 2 dnovomesky 2020-02-26 12:43:28 UTC
Created attachment 126421 [details]
Source code of the plugin

I am sharing initial version of my plug-in to support AVIF image format.

Dependencies:
https://github.com/AOMediaCodec/libavif
You need to build and install libavif first. Configure libavif to use at least one supported AV1 encoder and decoder (AOM, RAV1E, DAV1D, GAV1).
When AV1 encoders/decoders are upgraded, it is good to rebuild libavif too.

How to build:
qmake
make

qmake will produce Makefile,
make will produce libqavif.so

How to install:
cp libqavif.so /usr/lib/qt5/plugins/imageformats/
cp avif.desktop /usr/share/kservices5/qimageioplugins/

Associate .avif extension (use mimetype image/avif , suggested name "AV1 Image File Format (AVIF)") with gwenview (for example).

How to enable thumbnails in dolphin:
Update -
/usr/share/kservices5/imagethumbnail.desktop
add image/avif; to the list MimeType=...
Comment 3 dnovomesky 2020-03-20 17:51:12 UTC
I made a new version of the plug-in.
The new version supports AVIF image sequences.
It supports colorspaces if you compile it with Qt >= 5.14
Loaded picture is automatically rotated and/or mirrored if necessary.

It is possible to make a version with libavif statically linked with the plug-in, sources + build script included. Sources of dependencies (libaom + libavif) included.
Who wants to make dynamic linking with system installed libavif, can do it too (another build script included). libavif >= 0.6.0 is required in case of dynamic linking.

I wrote in README.txt how to install the plug-in and how to make dolphin to display thumbnails with AVIF pictures.
Comment 4 Christoph Feck 2020-03-20 17:58:59 UTC
Did you yet decide where to publish it? Do you want to maintain your own repository in github, or do you want to contribute to Qt or KDE repositories?
Comment 5 dnovomesky 2020-03-20 20:55:24 UTC
My plug-in is free, it can be used by closed source too.
I wish it to be included in Qt, however it's not me who can decide if/when it will be accepted.
I would consider inclusion in kimageformats (instead of Qt Image Formats) a big success too. It would bring AVIF support to large volume of applications/users and perhaps it would stimulate other software vendors to add support too.
Comment 6 Christoph Feck 2020-04-02 10:27:07 UTC
> I wish it to be included in Qt, however it's not me who can decide if/when it will be accepted.

Did you discuss this with the Qt developers? They won't magically find out that you want to include and maintain it. You can find them at the Qt development mailing list.

https://lists.qt-project.org/listinfo/development
Comment 7 dnovomesky 2020-04-02 11:13:36 UTC
(In reply to Christoph Feck from comment #6)
> Did you discuss this with the Qt developers? They won't magically find out
> that you want to include and maintain it. You can find them at the Qt
> development mailing list.

I wrote at Qt forum that I am willing to contribute the code.
They informed me about https://wiki.qt.io/Qt_Contribution_Guidelines

Those things are new for me, I feel I need to learn a lot. It will take some time to go through everything. Perhaps someone will help.
Comment 8 Thomas Fischer 2020-05-03 19:07:40 UTC
(In reply to dnovomesky from comment #7)
> [..]
> Those things are new for me, I feel I need to learn a lot. It will take some
> time to go through everything. Perhaps someone will help.

I am also interested in the adoption and support of AVIF in Qt and KDE. Maybe as an alternative to the big step of getting your code into Qt directly, you may start with smaller goals such as:

- Decide under which license you software is about to be released. You mentioned that you want to allow closed-source usage, so one of the BSD-licenses is a popular choice here, for example the 3-clause BSD license [1]
Once you have chosen a license, put a text file called LICENSE.txt with the license's text in the source code's root directory and add comments at the beginning of each source file stating under which license it is available and who is the copyright holder (you and any potential future contributor).
- Align your build system, directory structure, and filenames to how they are in other Qt or KDE image plugins. For example, it is rather uncommon to have shell scripts like build_libqavif_dynamic.sh.
- To make your code accessible to other developers and to allow for easier contributions instead of attaching .zip files to a bug report or referring to webservers without TLS or domain name, get an account at some Git repo hoster, such as GitLab (AFAIK KDE is considering adopting the GitLab software, too). [2,3]

Good luck and happy coding!

[1] https://opensource.org/licenses/BSD-3-Clause
[2] https://gitlab.com/users/sign_in#register-pane
[3] https://about.gitlab.com/press/releases/2019-09-17-gitlab-adopted-by-KDE.html
Comment 9 dnovomesky 2020-05-04 09:00:24 UTC
Hello Thomas,
I host the plug-in on GitHub ( https://github.com/novomesk/qt-avif-image-plugin ) as few people recommended before.

The license I use is BSD 2-Clause License ( https://aomedia.org/license/ ) - it is the same license as dependencies needed for the plug-in (libavif + libaom), nothing more above that.

I submitted AVIF mimetypes to shared-mime-info, so the AVIF will be recognized in the future:
https://gitlab.freedesktop.org/xdg/shared-mime-info/-/commit/d23e9fa537b84950cdb518f87e3bf1f3f2577523

Those shell scripts are for common users who are not programmers. The essence of the scripts is to run qmake + make.

I am open to change the file structure and the build process but I need some real examples I should follow.
Comment 10 dnovomesky 2020-12-15 21:02:04 UTC
We can close this. AVIF is now supported by kimageformats 
https://invent.kde.org/frameworks/kimageformats/-/commit/34a9ec1b06844a4caca1362ee15fc8a4143931e6
Comment 11 Luigi Toscano 2021-03-24 15:14:51 UTC
*** Bug 434888 has been marked as a duplicate of this bug. ***
Comment 12 Lonnie 2021-03-24 16:23:14 UTC
In Okular, using the open-file dialog, if you navigate to a folder that contains avif or webp images, the file selection dialog will not even list those file-types without the additional step of changing the filter from "All supported files" to "All files".

Screenshot:
https://i.imgur.com/wwVUuEU.png