On further reading the ImageMagick source, I would that the calls to 'MagickWandGenesis' protect themselves against redundant repeat calls. Hence, there is no need to protect it using a static variable. The following patch is a minimal fix.
commit 23236f26d2f5839f2fdb7022039dcf102dcf3a3b
Date: Mon Dec 23 14:49:51 2019 -0800
Initialize ImageMagick runtime environment before use
diff --git a/src/image.c b/src/image.c
index 70d932f9ed..75c31cad57 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8875,13 +8875,8 @@ imagemagick_load_image (struct frame *f, struct image *img,
char hint_buffer[MaxTextExtent];
char *filename_hint = NULL;
- /* Initialize the ImageMagick environment. */
- static bool imagemagick_initialized;
- if (!imagemagick_initialized)
- {
- imagemagick_initialized = true;
- MagickWandGenesis ();
- }
+ /* Initialize the ImageMagick environment if not initialized. */
+ MagickWandGenesis ();
/* Handle image index for image types who can contain more than one image.
Interface :index is same as for GIF. First we "ping" the image to see how
@@ -9290,6 +9285,9 @@ DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0,
char **imtypes;
size_t i;
+ /* Initialize the ImageMagick environment if not initialized. */
+ MagickWandGenesis ();
+
ex = AcquireExceptionInfo ();
imtypes = GetMagickList ("*", &numf, ex);
DestroyExceptionInfo (ex);