GIMP file-heif plugin fails to load HEVC-encoded HEIF image with libheif-1.15.x when libde265 decoder is built as plugin
Environment/Versions
- GIMP version: 2.10.34
- Package: Fedora
- Operating System: Fedora Linux 37
Description of the bug
The HEIF file input plugin in GIMP fails to recognize a HEVC-encoded HEIF image:
$ file image1.heic
image1.heic: ISO Media, HEIF Image HEVC Main or Main Still Picture Profile
When trying to import this file in GIMP, I get an error dialog saying "Opening image1.heic failed: Unknown file type". This happens with libheif-1.15.1 with the libde265 decoder compiled as plugin (/usr/lib64/libheif/libheif-libde265.so):
If I downgrade libheif to 1.13.0 (which has libde265 decoder built-in), opening the same image works.
Reproduction
Is the bug reproducible? Always
Reproduction steps:
- Install libheif-1.15.x with libde265 decoder built as plugin
- Build GIMP 2.10.34 with HEIF support enabled
- Try importing a HEVC-encoded HEIF image
…
Expected result: Image is imported successfully.
Actual result: Import fails with "Unknown file type".
Additional information
I found a similar issue in libheif's heif-thumbnailer tool and reported it there: https://github.com/strukturag/libheif/issues/825 . Following upstream fix, I tried adding the heif_init()/heif_deinit()
calls to file-heif plugin like this:
diff -up gimp-2.10.34/plug-ins/common/file-heif.c.orig gimp-2.10.34/plug-ins/common/file-heif.c
--- gimp-2.10.34/plug-ins/common/file-heif.c.orig 2023-02-21 20:56:19.000000000 +0100
+++ gimp-2.10.34/plug-ins/common/file-heif.c 2023-04-24 10:15:10.341889165 +0200
@@ -74,7 +74,7 @@ static gboolean save_dialog (SavePa
GimpPlugInInfo PLUG_IN_INFO =
{
init, /* init_proc */
- NULL, /* quit_proc */
+ heif_deinit, /* quit_proc */
NULL, /* query_proc */
run, /* run_proc */
};
@@ -109,6 +109,8 @@ init (void)
{ GIMP_PDB_INT32, "quality", "Quality factor (range: 0-100. 0 = worst, 100 = best)" },
{ GIMP_PDB_INT32, "lossless", "Use lossless compression (0 = lossy, 1 = lossless)" }
};
+
+ heif_init(NULL);
if (heif_have_decoder_for_format (heif_compression_HEVC)
#if LIBHEIF_HAVE_VERSION(1,8,0)
but I still get an error, although a different one (Unsupported codec):