[gimp] HEIF plug-in: runtime detection of supported formats
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] HEIF plug-in: runtime detection of supported formats
- Date: Thu, 22 Oct 2020 18:45:16 +0000 (UTC)
commit 35c0d7dca6251c1469d880d609d04acb9647ba13
Author: Daniel Novomesky <dnovomesky gmail com>
Date: Tue Oct 20 14:16:53 2020 +0200
HEIF plug-in: runtime detection of supported formats
plug-ins/common/file-heif.c | 75 +++++++++++++++++++++++++++++++++------------
1 file changed, 55 insertions(+), 20 deletions(-)
---
diff --git a/plug-ins/common/file-heif.c b/plug-ins/common/file-heif.c
index 3df9b6fcc8..4fa078719b 100644
--- a/plug-ins/common/file-heif.c
+++ b/plug-ins/common/file-heif.c
@@ -30,6 +30,7 @@
#define LOAD_PROC "file-heif-load"
+#define LOAD_PROC_AV1 "file-heif-av1-load"
#define SAVE_PROC "file-heif-save"
#define SAVE_PROC_AV1 "file-heif-av1-save"
#define PLUG_IN_BINARY "file-heif"
@@ -146,10 +147,25 @@ heif_query_procedures (GimpPlugIn *plug_in)
{
GList *list = NULL;
- list = g_list_append (list, g_strdup (LOAD_PROC));
- list = g_list_append (list, g_strdup (SAVE_PROC));
+ if (heif_have_decoder_for_format (heif_compression_HEVC))
+ {
+ list = g_list_append (list, g_strdup (LOAD_PROC));
+ }
+
+ if (heif_have_encoder_for_format (heif_compression_HEVC))
+ {
+ list = g_list_append (list, g_strdup (SAVE_PROC));
+ }
#if LIBHEIF_HAVE_VERSION(1,8,0)
- list = g_list_append (list, g_strdup (SAVE_PROC_AV1));
+ if (heif_have_decoder_for_format (heif_compression_AV1))
+ {
+ list = g_list_append (list, g_strdup (LOAD_PROC_AV1));
+ }
+
+ if (heif_have_encoder_for_format (heif_compression_AV1))
+ {
+ list = g_list_append (list, g_strdup (SAVE_PROC_AV1));
+ }
#endif
return list;
}
@@ -183,17 +199,9 @@ heif_create_procedure (GimpPlugIn *plug_in,
gimp_file_procedure_set_handles_remote (GIMP_FILE_PROCEDURE (procedure),
TRUE);
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
- "image/heif"
-#if LIBHEIF_HAVE_VERSION(1,8,0)
- ",image/avif"
-#endif
- );
+ "image/heif");
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
- "heif,heic"
-#if LIBHEIF_HAVE_VERSION(1,8,0)
- ",avif"
-#endif
- );
+ "heif,heic");
/* HEIF is an ISOBMFF format whose "brand" (the value after "ftyp")
* can be of various values.
@@ -204,11 +212,7 @@ heif_create_procedure (GimpPlugIn *plug_in,
"4,string,ftyphevc,4,string,ftypheim,"
"4,string,ftypheis,4,string,ftyphevm,"
"4,string,ftyphevs,4,string,ftypmif1,"
- "4,string,ftypmsf1"
-#if LIBHEIF_HAVE_VERSION(1,8,0)
- ",4,string,ftypavif"
-#endif
- );
+ "4,string,ftypmsf1");
}
else if (! strcmp (name, SAVE_PROC))
{
@@ -288,6 +292,35 @@ heif_create_procedure (GimpPlugIn *plug_in,
G_PARAM_READWRITE);
}
#if LIBHEIF_HAVE_VERSION(1,8,0)
+ else if (! strcmp (name, LOAD_PROC_AV1))
+ {
+ procedure = gimp_load_procedure_new (plug_in, name,
+ GIMP_PDB_PROC_TYPE_PLUGIN,
+ heif_load, NULL, NULL);
+
+ gimp_procedure_set_menu_label (procedure, "HEIF/AVIF");
+
+ gimp_procedure_set_documentation (procedure,
+ _("Loads AVIF images"),
+ _("Load image stored in AV1 Image File Format (AVIF)"),
+ name);
+ gimp_procedure_set_attribution (procedure,
+ "Daniel Novomesky <dnovomesky gmail com>",
+ "Daniel Novomesky <dnovomesky gmail com>",
+ "2020");
+
+ gimp_file_procedure_set_handles_remote (GIMP_FILE_PROCEDURE (procedure),
+ TRUE);
+ gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
+ "image/avif");
+ gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
+ "avif");
+
+ gimp_file_procedure_set_magics (GIMP_FILE_PROCEDURE (procedure),
+ "4,string,ftypmif1,4,string,ftypavif");
+
+ gimp_file_procedure_set_priority (GIMP_FILE_PROCEDURE (procedure), 100);
+ }
else if (! strcmp (name, SAVE_PROC_AV1))
{
procedure = gimp_save_procedure_new (plug_in, name,
@@ -299,8 +332,8 @@ heif_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_set_menu_label (procedure, "HEIF/AVIF");
gimp_procedure_set_documentation (procedure,
- "Exports AVIF images",
- "Save image in AV1 Image File Format (AVIF)",
+ _("Exports AVIF images"),
+ _("Save image in AV1 Image File Format (AVIF)"),
name);
gimp_procedure_set_attribution (procedure,
"Daniel Novomesky <dnovomesky gmail com>",
@@ -314,6 +347,8 @@ heif_create_procedure (GimpPlugIn *plug_in,
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
"avif");
+ gimp_file_procedure_set_priority (GIMP_FILE_PROCEDURE (procedure), 100);
+
GIMP_PROC_ARG_INT (procedure, "quality",
"Quality",
"Quality factor (0 = worst, 100 = best)",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]