From 7fde2224db9e78d024cec862ab3cd73514125ed1 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Aug 20 2023 21:59:01 +0000 Subject: Fix loading HEVC-encoded HEIF images (#2189462) Signed-off-by: Nils Philippsen --- diff --git a/0001-plug-ins-use-heif_init-heif_deinit.patch b/0001-plug-ins-use-heif_init-heif_deinit.patch new file mode 100644 index 0000000..ea18a4b --- /dev/null +++ b/0001-plug-ins-use-heif_init-heif_deinit.patch @@ -0,0 +1,101 @@ +From bb06322b490d5b942d4289c3cf2b78a535d20840 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= +Date: Mon, 24 Apr 2023 18:07:19 +0200 +Subject: [PATCH] plug-ins: use heif_init/heif_deinit + +--- + plug-ins/common/file-heif.c | 34 ++++++++++++++++++++++++++++++++++ + 1 file changed, 34 insertions(+) + +diff --git a/plug-ins/common/file-heif.c b/plug-ins/common/file-heif.c +index 9564355f4f..97b0a9153c 100644 +--- a/plug-ins/common/file-heif.c ++++ b/plug-ins/common/file-heif.c +@@ -110,6 +110,10 @@ init (void) + { GIMP_PDB_INT32, "lossless", "Use lossless compression (0 = lossy, 1 = lossless)" } + }; + ++#if LIBHEIF_HAVE_VERSION(1,13,0) ++ heif_init (NULL); ++#endif ++ + if (heif_have_decoder_for_format (heif_compression_HEVC) + #if LIBHEIF_HAVE_VERSION(1,8,0) + || heif_have_decoder_for_format (heif_compression_AV1) +@@ -207,6 +211,10 @@ init (void) + gimp_register_file_handler_uri (SAVE_PROC_AV1); + } + #endif ++ ++#if LIBHEIF_HAVE_VERSION(1,13,0) ++ heif_deinit (); ++#endif + } + + #define LOAD_HEIF_CANCEL -2 +@@ -252,8 +260,16 @@ run (const gchar *name, + { + gint32 image_ID; + ++#if LIBHEIF_HAVE_VERSION(1,13,0) ++ heif_init (NULL); ++#endif ++ + image_ID = load_image (file, interactive, &error); + ++#if LIBHEIF_HAVE_VERSION(1,13,0) ++ heif_deinit (); ++#endif ++ + if (image_ID >= 0) + { + *nreturn_vals = 2; +@@ -341,6 +357,10 @@ run (const gchar *name, + { + GFile *file = g_file_new_for_uri (param[3].data.d_string); + ++#if LIBHEIF_HAVE_VERSION(1,13,0) ++ heif_init (NULL); ++#endif ++ + if (save_image (file, image_ID, drawable_ID, + ¶ms, + &error, +@@ -359,6 +379,11 @@ run (const gchar *name, + { + status = GIMP_PDB_EXECUTION_ERROR; + } ++ ++#if LIBHEIF_HAVE_VERSION(1,13,0) ++ heif_deinit (); ++#endif ++ + g_object_unref (file); + } + +@@ -437,6 +462,10 @@ run (const gchar *name, + { + GFile *file = g_file_new_for_uri (param[3].data.d_string); + ++#if LIBHEIF_HAVE_VERSION(1,13,0) ++ heif_init (NULL); ++#endif ++ + if (save_image (file, image_ID, drawable_ID, + ¶ms, + &error, +@@ -448,6 +477,11 @@ run (const gchar *name, + { + status = GIMP_PDB_EXECUTION_ERROR; + } ++ ++#if LIBHEIF_HAVE_VERSION(1,13,0) ++ heif_deinit (); ++#endif ++ + g_object_unref (file); + } + +-- +2.41.0 + diff --git a/gimp.spec b/gimp.spec index 218e310..bc7e94e 100644 --- a/gimp.spec +++ b/gimp.spec @@ -197,6 +197,10 @@ Patch100: gimp-2.10.24-external-help-browser.patch Patch101: gimp-configure-c99.patch +# fix loading HEVC-encoded HEIF images +# patch from upstream: https://gitlab.gnome.org/GNOME/gimp/-/merge_requests/905 +Patch102: 0001-plug-ins-use-heif_init-heif_deinit.patch + %description GIMP (GNU Image Manipulation Program) is a powerful image composition and editing program, which can be extremely useful for creating logos and other @@ -283,11 +287,13 @@ EOF %patch 100 -p1 -b .external-help-browser %endif -%patch 101 -p1 +%patch 101 -p1 -b .configure-c99 # Avoid re-running autotools. touch -r aclocal.m4 configure* +%patch 102 -p1 -b .heif + %build # allow python2 package for RHEL-8 export RHEL_ALLOW_PYTHON2_FOR_BUILD=1