2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % M M AAA GGGG IIIII CCCC K K %
7 % MM MM A A G I C K K %
8 % M M M AAAAA G GGG I C KKK %
9 % M M A A G G I C K K %
10 % M M A A GGGG IIIII CCCC K K %
13 % Methods to Read or List ImageMagick Image formats %
21 % Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
22 % dedicated to making software imaging solutions freely available. %
24 % You may not use this file except in compliance with the License. You may %
25 % obtain a copy of the License at %
27 % https://www.imagemagick.org/script/license.php %
29 % Unless required by applicable law or agreed to in writing, software %
30 % distributed under the License is distributed on an "AS IS" BASIS, %
31 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
32 % See the License for the specific language governing permissions and %
33 % limitations under the License. %
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "MagickCore/studio.h"
44 #include "MagickCore/annotate-private.h"
45 #include "MagickCore/blob.h"
46 #include "MagickCore/blob-private.h"
47 #include "MagickCore/cache.h"
48 #include "MagickCore/cache-private.h"
49 #include "MagickCore/coder-private.h"
50 #include "MagickCore/client.h"
51 #include "MagickCore/color-private.h"
52 #include "MagickCore/configure-private.h"
53 #include "MagickCore/constitute-private.h"
54 #include "MagickCore/delegate-private.h"
55 #include "MagickCore/draw.h"
56 #include "MagickCore/exception.h"
57 #include "MagickCore/exception-private.h"
58 #include "MagickCore/locale-private.h"
59 #include "MagickCore/log-private.h"
60 #include "MagickCore/magic-private.h"
61 #include "MagickCore/magick.h"
62 #include "MagickCore/magick-private.h"
63 #include "MagickCore/memory_.h"
64 #include "MagickCore/memory-private.h"
65 #include "MagickCore/mime-private.h"
66 #include "MagickCore/module.h"
67 #include "MagickCore/module-private.h"
68 #include "MagickCore/nt-base-private.h"
69 #include "MagickCore/nt-feature.h"
70 #include "MagickCore/opencl-private.h"
71 #include "MagickCore/option-private.h"
72 #include "MagickCore/random-private.h"
73 #include "MagickCore/registry.h"
74 #include "MagickCore/registry-private.h"
75 #include "MagickCore/resource_.h"
76 #include "MagickCore/resource-private.h"
77 #include "MagickCore/policy.h"
78 #include "MagickCore/policy-private.h"
79 #include "MagickCore/semaphore.h"
80 #include "MagickCore/semaphore-private.h"
81 #include "MagickCore/signature-private.h"
82 #include "MagickCore/splay-tree.h"
83 #include "MagickCore/static.h"
84 #include "MagickCore/string_.h"
85 #include "MagickCore/string-private.h"
86 #include "MagickCore/thread_.h"
87 #include "MagickCore/thread-private.h"
88 #include "MagickCore/type-private.h"
89 #include "MagickCore/token.h"
90 #include "MagickCore/utility.h"
91 #include "MagickCore/utility-private.h"
92 #include "MagickCore/xwindow-private.h"
97 #if !defined(MAGICKCORE_RETSIGTYPE)
98 # define MAGICKCORE_RETSIGTYPE void
100 #if !defined(SIG_DFL)
101 # define SIG_DFL ((SignalHandler *) 0)
103 #if !defined(SIG_ERR)
104 # define SIG_ERR ((SignalHandler *) -1)
111 Typedef declarations.
113 typedef MAGICKCORE_RETSIGTYPE
120 *magick_semaphore = (SemaphoreInfo *) NULL;
123 *signal_handlers[SIGMAX] = { (SignalHandler *) NULL };
126 *magick_list = (SplayTreeInfo *) NULL;
128 static volatile MagickBooleanType
129 instantiate_magickcore = MagickFalse,
130 magickcore_signal_in_progress = MagickFalse,
131 magick_list_initialized = MagickFalse;
134 magick_precision = 0;
137 Forward declarations.
139 static MagickBooleanType
140 IsMagickTreeInstantiated(ExceptionInfo *);
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147 % A c q u i r e M a g i c k I n f o %
151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153 % AcquireMagickInfo() allocates a MagickInfo structure and initializes the
154 % members to default values.
156 % The format of the AcquireMagickInfo method is:
158 % MagickInfo *AcquireMagickInfo(const char *module, const char *name,)
160 % A description of each parameter follows:
162 % o module: a character string that represents the module associated
163 % with the MagickInfo structure.
165 % o name: a character string that represents the image format associated
166 % with the MagickInfo structure.
168 % o description: a character string that represents the image format
169 % associated with the MagickInfo structure.
172 MagickExport MagickInfo *AcquireMagickInfo(const char *module,const char *name,
173 const char *description)
178 assert(module != (const char *) NULL);
179 assert(name != (const char *) NULL);
180 assert(description != (const char *) NULL);
181 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name);
182 magick_info=(MagickInfo *) AcquireCriticalMemory(sizeof(*magick_info));
183 (void) memset(magick_info,0,sizeof(*magick_info));
184 magick_info->module=ConstantString(module);
185 magick_info->name=ConstantString(name);
186 magick_info->description=ConstantString(description);
187 magick_info->flags=CoderAdjoinFlag | CoderBlobSupportFlag |
188 CoderDecoderThreadSupportFlag | CoderEncoderThreadSupportFlag |
189 CoderUseExtensionFlag;
190 magick_info->signature=MagickCoreSignature;
195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 + G e t I m a g e D e c o d e r %
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 % GetImageDecoder() returns the image decoder.
207 % The format of the GetImageDecoder method is:
209 % DecodeImageHandler *GetImageDecoder(const MagickInfo *magick_info)
211 % A description of each parameter follows:
213 % o magick_info: The magick info.
216 MagickExport DecodeImageHandler *GetImageDecoder(const MagickInfo *magick_info)
218 if (magick_info == (MagickInfo *) NULL)
219 return((DecodeImageHandler *) NULL);
220 assert(magick_info->signature == MagickCoreSignature);
221 return(magick_info->decoder);
225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229 + G e t I m a g e E n c o d e r %
233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
235 % GetImageEncoder() returns the image encoder.
237 % The format of the GetImageEncoder method is:
239 % EncodeImageHandler *GetImageEncoder(const MagickInfo *magick_info)
241 % A description of each parameter follows:
243 % o magick_info: The magick info.
246 MagickExport EncodeImageHandler *GetImageEncoder(const MagickInfo *magick_info)
248 if (magick_info == (MagickInfo *) NULL)
249 return((EncodeImageHandler *) NULL);
250 assert(magick_info->signature == MagickCoreSignature);
251 return(magick_info->encoder);
255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 + G e t I m a g e M a g i c k %
263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265 % GetImageMagick() searches for an image format that matches the specified
266 % magick string. If one is found, MagickTrue is returned otherwise
269 % The format of the GetImageMagick method is:
271 % MagickBooleanType GetImageMagick(const unsigned char *magick,
272 % const size_t length,char *format)
274 % A description of each parameter follows:
276 % o magick: the image format we are searching for.
278 % o length: the length of the binary string.
280 % o format: the image format as determined by the magick bytes.
283 MagickExport MagickBooleanType GetImageMagick(const unsigned char *magick,
284 const size_t length,char *format)
292 register const MagickInfo
295 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
296 assert(magick != (const unsigned char *) NULL);
297 exception=AcquireExceptionInfo();
298 p=GetMagickInfo("*",exception);
299 exception=DestroyExceptionInfo(exception);
300 if (p == (const MagickInfo *) NULL)
303 LockSemaphoreInfo(magick_semaphore);
304 ResetSplayTreeIterator(magick_list);
305 p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
306 while (p != (const MagickInfo *) NULL)
308 if ((p->magick != (IsImageFormatHandler *) NULL) &&
309 (p->magick(magick,length) != 0))
312 (void) CopyMagickString(format,p->name,MagickPathExtent);
315 p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
317 UnlockSemaphoreInfo(magick_semaphore);
322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 + G e t M a g i c k A d j o i n %
330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
332 % GetMagickAdjoin() returns MagickTrue if the magick adjoin is MagickTrue.
334 % The format of the GetMagickAdjoin method is:
336 % MagickBooleanType GetMagickAdjoin(const MagickInfo *magick_info)
338 % A description of each parameter follows:
340 % o magick_info: The magick info.
343 MagickExport MagickBooleanType GetMagickAdjoin(const MagickInfo *magick_info)
345 assert(magick_info != (MagickInfo *) NULL);
346 assert(magick_info->signature == MagickCoreSignature);
347 return(((magick_info->flags & CoderAdjoinFlag) == 0) ? MagickFalse :
352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
356 + G e t M a g i c k B l o b S u p p o r t %
360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362 % GetMagickBlobSupport() returns MagickTrue if the magick supports blobs.
364 % The format of the GetMagickBlobSupport method is:
366 % MagickBooleanType GetMagickBlobSupport(const MagickInfo *magick_info)
368 % A description of each parameter follows:
370 % o magick_info: The magick info.
373 MagickExport MagickBooleanType GetMagickBlobSupport(
374 const MagickInfo *magick_info)
376 assert(magick_info != (MagickInfo *) NULL);
377 assert(magick_info->signature == MagickCoreSignature);
378 return(((magick_info->flags & CoderBlobSupportFlag) == 0) ? MagickFalse :
383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
387 + G e t M a g i c k D e c o d e r S e e k a b l e S t r e a m %
391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
393 % GetMagickDecoderSeekableStream() returns MagickTrue if the magick supports a
394 % seekable stream in the decoder.
396 % The format of the GetMagickDecoderSeekableStream method is:
398 % MagickBooleanType GetMagickDecoderSeekableStream(
399 % const MagickInfo *magick_info)
401 % A description of each parameter follows:
403 % o magick_info: The magick info.
406 MagickExport MagickBooleanType GetMagickDecoderSeekableStream(
407 const MagickInfo *magick_info)
409 assert(magick_info != (MagickInfo *) NULL);
410 assert(magick_info->signature == MagickCoreSignature);
411 if ((magick_info->flags & CoderDecoderSeekableStreamFlag) == 0)
417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
421 + G e t M a g i c k D e c o d e r T h r e a d S u p p o r t %
425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427 % GetMagickDecoderThreadSupport() returns MagickTrue if the decoder supports
430 % The format of the GetMagickDecoderThreadSupport method is:
432 % MagickStatusType GetMagickDecoderThreadSupport(
433 % const MagickInfo *magick_info)
435 % A description of each parameter follows:
437 % o magick_info: The magick info.
440 MagickExport MagickBooleanType GetMagickDecoderThreadSupport(
441 const MagickInfo *magick_info)
443 assert(magick_info != (MagickInfo *) NULL);
444 assert(magick_info->signature == MagickCoreSignature);
445 return(((magick_info->flags & CoderDecoderThreadSupportFlag) == 0) ?
446 MagickFalse : MagickTrue);
450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
454 + G e t M a g i c k D e s c r i p t i o n %
458 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
460 % GetMagickDescription() returns the magick description.
462 % The format of the GetMagickDescription method is:
464 % const char *GetMagickDescription(const MagickInfo *magick_info)
466 % A description of each parameter follows:
468 % o magick_info: The magick info.
471 MagickExport const char *GetMagickDescription(const MagickInfo *magick_info)
473 assert(magick_info != (MagickInfo *) NULL);
474 assert(magick_info->signature == MagickCoreSignature);
475 return(magick_info->description);
479 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
483 + G e t M a g i c k E n c o d e r S e e k a b l e S t r e a m %
487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
489 % GetMagickEncoderSeekableStream() returns MagickTrue if the magick supports a
490 % seekable stream in the encoder.
492 % The format of the GetMagickEncoderSeekableStream method is:
494 % MagickBooleanType GetMagickEncoderSeekableStream(
495 % const MagickInfo *magick_info)
497 % A description of each parameter follows:
499 % o magick_info: The magick info.
502 MagickExport MagickBooleanType GetMagickEncoderSeekableStream(
503 const MagickInfo *magick_info)
505 assert(magick_info != (MagickInfo *) NULL);
506 assert(magick_info->signature == MagickCoreSignature);
507 if ((magick_info->flags & CoderEncoderSeekableStreamFlag) == 0)
513 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
517 + G e t M a g i c k E n c o d e r T h r e a d S u p p o r t %
521 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
523 % GetMagickEncoderThreadSupport() returns MagickTrue if the encoder supports
526 % The format of the GetMagickEncoderThreadSupport method is:
528 % MagickStatusType GetMagickEncoderThreadSupport(
529 % const MagickInfo *magick_info)
531 % A description of each parameter follows:
533 % o magick_info: The magick info.
536 MagickExport MagickBooleanType GetMagickEncoderThreadSupport(
537 const MagickInfo *magick_info)
539 assert(magick_info != (MagickInfo *) NULL);
540 assert(magick_info->signature == MagickCoreSignature);
541 return(((magick_info->flags & CoderDecoderThreadSupportFlag) == 0) ?
542 MagickFalse : MagickTrue);
546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
550 + G e t M a g i c k E n d i a n S u p p o r t %
554 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
556 % GetMagickEndianSupport() returns the MagickTrue if the coder respects
557 % endianness other than MSBEndian.
559 % The format of the GetMagickEndianSupport method is:
561 % MagickBooleanType GetMagickEndianSupport(const MagickInfo *magick_info)
563 % A description of each parameter follows:
565 % o magick_info: The magick info.
568 MagickExport MagickBooleanType GetMagickEndianSupport(
569 const MagickInfo *magick_info)
571 assert(magick_info != (MagickInfo *) NULL);
572 assert(magick_info->signature == MagickCoreSignature);
573 return(((magick_info->flags & CoderEndianSupportFlag) == 0) ? MagickFalse :
578 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582 + G e t M a g i c k I n f o %
586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
588 % GetMagickInfo() returns a pointer MagickInfo structure that matches
589 % the specified name. If name is NULL, the head of the image format list
592 % The format of the GetMagickInfo method is:
594 % const MagickInfo *GetMagickInfo(const char *name,Exception *exception)
596 % A description of each parameter follows:
598 % o name: the image format we are looking for.
600 % o exception: return any errors or warnings in this structure.
603 MagickExport const MagickInfo *GetMagickInfo(const char *name,
604 ExceptionInfo *exception)
606 register const MagickInfo
610 Find named module attributes.
612 assert(exception != (ExceptionInfo *) NULL);
613 if (IsMagickTreeInstantiated(exception) == MagickFalse)
614 return((const MagickInfo *) NULL);
615 magick_info=(const MagickInfo *) NULL;
616 if ((name != (const char *) NULL) && (*name != '\0'))
618 LockSemaphoreInfo(magick_semaphore);
619 if (LocaleCompare(name,"*") == 0)
620 #if defined(MAGICKCORE_BUILD_MODULES)
621 (void) OpenModules(exception);
623 RegisterStaticModules();
627 magick_info=(const MagickInfo *) GetValueFromSplayTree(magick_list,
629 if (magick_info == (const MagickInfo *) NULL)
630 #if defined(MAGICKCORE_BUILD_MODULES)
631 (void) OpenModule(name,exception);
633 (void) RegisterStaticModule(name,exception);
636 UnlockSemaphoreInfo(magick_semaphore);
638 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
639 magick_info=(const MagickInfo *) GetRootValueFromSplayTree(magick_list);
640 if (magick_info == (const MagickInfo *) NULL)
641 magick_info=(const MagickInfo *) GetValueFromSplayTree(magick_list,name);
646 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
650 + G e t M a g i c k I n f o L i s t %
654 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
656 % GetMagickInfoList() returns any image formats that match the specified
659 % The format of the GetMagickInfoList function is:
661 % const MagickInfo **GetMagickInfoList(const char *pattern,
662 % size_t *number_formats,ExceptionInfo *exception)
664 % A description of each parameter follows:
666 % o pattern: Specifies a pointer to a text string containing a pattern.
668 % o number_formats: This integer returns the number of formats in the list.
670 % o exception: return any errors or warnings in this structure.
674 #if defined(__cplusplus) || defined(c_plusplus)
678 static int MagickInfoCompare(const void *x,const void *y)
684 p=(const MagickInfo **) x,
685 q=(const MagickInfo **) y;
686 return(LocaleCompare((*p)->name,(*q)->name));
689 #if defined(__cplusplus) || defined(c_plusplus)
693 MagickExport const MagickInfo **GetMagickInfoList(const char *pattern,
694 size_t *number_formats,ExceptionInfo *exception)
699 register const MagickInfo
706 Allocate magick list.
708 assert(pattern != (char *) NULL);
709 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
710 assert(number_formats != (size_t *) NULL);
712 p=GetMagickInfo("*",exception);
713 if (p == (const MagickInfo *) NULL)
714 return((const MagickInfo **) NULL);
715 formats=(const MagickInfo **) AcquireQuantumMemory((size_t)
716 GetNumberOfNodesInSplayTree(magick_list)+1UL,sizeof(*formats));
717 if (formats == (const MagickInfo **) NULL)
718 return((const MagickInfo **) NULL);
720 Generate magick list.
722 LockSemaphoreInfo(magick_semaphore);
723 ResetSplayTreeIterator(magick_list);
724 p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
725 for (i=0; p != (const MagickInfo *) NULL; )
727 if ((GetMagickStealth(p) == MagickFalse) &&
728 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
730 p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
732 UnlockSemaphoreInfo(magick_semaphore);
733 qsort((void *) formats,(size_t) i,sizeof(*formats),MagickInfoCompare);
734 formats[i]=(MagickInfo *) NULL;
735 *number_formats=(size_t) i;
740 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
744 + G e t M a g i c k L i s t %
748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
750 % GetMagickList() returns any image formats that match the specified pattern.
752 % The format of the GetMagickList function is:
754 % char **GetMagickList(const char *pattern,size_t *number_formats,
755 % ExceptionInfo *exception)
757 % A description of each parameter follows:
759 % o pattern: Specifies a pointer to a text string containing a pattern.
761 % o number_formats: This integer returns the number of formats in the list.
763 % o exception: return any errors or warnings in this structure.
767 #if defined(__cplusplus) || defined(c_plusplus)
771 static int MagickCompare(const void *x,const void *y)
779 return(LocaleCompare(*p,*q));
782 #if defined(__cplusplus) || defined(c_plusplus)
786 MagickExport char **GetMagickList(const char *pattern,
787 size_t *number_formats,ExceptionInfo *exception)
792 register const MagickInfo
799 Allocate magick list.
801 assert(pattern != (char *) NULL);
802 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
803 assert(number_formats != (size_t *) NULL);
805 p=GetMagickInfo("*",exception);
806 if (p == (const MagickInfo *) NULL)
807 return((char **) NULL);
808 formats=(char **) AcquireQuantumMemory((size_t)
809 GetNumberOfNodesInSplayTree(magick_list)+1UL,sizeof(*formats));
810 if (formats == (char **) NULL)
811 return((char **) NULL);
812 LockSemaphoreInfo(magick_semaphore);
813 ResetSplayTreeIterator(magick_list);
814 p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
815 for (i=0; p != (const MagickInfo *) NULL; )
817 if ((GetMagickStealth(p) == MagickFalse) &&
818 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
819 formats[i++]=ConstantString(p->name);
820 p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
822 UnlockSemaphoreInfo(magick_semaphore);
823 qsort((void *) formats,(size_t) i,sizeof(*formats),MagickCompare);
824 formats[i]=(char *) NULL;
825 *number_formats=(size_t) i;
830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
834 + G e t M a g i c k M i m e T y p e %
838 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
840 % GetMagickMimeType() returns the magick mime type.
842 % The format of the GetMagickMimeType method is:
844 % const char *GetMagickMimeType(const MagickInfo *magick_info)
846 % A description of each parameter follows:
848 % o magick_info: The magick info.
851 MagickExport const char *GetMagickMimeType(const MagickInfo *magick_info)
853 assert(magick_info != (MagickInfo *) NULL);
854 assert(magick_info->signature == MagickCoreSignature);
855 return(magick_info->mime_type);
859 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
863 % G e t M a g i c k P r e c i s i o n %
867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
869 % GetMagickPrecision() returns the maximum number of significant digits to be
872 % The format of the GetMagickPrecision method is:
874 % int GetMagickPrecision(void)
877 MagickExport int GetMagickPrecision(void)
879 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
880 return(SetMagickPrecision(0));
884 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
888 + G e t M a g i c k R a w S u p p o r t %
892 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
894 % GetMagickRawSupport() returns the MagickTrue if the coder is a raw format.
896 % The format of the GetMagickRawSupport method is:
898 % MagickBooleanType GetMagickRawSupport(const MagickInfo *magick_info)
900 % A description of each parameter follows:
902 % o magick_info: The magick info.
905 MagickExport MagickBooleanType GetMagickRawSupport(
906 const MagickInfo *magick_info)
908 assert(magick_info != (MagickInfo *) NULL);
909 assert(magick_info->signature == MagickCoreSignature);
910 return(((magick_info->flags & CoderRawSupportFlag) == 0) ? MagickFalse :
916 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
920 + G e t M a g i c k S t e a l t h %
924 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
926 % GetMagickStealth() returns MagickTrue if the magick is a stealth coder.
928 % The format of the GetMagickStealth method is:
930 % MagickBooleanType GetMagickStealth(const MagickInfo *magick_info)
932 % A description of each parameter follows:
934 % o magick_info: The magick info.
937 MagickExport MagickBooleanType GetMagickStealth(const MagickInfo *magick_info)
939 assert(magick_info != (MagickInfo *) NULL);
940 assert(magick_info->signature == MagickCoreSignature);
941 return(((magick_info->flags & CoderStealthFlag) == 0) ? MagickFalse :
947 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
951 + G e t M a g i c k U s e E x t e n s i o n %
955 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
957 % GetMagickUseExtension() returns MagickTrue if the magick can use the
958 % extension of the format if the format return by IsImageFormatHandler uses
961 % The format of the GetMagickUseExtension method is:
963 % MagickBooleanType GetMagickUseExtension(const MagickInfo *magick_info)
965 % A description of each parameter follows:
967 % o magick_info: The magick info.
970 MagickExport MagickBooleanType GetMagickUseExtension(
971 const MagickInfo *magick_info)
973 assert(magick_info != (MagickInfo *) NULL);
974 assert(magick_info->signature == MagickCoreSignature);
975 return(((magick_info->flags & CoderUseExtensionFlag) == 0) ? MagickFalse :
980 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
984 + I s M a g i c k T r e e I n s t a n t i a t e d %
988 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
990 % IsMagickTreeInstantiated() determines if the magick tree is instantiated.
991 % If not, it instantiates the tree and returns it.
993 % The format of the IsMagickTreeInstantiated() method is:
995 % IsMagickTreeInstantiated(Exceptioninfo *exception)
997 % A description of each parameter follows.
999 % o exception: return any errors or warnings in this structure.
1003 static void *DestroyMagickNode(void *magick_info)
1008 p=(MagickInfo *) magick_info;
1009 if (p->module != (char *) NULL)
1010 p->module=DestroyString(p->module);
1011 if (p->note != (char *) NULL)
1012 p->note=DestroyString(p->note);
1013 if (p->mime_type != (char *) NULL)
1014 p->mime_type=DestroyString(p->mime_type);
1015 if (p->version != (char *) NULL)
1016 p->version=DestroyString(p->version);
1017 if (p->description != (char *) NULL)
1018 p->description=DestroyString(p->description);
1019 if (p->name != (char *) NULL)
1020 p->name=DestroyString(p->name);
1021 if (p->semaphore != (SemaphoreInfo *) NULL)
1022 RelinquishSemaphoreInfo(&p->semaphore);
1023 return(RelinquishMagickMemory(p));
1026 static MagickBooleanType IsMagickTreeInstantiated(ExceptionInfo *exception)
1028 if (magick_list_initialized == MagickFalse)
1030 if (magick_semaphore == (SemaphoreInfo *) NULL)
1031 ActivateSemaphoreInfo(&magick_semaphore);
1032 LockSemaphoreInfo(magick_semaphore);
1033 if (magick_list_initialized == MagickFalse)
1035 magick_list=NewSplayTree(CompareSplayTreeString,(void *(*)(void *))
1036 NULL,DestroyMagickNode);
1037 #if defined(MAGICKCORE_MODULES_SUPPORT)
1038 (void) GetModuleInfo((char *) NULL,exception);
1040 magick_list_initialized=MagickTrue;
1042 UnlockSemaphoreInfo(magick_semaphore);
1044 return(magick_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
1048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1052 + I s M a g i c k C o n f l i c t %
1056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1058 % IsMagickConflict() returns MagickTrue if the image format conflicts with a
1059 % logical drive (.e.g. X:).
1061 % The format of the IsMagickConflict method is:
1063 % MagickBooleanType IsMagickConflict(const char *magick)
1065 % A description of each parameter follows:
1067 % o magick: Specifies the image format.
1070 MagickPrivate MagickBooleanType IsMagickConflict(const char *magick)
1072 assert(magick != (char *) NULL);
1073 #if defined(macintosh)
1074 return(MACIsMagickConflict(magick));
1076 return(VMSIsMagickConflict(magick));
1077 #elif defined(MAGICKCORE_WINDOWS_SUPPORT)
1078 return(NTIsMagickConflict(magick));
1080 return(MagickFalse);
1085 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1089 + L i s t M a g i c k I n f o %
1093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1095 % ListMagickInfo() lists the image formats to a file.
1097 % The format of the ListMagickInfo method is:
1099 % MagickBooleanType ListMagickInfo(FILE *file,ExceptionInfo *exception)
1101 % A description of each parameter follows.
1103 % o file: A file handle.
1105 % o exception: return any errors or warnings in this structure.
1108 MagickExport MagickBooleanType ListMagickInfo(FILE *file,
1109 ExceptionInfo *exception)
1123 if (file == (FILE *) NULL)
1125 magick_info=GetMagickInfoList("*",&number_formats,exception);
1126 if (magick_info == (const MagickInfo **) NULL)
1127 return(MagickFalse);
1128 ClearMagickException(exception);
1129 #if !defined(MAGICKCORE_MODULES_SUPPORT)
1130 (void) FormatLocaleFile(file," Format Mode Description\n");
1132 (void) FormatLocaleFile(file," Format Module Mode Description\n");
1134 (void) FormatLocaleFile(file,
1135 "--------------------------------------------------------"
1136 "-----------------------\n");
1137 for (i=0; i < (ssize_t) number_formats; i++)
1139 if (GetMagickStealth(magick_info[i]) != MagickFalse)
1141 (void) FormatLocaleFile(file,"%9s%c ",
1142 magick_info[i]->name != (char *) NULL ? magick_info[i]->name : "",
1143 GetMagickBlobSupport(magick_info[i]) != MagickFalse ? '*' : ' ');
1144 #if defined(MAGICKCORE_MODULES_SUPPORT)
1147 module[MagickPathExtent];
1150 if (magick_info[i]->module != (char *) NULL)
1151 (void) CopyMagickString(module,magick_info[i]->module,MagickPathExtent);
1152 (void) ConcatenateMagickString(module," ",MagickPathExtent);
1154 (void) FormatLocaleFile(file,"%9s ",module);
1157 (void) FormatLocaleFile(file,"%c%c%c ",magick_info[i]->decoder ? 'r' : '-',
1158 magick_info[i]->encoder ? 'w' : '-',magick_info[i]->encoder != NULL &&
1159 GetMagickAdjoin(magick_info[i]) != MagickFalse ? '+' : '-');
1160 if (magick_info[i]->description != (char *) NULL)
1161 (void) FormatLocaleFile(file," %s",magick_info[i]->description);
1162 if (magick_info[i]->version != (char *) NULL)
1163 (void) FormatLocaleFile(file," (%s)",magick_info[i]->version);
1164 (void) FormatLocaleFile(file,"\n");
1165 if (magick_info[i]->note != (char *) NULL)
1170 text=StringToList(magick_info[i]->note);
1171 if (text != (char **) NULL)
1173 for (j=0; text[j] != (char *) NULL; j++)
1175 (void) FormatLocaleFile(file," %s\n",text[j]);
1176 text[j]=DestroyString(text[j]);
1178 text=(char **) RelinquishMagickMemory(text);
1182 (void) FormatLocaleFile(file,"\n* native blob support\n");
1183 (void) FormatLocaleFile(file,"r read support\n");
1184 (void) FormatLocaleFile(file,"w write support\n");
1185 (void) FormatLocaleFile(file,"+ support for multiple images\n");
1186 (void) fflush(file);
1187 magick_info=(const MagickInfo **) RelinquishMagickMemory((void *)
1193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1197 % I s M a g i c k C o r e I n s t a n t i a t e d %
1201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1203 % IsMagickCoreInstantiated() returns MagickTrue if the ImageMagick environment
1204 % is currently instantiated: MagickCoreGenesis() has been called but
1205 % MagickDestroy() has not.
1207 % The format of the IsMagickCoreInstantiated method is:
1209 % MagickBooleanType IsMagickCoreInstantiated(void)
1212 MagickExport MagickBooleanType IsMagickCoreInstantiated(void)
1214 return(instantiate_magickcore);
1218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1222 + M a g i c k C o m p o n e n t G e n e s i s %
1226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1228 % MagickComponentGenesis() instantiates the magick component.
1230 % The format of the MagickComponentGenesis method is:
1232 % MagickBooleanType MagickComponentGenesis(void)
1235 MagickPrivate MagickBooleanType MagickComponentGenesis(void)
1237 if (magick_semaphore == (SemaphoreInfo *) NULL)
1238 magick_semaphore=AcquireSemaphoreInfo();
1243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1247 + M a g i c k C o m p o n e n t T e r m i n u s %
1251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1253 % MagickComponentTerminus() destroys the magick component.
1255 % The format of the MagickComponentTerminus method is:
1257 % void MagickComponentTerminus(void)
1260 MagickPrivate void MagickComponentTerminus(void)
1262 if (magick_semaphore == (SemaphoreInfo *) NULL)
1263 ActivateSemaphoreInfo(&magick_semaphore);
1264 LockSemaphoreInfo(magick_semaphore);
1265 if (magick_list != (SplayTreeInfo *) NULL)
1267 magick_list=DestroySplayTree(magick_list);
1268 magick_list_initialized=MagickFalse;
1270 UnlockSemaphoreInfo(magick_semaphore);
1271 RelinquishSemaphoreInfo(&magick_semaphore);
1275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1279 % M a g i c k C o r e G e n e s i s %
1283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1285 % MagickCoreGenesis() initializes the MagickCore environment.
1287 % The format of the MagickCoreGenesis function is:
1289 % MagickCoreGenesis(const char *path,
1290 % const MagickBooleanType establish_signal_handlers)
1292 % A description of each parameter follows:
1294 % o path: the execution path of the current ImageMagick client.
1296 % o establish_signal_handlers: set to MagickTrue to use MagickCore's own
1297 % signal handlers for common signals.
1301 static SignalHandler *SetMagickSignalHandler(int signal_number,
1302 SignalHandler *handler)
1304 #if defined(MAGICKCORE_HAVE_SIGACTION) && defined(MAGICKCORE_HAVE_SIGEMPTYSET)
1316 sigaddset(&mask,signal_number);
1317 sigprocmask(SIG_BLOCK,&mask,NULL);
1318 action.sa_mask=mask;
1319 action.sa_handler=handler;
1321 #if defined(SA_INTERRUPT)
1322 action.sa_flags|=SA_INTERRUPT;
1324 #if defined(SA_ONSTACK)
1325 action.sa_flags|=SA_ONSTACK;
1327 status=sigaction(signal_number,&action,&previous_action);
1330 sigprocmask(SIG_UNBLOCK,&mask,NULL);
1331 return(previous_action.sa_handler);
1333 return(signal(signal_number,handler));
1337 static void MagickSignalHandler(int signal_number)
1339 if (magickcore_signal_in_progress != MagickFalse)
1340 (void) SetMagickSignalHandler(signal_number,signal_handlers[signal_number]);
1341 magickcore_signal_in_progress=MagickTrue;
1342 AsynchronousResourceComponentTerminus();
1343 #if defined(SIGQUIT)
1344 if (signal_number == SIGQUIT)
1347 #if defined(SIGABRT)
1348 if (signal_number == SIGABRT)
1352 if (signal_number == SIGBUS)
1356 if (signal_number == SIGFPE)
1359 #if defined(SIGXCPU)
1360 if (signal_number == SIGXCPU)
1363 #if defined(SIGXFSZ)
1364 if (signal_number == SIGXFSZ)
1367 #if defined(SIGSEGV)
1368 if (signal_number == SIGSEGV)
1371 #if !defined(MAGICKCORE_HAVE__EXIT)
1372 exit(signal_number);
1375 if (signal_number == SIGHUP)
1376 _exit(signal_number);
1379 if (signal_number == SIGINT)
1380 _exit(signal_number);
1383 if (signal_number == SIGBUS)
1384 _exit(signal_number);
1386 #if defined(MAGICKCORE_HAVE_RAISE)
1387 if (signal_handlers[signal_number] != MagickSignalHandler)
1388 raise(signal_number);
1390 _exit(signal_number); /* do not invoke registered atexit() methods */
1394 static SignalHandler *RegisterMagickSignalHandler(int signal_number)
1399 handler=SetMagickSignalHandler(signal_number,MagickSignalHandler);
1400 if (handler == SIG_ERR)
1402 if (handler != SIG_DFL)
1403 handler=SetMagickSignalHandler(signal_number,handler);
1405 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
1406 "Register handler for signal: %d",signal_number);
1410 MagickExport void MagickCoreGenesis(const char *path,
1411 const MagickBooleanType establish_signal_handlers)
1415 execution_path[MagickPathExtent],
1416 filename[MagickPathExtent];
1419 Initialize the Magick environment.
1421 InitializeMagickMutex();
1423 if (instantiate_magickcore != MagickFalse)
1425 UnlockMagickMutex();
1428 (void) SemaphoreComponentGenesis();
1429 (void) LogComponentGenesis();
1430 (void) LocaleComponentGenesis();
1431 (void) RandomComponentGenesis();
1432 events=GetEnvironmentValue("MAGICK_DEBUG");
1433 if (events != (char *) NULL)
1435 (void) SetLogEventMask(events);
1436 events=DestroyString(events);
1438 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
1442 Set client name and execution path.
1444 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
1445 if ((path != (const char *) NULL) && (IsPathAccessible(path) != MagickFalse))
1447 if ((path != (const char *) NULL) && (*path == *DirectorySeparator) &&
1448 (IsPathAccessible(path) != MagickFalse))
1450 (void) CopyMagickString(execution_path,path,MagickPathExtent);
1452 (void) GetExecutionPath(execution_path,MagickPathExtent);
1453 GetPathComponent(execution_path,TailPath,filename);
1454 (void) SetClientName(filename);
1455 GetPathComponent(execution_path,HeadPath,execution_path);
1456 (void) SetClientPath(execution_path);
1457 if (establish_signal_handlers != MagickFalse)
1460 Set signal handlers.
1462 #if defined(SIGABRT)
1463 if (signal_handlers[SIGABRT] == (SignalHandler *) NULL)
1464 signal_handlers[SIGABRT]=RegisterMagickSignalHandler(SIGABRT);
1467 if (signal_handlers[SIGBUS] == (SignalHandler *) NULL)
1468 signal_handlers[SIGBUS]=RegisterMagickSignalHandler(SIGBUS);
1470 #if defined(SIGSEGV)
1471 if (signal_handlers[SIGSEGV] == (SignalHandler *) NULL)
1472 signal_handlers[SIGSEGV]=RegisterMagickSignalHandler(SIGSEGV);
1475 if (signal_handlers[SIGFPE] == (SignalHandler *) NULL)
1476 signal_handlers[SIGFPE]=RegisterMagickSignalHandler(SIGFPE);
1479 if (signal_handlers[SIGHUP] == (SignalHandler *) NULL)
1480 signal_handlers[SIGHUP]=RegisterMagickSignalHandler(SIGHUP);
1483 if (signal_handlers[SIGINT] == (SignalHandler *) NULL)
1484 signal_handlers[SIGINT]=RegisterMagickSignalHandler(SIGINT);
1486 #if defined(SIGQUIT)
1487 if (signal_handlers[SIGQUIT] == (SignalHandler *) NULL)
1488 signal_handlers[SIGQUIT]=RegisterMagickSignalHandler(SIGQUIT);
1490 #if defined(SIGTERM)
1491 if (signal_handlers[SIGTERM] == (SignalHandler *) NULL)
1492 signal_handlers[SIGTERM]=RegisterMagickSignalHandler(SIGTERM);
1494 #if defined(SIGXCPU)
1495 if (signal_handlers[SIGXCPU] == (SignalHandler *) NULL)
1496 signal_handlers[SIGXCPU]=RegisterMagickSignalHandler(SIGXCPU);
1498 #if defined(SIGXFSZ)
1499 if (signal_handlers[SIGXFSZ] == (SignalHandler *) NULL)
1500 signal_handlers[SIGXFSZ]=RegisterMagickSignalHandler(SIGXFSZ);
1504 Instantiate magick resources.
1506 (void) ConfigureComponentGenesis();
1507 (void) PolicyComponentGenesis();
1508 #if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
1509 (void) ZeroConfigurationPolicy;
1511 (void) CacheComponentGenesis();
1512 (void) ResourceComponentGenesis();
1513 (void) CoderComponentGenesis();
1514 (void) MagickComponentGenesis();
1515 #if defined(MAGICKCORE_MODULES_SUPPORT)
1516 (void) ModuleComponentGenesis();
1518 (void) DelegateComponentGenesis();
1519 (void) MagicComponentGenesis();
1520 (void) ColorComponentGenesis();
1521 (void) TypeComponentGenesis();
1522 (void) MimeComponentGenesis();
1523 (void) AnnotateComponentGenesis();
1524 #if defined(MAGICKCORE_X11_DELEGATE)
1525 (void) XComponentGenesis();
1527 (void) RegistryComponentGenesis();
1528 instantiate_magickcore=MagickTrue;
1529 UnlockMagickMutex();
1533 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1537 % M a g i c k C o r e T e r m i n u s %
1541 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1543 % MagickCoreTerminus() destroys the MagickCore environment.
1545 % The format of the MagickCoreTerminus function is:
1547 % MagickCoreTerminus(void)
1550 MagickExport void MagickCoreTerminus(void)
1552 InitializeMagickMutex();
1554 if (instantiate_magickcore == MagickFalse)
1556 UnlockMagickMutex();
1559 RegistryComponentTerminus();
1560 #if defined(MAGICKCORE_X11_DELEGATE)
1561 XComponentTerminus();
1563 AnnotateComponentTerminus();
1564 MimeComponentTerminus();
1565 TypeComponentTerminus();
1566 #if defined(MAGICKCORE_OPENCL_SUPPORT)
1569 ColorComponentTerminus();
1570 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
1571 NTWindowsTerminus();
1573 MagicComponentTerminus();
1574 DelegateComponentTerminus();
1575 MagickComponentTerminus();
1576 #if !defined(MAGICKCORE_BUILD_MODULES)
1577 UnregisterStaticModules();
1579 #if defined(MAGICKCORE_MODULES_SUPPORT)
1580 ModuleComponentTerminus();
1582 CoderComponentTerminus();
1583 ResourceComponentTerminus();
1584 CacheComponentTerminus();
1585 PolicyComponentTerminus();
1586 ConfigureComponentTerminus();
1587 RandomComponentTerminus();
1588 LocaleComponentTerminus();
1589 LogComponentTerminus();
1590 instantiate_magickcore=MagickFalse;
1591 UnlockMagickMutex();
1592 SemaphoreComponentTerminus();
1596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1600 + R e g i s t e r M a g i c k I n f o %
1604 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1606 % RegisterMagickInfo() adds attributes for a particular image format to the
1607 % list of supported formats. The attributes include the image format name,
1608 % a method to read and/or write the format, whether the format supports the
1609 % saving of more than one frame to the same file or blob, whether the format
1610 % supports native in-memory I/O, and a brief description of the format.
1612 % The format of the RegisterMagickInfo method is:
1614 % MagickInfo *RegisterMagickInfo(MagickInfo *magick_info)
1616 % A description of each parameter follows:
1618 % o magick_info: the magick info.
1621 MagickExport MagickBooleanType RegisterMagickInfo(MagickInfo *magick_info)
1627 Register a new image format.
1629 assert(magick_info != (MagickInfo *) NULL);
1630 assert(magick_info->signature == MagickCoreSignature);
1631 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",magick_info->name);
1632 if (magick_list == (SplayTreeInfo *) NULL)
1633 return(MagickFalse);
1634 if ((GetMagickDecoderThreadSupport(magick_info) == MagickFalse) ||
1635 (GetMagickEncoderThreadSupport(magick_info) == MagickFalse))
1636 magick_info->semaphore=AcquireSemaphoreInfo();
1637 status=AddValueToSplayTree(magick_list,magick_info->name,magick_info);
1642 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1646 + R e s e t M a g i c k P r e c i s i o n %
1650 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1652 % ResetMagickPrecision() resets the magick_precision value.
1654 % The format of the ResetMagickPrecision method is:
1656 % void ResetMagickPrecision(void)
1659 MagickPrivate void ResetMagickPrecision(void)
1665 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1669 % S e t M a g i c k P r e c i s i o n %
1673 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1675 % SetMagickPrecision() sets the maximum number of significant digits to be
1678 % An input argument of 0 returns the current precision setting.
1680 % A negative value forces the precision to reset to a default value according
1681 % to the environment variable "MAGICK_PRECISION", the current 'policy'
1682 % configuration setting, or the default value of '6', in that order.
1684 % The format of the SetMagickPrecision method is:
1686 % int SetMagickPrecision(const int precision)
1688 % A description of each parameter follows:
1690 % o precision: set the maximum number of significant digits to be printed.
1693 MagickExport int SetMagickPrecision(const int precision)
1695 #define MagickPrecision 6
1697 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1699 magick_precision=precision;
1700 if ((precision < 0) || (magick_precision == 0))
1706 Precision reset, or it has not been set yet
1708 magick_precision=MagickPrecision;
1709 limit=GetEnvironmentValue("MAGICK_PRECISION");
1710 if (limit == (char *) NULL)
1711 limit=GetPolicyValue("system:precision");
1712 if (limit != (char *) NULL)
1714 magick_precision=StringToInteger(limit);
1715 limit=DestroyString(limit);
1718 return(magick_precision);
1722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1726 + U n r e g i s t e r M a g i c k I n f o %
1730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1732 % UnregisterMagickInfo() removes a name from the magick info list. It returns
1733 % MagickFalse if the name does not exist in the list otherwise MagickTrue.
1735 % The format of the UnregisterMagickInfo method is:
1737 % MagickBooleanType UnregisterMagickInfo(const char *name)
1739 % A description of each parameter follows:
1741 % o name: a character string that represents the image format we are
1745 MagickExport MagickBooleanType UnregisterMagickInfo(const char *name)
1747 register const MagickInfo
1753 assert(name != (const char *) NULL);
1754 if (magick_list == (SplayTreeInfo *) NULL)
1755 return(MagickFalse);
1756 if (GetNumberOfNodesInSplayTree(magick_list) == 0)
1757 return(MagickFalse);
1758 LockSemaphoreInfo(magick_semaphore);
1759 ResetSplayTreeIterator(magick_list);
1760 p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
1761 while (p != (const MagickInfo *) NULL)
1763 if (LocaleCompare(p->name,name) == 0)
1765 p=(const MagickInfo *) GetNextValueInSplayTree(magick_list);
1767 status=DeleteNodeByValueFromSplayTree(magick_list,p);
1768 UnlockSemaphoreInfo(magick_semaphore);