Last active
December 29, 2019 11:57
-
-
Save d12frosted/469cb040f9efe619d8f7056cf2a806ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 23236f26d2f5839f2fdb7022039dcf102dcf3a3b | |
Author: Dhruva Krishnamurthy <address@hidden> | |
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..50d90ccb55 100644 | |
--- a/src/image.c | |
+++ b/src/image.c | |
@@ -8603,6 +8603,20 @@ #define DrawRectangle DrawRectangleGif | |
MagickPixelPacket *); | |
#endif | |
+/* Initialize the ImageMagick environment if not initialized. */ | |
+ | |
+static void | |
+imagemagick_initialize(void) | |
+{ | |
+ /* Initialize the ImageMagick environment. */ | |
+ static bool imagemagick_initialized; | |
+ if (!imagemagick_initialized) | |
+ { | |
+ MagickWandGenesis(); | |
+ imagemagick_initialized = !!IsMagickWandInstantiated(); | |
+ } | |
+} | |
+ | |
/* Log ImageMagick error message. | |
Useful when an ImageMagick function returns the status `MagickFalse'. */ | |
@@ -8876,12 +8890,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |
char *filename_hint = NULL; | |
/* Initialize the ImageMagick environment. */ | |
- static bool imagemagick_initialized; | |
- if (!imagemagick_initialized) | |
- { | |
- imagemagick_initialized = true; | |
- MagickWandGenesis (); | |
- } | |
+ imagemagick_initialize(); | |
/* 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 +9299,9 @@ DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0, | |
char **imtypes; | |
size_t i; | |
+ /* Initialize the ImageMagick environment. */ | |
+ imagemagick_initialize(); | |
+ | |
ex = AcquireExceptionInfo (); | |
imtypes = GetMagickList ("*", &numf, ex); | |
DestroyExceptionInfo (ex); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment