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 %
14 % W W W AAAAA N N N D D %
15 % WW WW A A N NN D D %
19 % MagickWand Wand Methods %
26 % Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 #include "wand/studio.h"
50 #include "wand/MagickWand.h"
51 #include "wand/magick-wand-private.h"
52 #include "wand/wand.h"
57 #define ThrowWandException(severity,tag,context) \
59 (void) ThrowMagickException(wand->exception,GetMagickModule(),severity, \
60 tag,"`%s'",context); \
61 return(MagickFalse); \
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 % C l e a r M a g i c k W a n d %
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 % ClearMagickWand() clears resources associated with the wand.
77 % The format of the ClearMagickWand method is:
79 % void ClearMagickWand(MagickWand *wand)
81 % A description of each parameter follows:
83 % o wand: the magick wand.
86 WandExport void ClearMagickWand(MagickWand *wand)
88 assert(wand != (MagickWand *) NULL);
89 assert(wand->signature == WandSignature);
90 if (wand->debug != MagickFalse)
91 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
92 wand->quantize_info=DestroyQuantizeInfo(wand->quantize_info);
93 wand->image_info=DestroyImageInfo(wand->image_info);
94 wand->images=DestroyImageList(wand->images);
95 wand->quantize_info=CloneQuantizeInfo((QuantizeInfo *) NULL);
96 wand->image_info=AcquireImageInfo();
97 ClearMagickException(wand->exception);
98 wand->debug=IsEventLogging();
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 % C l o n e M a g i c k W a n d %
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112 % CloneMagickWand() makes an exact copy of the specified wand.
114 % The format of the CloneMagickWand method is:
116 % MagickWand *CloneMagickWand(const MagickWand *wand)
118 % A description of each parameter follows:
120 % o wand: the magick wand.
123 WandExport MagickWand *CloneMagickWand(const MagickWand *wand)
128 assert(wand != (MagickWand *) NULL);
129 assert(wand->signature == WandSignature);
130 if (wand->debug != MagickFalse)
131 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
132 clone_wand=(MagickWand *) AcquireAlignedMemory(1,sizeof(*clone_wand));
133 if (clone_wand == (MagickWand *) NULL)
134 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
136 (void) ResetMagickMemory(clone_wand,0,sizeof(*clone_wand));
137 clone_wand->id=AcquireWandId();
138 (void) FormatMagickString(clone_wand->name,MaxTextExtent,"%s-%.20g",
139 MagickWandId,(double) clone_wand->id);
140 clone_wand->exception=AcquireExceptionInfo();
141 InheritException(clone_wand->exception,wand->exception);
142 clone_wand->image_info=CloneImageInfo(wand->image_info);
143 clone_wand->quantize_info=CloneQuantizeInfo(wand->quantize_info);
144 clone_wand->images=CloneImageList(wand->images,clone_wand->exception);
145 clone_wand->debug=IsEventLogging();
146 if (clone_wand->debug != MagickFalse)
147 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_wand->name);
148 clone_wand->signature=WandSignature;
153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 % D e s t r o y M a g i c k W a n d %
161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 % DestroyMagickWand() deallocates memory associated with an MagickWand.
165 % The format of the DestroyMagickWand method is:
167 % MagickWand *DestroyMagickWand(MagickWand *wand)
169 % A description of each parameter follows:
171 % o wand: the magick wand.
174 WandExport MagickWand *DestroyMagickWand(MagickWand *wand)
176 assert(wand != (MagickWand *) NULL);
177 assert(wand->signature == WandSignature);
178 if (wand->debug != MagickFalse)
179 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
180 wand->quantize_info=DestroyQuantizeInfo(wand->quantize_info);
181 wand->image_info=DestroyImageInfo(wand->image_info);
182 wand->images=DestroyImageList(wand->images);
183 wand->exception=DestroyExceptionInfo(wand->exception);
184 RelinquishWandId(wand->id);
185 wand->signature=(~WandSignature);
186 wand=(MagickWand *) RelinquishMagickMemory(wand);
191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195 % I s M a g i c k W a n d %
199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 % IsMagickWand() returns MagickTrue if the wand is verified as a magick wand.
203 % The format of the IsMagickWand method is:
205 % MagickBooleanType IsMagickWand(const MagickWand *wand)
207 % A description of each parameter follows:
209 % o wand: the magick wand.
212 WandExport MagickBooleanType IsMagickWand(const MagickWand *wand)
214 if (wand == (const MagickWand *) NULL)
216 if (wand->signature != WandSignature)
218 if (LocaleNCompare(wand->name,MagickWandId,strlen(MagickWandId)) != 0)
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228 % M a g i c k C l e a r E x c e p t i o n %
232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234 % MagickClearException() clears any exceptions associated with the wand.
236 % The format of the MagickClearException method is:
238 % MagickBooleanType MagickClearException(MagickWand *wand)
240 % A description of each parameter follows:
242 % o wand: the magick wand.
245 WandExport MagickBooleanType MagickClearException(MagickWand *wand)
247 assert(wand != (MagickWand *) NULL);
248 assert(wand->signature == WandSignature);
249 if (wand->debug != MagickFalse)
250 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
251 ClearMagickException(wand->exception);
256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 % M a g i c k G e t E x c e p t i o n %
264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266 % MagickGetException() returns the severity, reason, and description of any
267 % error that occurs when using other methods in this API.
269 % The format of the MagickGetException method is:
271 % char *MagickGetException(const MagickWand *wand,ExceptionType *severity)
273 % A description of each parameter follows:
275 % o wand: the magick wand.
277 % o severity: the severity of the error is returned here.
280 WandExport char *MagickGetException(const MagickWand *wand,
281 ExceptionType *severity)
286 assert(wand != (const MagickWand *) NULL);
287 assert(wand->signature == WandSignature);
288 if (wand->debug != MagickFalse)
289 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
290 assert(severity != (ExceptionType *) NULL);
291 *severity=wand->exception->severity;
292 description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent,
293 sizeof(*description));
294 if (description == (char *) NULL)
296 (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
297 "MemoryAllocationFailed","`%s'",wand->name);
298 return((char *) NULL);
301 if (wand->exception->reason != (char *) NULL)
302 (void) CopyMagickString(description,GetLocaleExceptionMessage(
303 wand->exception->severity,wand->exception->reason),MaxTextExtent);
304 if (wand->exception->description != (char *) NULL)
306 (void) ConcatenateMagickString(description," (",MaxTextExtent);
307 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
308 wand->exception->severity,wand->exception->description),MaxTextExtent);
309 (void) ConcatenateMagickString(description,")",MaxTextExtent);
315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
319 % M a g i c k G e t E x c e p t i o n T y p e %
323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
325 % MagickGetExceptionType() returns the exception type associated with the
326 % wand. If no exception has occurred, UndefinedExceptionType is returned.
328 % The format of the MagickGetExceptionType method is:
330 % ExceptionType MagickGetExceptionType(const MagickWand *wand)
332 % A description of each parameter follows:
334 % o wand: the magick wand.
337 WandExport ExceptionType MagickGetExceptionType(const MagickWand *wand)
339 assert(wand != (MagickWand *) NULL);
340 assert(wand->signature == WandSignature);
341 if (wand->debug != MagickFalse)
342 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
343 return(wand->exception->severity);
347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
351 % M a g i c k G e t I t e r a t o r I n d e x %
355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
357 % MagickGetIteratorIndex() returns the position of the iterator in the image
360 % The format of the MagickGetIteratorIndex method is:
362 % ssize_t MagickGetIteratorIndex(MagickWand *wand)
364 % A description of each parameter follows:
366 % o wand: the magick wand.
369 WandExport ssize_t MagickGetIteratorIndex(MagickWand *wand)
371 assert(wand != (MagickWand *) NULL);
372 assert(wand->signature == WandSignature);
373 if (wand->debug != MagickFalse)
374 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
375 if (wand->images == (Image *) NULL)
377 (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
378 "ContainsNoIterators","`%s'",wand->name);
381 return(GetImageIndexInList(wand->images));
385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
389 % M a g i c k Q u e r y C o n f i g u r e O p t i o n %
393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
395 % MagickQueryConfigureOption() returns the value associated with the specified
398 % The format of the MagickQueryConfigureOption function is:
400 % char *MagickQueryConfigureOption(const char *option)
402 % A description of each parameter follows:
404 % o option: the option name.
407 WandExport char *MagickQueryConfigureOption(const char *option)
421 exception=AcquireExceptionInfo();
422 configure_info=GetConfigureInfoList(option,&number_options,exception);
423 exception=DestroyExceptionInfo(exception);
424 if (configure_info == (const ConfigureInfo **) NULL)
425 return((char *) NULL);
426 value=AcquireString(configure_info[0]->value);
427 configure_info=(const ConfigureInfo **)
428 RelinquishMagickMemory((void *) configure_info);
433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
437 % M a g i c k Q u e r y C o n f i g u r e O p t i o n s %
441 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
443 % MagickQueryConfigureOptions() returns any configure options that match the
444 % specified pattern (e.g. "*" for all). Options include NAME, VERSION,
447 % The format of the MagickQueryConfigureOptions function is:
449 % char **MagickQueryConfigureOptions(const char *pattern,
450 % size_t *number_options)
452 % A description of each parameter follows:
454 % o pattern: Specifies a pointer to a text string containing a pattern.
456 % o number_options: Returns the number of configure options in the list.
460 WandExport char **MagickQueryConfigureOptions(const char *pattern,
461 size_t *number_options)
469 exception=AcquireExceptionInfo();
470 options=GetConfigureList(pattern,number_options,exception);
471 exception=DestroyExceptionInfo(exception);
476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
480 % M a g i c k Q u e r y F o n t M e t r i c s %
484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
486 % MagickQueryFontMetrics() returns a 13 element array representing the
487 % following font metrics:
489 % Element Description
490 % -------------------------------------------------
497 % 6 maximum horizontal advance
501 % 10 bounding box: y2
505 % The format of the MagickQueryFontMetrics method is:
507 % double *MagickQueryFontMetrics(MagickWand *wand,
508 % const DrawingWand *drawing_wand,const char *text)
510 % A description of each parameter follows:
512 % o wand: the Magick wand.
514 % o drawing_wand: the drawing wand.
519 WandExport double *MagickQueryFontMetrics(MagickWand *wand,
520 const DrawingWand *drawing_wand,const char *text)
534 assert(wand != (MagickWand *) NULL);
535 assert(wand->signature == WandSignature);
536 if (wand->debug != MagickFalse)
537 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
538 assert(drawing_wand != (const DrawingWand *) NULL);
539 if (wand->images == (Image *) NULL)
541 (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
542 "ContainsNoImages","`%s'",wand->name);
543 return((double *) NULL);
545 font_metrics=(double *) AcquireQuantumMemory(13UL,sizeof(*font_metrics));
546 if (font_metrics == (double *) NULL)
547 return((double *) NULL);
548 draw_info=PeekDrawingWand(drawing_wand);
549 if (draw_info == (DrawInfo *) NULL)
551 font_metrics=(double *) RelinquishMagickMemory(font_metrics);
552 return((double *) NULL);
554 (void) CloneString(&draw_info->text,text);
555 (void) ResetMagickMemory(&metrics,0,sizeof(metrics));
556 status=GetTypeMetrics(wand->images,draw_info,&metrics);
557 draw_info=DestroyDrawInfo(draw_info);
558 if (status == MagickFalse)
560 InheritException(wand->exception,&wand->images->exception);
561 font_metrics=(double *) RelinquishMagickMemory(font_metrics);
562 return((double *) NULL);
564 font_metrics[0]=metrics.pixels_per_em.x;
565 font_metrics[1]=metrics.pixels_per_em.y;
566 font_metrics[2]=metrics.ascent;
567 font_metrics[3]=metrics.descent;
568 font_metrics[4]=metrics.width;
569 font_metrics[5]=metrics.height;
570 font_metrics[6]=metrics.max_advance;
571 font_metrics[7]=metrics.bounds.x1;
572 font_metrics[8]=metrics.bounds.y1;
573 font_metrics[9]=metrics.bounds.x2;
574 font_metrics[10]=metrics.bounds.y2;
575 font_metrics[11]=metrics.origin.x;
576 font_metrics[12]=metrics.origin.y;
577 return(font_metrics);
581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
585 % M a g i c k Q u e r y M u l t i l i n e F o n t M e t r i c s %
589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
591 % MagickQueryMultilineFontMetrics() returns a 13 element array representing the
592 % following font metrics:
594 % Element Description
595 % -------------------------------------------------
602 % 6 maximum horizontal advance
606 % 10 bounding box: y2
610 % This method is like MagickQueryFontMetrics() but it returns the maximum text
611 % width and height for multiple lines of text.
613 % The format of the MagickQueryFontMetrics method is:
615 % double *MagickQueryMultilineFontMetrics(MagickWand *wand,
616 % const DrawingWand *drawing_wand,const char *text)
618 % A description of each parameter follows:
620 % o wand: the Magick wand.
622 % o drawing_wand: the drawing wand.
627 WandExport double *MagickQueryMultilineFontMetrics(MagickWand *wand,
628 const DrawingWand *drawing_wand,const char *text)
642 assert(wand != (MagickWand *) NULL);
643 assert(wand->signature == WandSignature);
644 if (wand->debug != MagickFalse)
645 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
646 assert(drawing_wand != (const DrawingWand *) NULL);
647 if (wand->images == (Image *) NULL)
649 (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
650 "ContainsNoImages","`%s'",wand->name);
651 return((double *) NULL);
653 font_metrics=(double *) AcquireQuantumMemory(13UL,sizeof(*font_metrics));
654 if (font_metrics == (double *) NULL)
655 return((double *) NULL);
656 draw_info=PeekDrawingWand(drawing_wand);
657 if (draw_info == (DrawInfo *) NULL)
659 font_metrics=(double *) RelinquishMagickMemory(font_metrics);
660 return((double *) NULL);
662 (void) CloneString(&draw_info->text,text);
663 (void) ResetMagickMemory(&metrics,0,sizeof(metrics));
664 status=GetMultilineTypeMetrics(wand->images,draw_info,&metrics);
665 draw_info=DestroyDrawInfo(draw_info);
666 if (status == MagickFalse)
668 InheritException(wand->exception,&wand->images->exception);
669 font_metrics=(double *) RelinquishMagickMemory(font_metrics);
670 return((double *) NULL);
672 font_metrics[0]=metrics.pixels_per_em.x;
673 font_metrics[1]=metrics.pixels_per_em.y;
674 font_metrics[2]=metrics.ascent;
675 font_metrics[3]=metrics.descent;
676 font_metrics[4]=metrics.width;
677 font_metrics[5]=metrics.height;
678 font_metrics[6]=metrics.max_advance;
679 font_metrics[7]=metrics.bounds.x1;
680 font_metrics[8]=metrics.bounds.y1;
681 font_metrics[9]=metrics.bounds.x2;
682 font_metrics[10]=metrics.bounds.y2;
683 font_metrics[11]=metrics.origin.x;
684 font_metrics[12]=metrics.origin.y;
685 return(font_metrics);
689 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
693 % M a g i c k Q u e r y F o n t s %
697 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
699 % MagickQueryFonts() returns any font that match the specified pattern (e.g.
702 % The format of the MagickQueryFonts function is:
704 % char **MagickQueryFonts(const char *pattern,size_t *number_fonts)
706 % A description of each parameter follows:
708 % o pattern: Specifies a pointer to a text string containing a pattern.
710 % o number_fonts: Returns the number of fonts in the list.
714 WandExport char **MagickQueryFonts(const char *pattern,
715 size_t *number_fonts)
723 exception=AcquireExceptionInfo();
724 fonts=GetTypeList(pattern,number_fonts,exception);
725 exception=DestroyExceptionInfo(exception);
730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
734 % M a g i c k Q u e r y F o r m a t s %
738 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
740 % MagickQueryFonts() returns any image formats that match the specified
741 % pattern (e.g. "*" for all).
743 % The format of the MagickQueryFonts function is:
745 % char **MagickQueryFonts(const char *pattern,
746 % size_t *number_formats)
748 % A description of each parameter follows:
750 % o pattern: Specifies a pointer to a text string containing a pattern.
752 % o number_formats: This integer returns the number of image formats in the
756 WandExport char **MagickQueryFormats(const char *pattern,
757 size_t *number_formats)
765 exception=AcquireExceptionInfo();
766 formats=GetMagickList(pattern,number_formats,exception);
767 exception=DestroyExceptionInfo(exception);
772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
776 % M a g i c k R e l i n q u i s h M e m o r y %
780 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
782 % MagickRelinquishMemory() relinquishes memory resources returned by such
783 % methods as MagickIdentifyImage(), MagickGetException(), etc.
785 % The format of the MagickRelinquishMemory method is:
787 % void *MagickRelinquishMemory(void *resource)
789 % A description of each parameter follows:
791 % o resource: Relinquish the memory associated with this resource.
794 WandExport void *MagickRelinquishMemory(void *memory)
796 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
797 return(RelinquishMagickMemory(memory));
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
805 % M a g i c k R e s e t I t e r a t o r %
809 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
811 % MagickResetIterator() resets the wand iterator. Use it in conjunction
812 % with MagickNextImage() to iterate over all the images in a wand
815 % The format of the MagickResetIterator method is:
817 % void MagickResetIterator(MagickWand *wand)
819 % A description of each parameter follows:
821 % o wand: the magick wand.
824 WandExport void MagickResetIterator(MagickWand *wand)
826 assert(wand != (MagickWand *) NULL);
827 assert(wand->signature == WandSignature);
828 if (wand->debug != MagickFalse)
829 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
830 wand->active=MagickFalse;
831 wand->pend=MagickTrue;
832 wand->images=GetFirstImageInList(wand->images);
836 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
840 % M a g i c k S e t F i r s t I t e r a t o r %
844 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
846 % MagickSetFirstIterator() sets the wand iterator to the first image.
848 % The format of the MagickSetFirstIterator method is:
850 % void MagickSetFirstIterator(MagickWand *wand)
852 % A description of each parameter follows:
854 % o wand: the magick wand.
857 WandExport void MagickSetFirstIterator(MagickWand *wand)
859 assert(wand != (MagickWand *) NULL);
860 assert(wand->signature == WandSignature);
861 if (wand->debug != MagickFalse)
862 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
863 wand->active=MagickTrue;
864 wand->pend=MagickFalse;
865 wand->images=GetFirstImageInList(wand->images);
869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
873 % M a g i c k S e t I t e r a t o r I n d e x %
877 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
879 % MagickSetIteratorIndex() set the iterator to the position in the image list
880 % specified with the index parameter.
882 % The format of the MagickSetIteratorIndex method is:
884 % MagickBooleanType MagickSetIteratorIndex(MagickWand *wand,
885 % const ssize_t index)
887 % A description of each parameter follows:
889 % o wand: the magick wand.
891 % o index: the scene number.
894 WandExport MagickBooleanType MagickSetIteratorIndex(MagickWand *wand,
900 assert(wand != (MagickWand *) NULL);
901 assert(wand->signature == WandSignature);
902 if (wand->debug != MagickFalse)
903 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
904 if (wand->images == (Image *) NULL)
906 image=GetImageFromList(wand->images,index);
907 if (image == (Image *) NULL)
909 InheritException(wand->exception,&wand->images->exception);
912 wand->active=MagickTrue;
913 wand->pend=MagickFalse;
918 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
922 % M a g i c k S e t L a s t I t e r a t o r %
926 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
928 % MagickSetLastIterator() sets the wand iterator to the last image.
930 % The format of the MagickSetLastIterator method is:
932 % void MagickSetLastIterator(MagickWand *wand)
934 % A description of each parameter follows:
936 % o wand: the magick wand.
939 WandExport void MagickSetLastIterator(MagickWand *wand)
941 assert(wand != (MagickWand *) NULL);
942 assert(wand->signature == WandSignature);
943 if (wand->debug != MagickFalse)
944 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
945 wand->active=MagickFalse;
946 wand->pend=MagickTrue;
947 wand->images=GetLastImageInList(wand->images);
951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
955 % M a g i c k W a n d G e n e s i s %
959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
961 % MagickWandGenesis() initializes the MagickWand environment.
963 % The format of the MagickWandGenesis method is:
965 % void MagickWandGenesis(void)
968 WandExport void MagickWandGenesis(void)
970 if (IsMagickInstantiated() == MagickFalse)
971 MagickCoreGenesis((char *) NULL,MagickFalse);
975 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
979 % M a g i c k W a n d T e r m i n u s %
983 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
985 % MagickWandTerminus() terminates the MagickWand environment.
987 % The format of the MaickWandTerminus method is:
989 % void MagickWandTerminus(void)
992 WandExport void MagickWandTerminus(void)
995 MagickCoreTerminus();
999 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1003 % N e w M a g i c k W a n d %
1007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1009 % NewMagickWand() returns a wand required for all other methods in the API.
1011 % The format of the NewMagickWand method is:
1013 % MagickWand *NewMagickWand(void)
1016 WandExport MagickWand *NewMagickWand(void)
1027 depth=MAGICKCORE_QUANTUM_DEPTH;
1028 quantum=GetMagickQuantumDepth(&depth);
1029 if (depth != MAGICKCORE_QUANTUM_DEPTH)
1030 ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
1031 wand=(MagickWand *) AcquireAlignedMemory(1,sizeof(*wand));
1032 if (wand == (MagickWand *) NULL)
1033 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
1034 GetExceptionMessage(errno));
1035 (void) ResetMagickMemory(wand,0,sizeof(*wand));
1036 wand->id=AcquireWandId();
1037 (void) FormatMagickString(wand->name,MaxTextExtent,"%s-%.20g",MagickWandId,
1039 wand->exception=AcquireExceptionInfo();
1040 wand->image_info=AcquireImageInfo();
1041 wand->quantize_info=CloneQuantizeInfo((QuantizeInfo *) NULL);
1042 wand->images=NewImageList();
1043 wand->debug=IsEventLogging();
1044 if (wand->debug != MagickFalse)
1045 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1046 wand->signature=WandSignature;
1051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1055 % N e w M a g i c k W a n d F r o m I m a g e %
1059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1061 % NewMagickWandFromImage() returns a wand with an image.
1063 % The format of the NewMagickWandFromImage method is:
1065 % MagickWand *NewMagickWandFromImage(const Image *image)
1067 % A description of each parameter follows:
1069 % o image: the image.
1072 WandExport MagickWand *NewMagickWandFromImage(const Image *image)
1077 wand=NewMagickWand();
1078 wand->images=CloneImage(image,0,0,MagickTrue,wand->exception);