2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % DDDD EEEEE PPPP RRRR EEEEE CCCC AAA TTTTT EEEEE %
7 % D D E P P R R E C A A T E %
8 % D D EEE PPPPP RRRR EEE C AAAAA T EEE %
9 % D D E P R R E C A A T E %
10 % DDDD EEEEE P R R EEEEE CCCC A A T EEEEE %
13 % MagickWand Deprecated Methods %
20 % Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "wand/studio.h"
44 #include "wand/MagickWand.h"
45 #include "wand/magick-wand-private.h"
46 #include "wand/wand.h"
47 #include "magick/monitor-private.h"
48 #include "magick/thread-private.h"
53 #define PixelViewId "PixelView"
54 #define ThrowWandException(severity,tag,context) \
56 (void) ThrowMagickException(wand->exception,GetMagickModule(),severity, \
57 tag,"`%s'",context); \
58 return(MagickFalse); \
97 #if !defined(MAGICKCORE_EXCLUDE_DEPRECATED)
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 % M a g i c k A v e r a g e I m a g e s %
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 % MagickAverageImages() average a set of images.
112 % The format of the MagickAverageImages method is:
114 % MagickWand *MagickAverageImages(MagickWand *wand)
116 % A description of each parameter follows:
118 % o wand: the magick wand.
122 static MagickWand *CloneMagickWandFromImages(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=images;
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;
152 WandExport MagickWand *MagickAverageImages(MagickWand *wand)
157 assert(wand != (MagickWand *) NULL);
158 assert(wand->signature == WandSignature);
159 if (wand->debug != MagickFalse)
160 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
161 if (wand->images == (Image *) NULL)
162 return((MagickWand *) NULL);
163 average_image=EvaluateImages(wand->images,MeanEvaluateOperator,
165 if (average_image == (Image *) NULL)
166 return((MagickWand *) NULL);
167 return(CloneMagickWandFromImages(wand,average_image));
171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175 % C l o n e P i x e l V i e w %
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 % ClonePixelView() makes a copy of the specified pixel view.
183 % The format of the ClonePixelView method is:
185 % PixelView *ClonePixelView(const PixelView *pixel_view)
187 % A description of each parameter follows:
189 % o pixel_view: the pixel view.
192 WandExport PixelView *ClonePixelView(const PixelView *pixel_view)
200 assert(pixel_view != (PixelView *) NULL);
201 assert(pixel_view->signature == WandSignature);
202 if (pixel_view->debug != MagickFalse)
203 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",pixel_view->name);
204 clone_view=(PixelView *) AcquireAlignedMemory(1,sizeof(*clone_view));
205 if (clone_view == (PixelView *) NULL)
206 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
208 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
209 clone_view->id=AcquireWandId();
210 (void) FormatMagickString(clone_view->name,MaxTextExtent,"%s-%.20g",
211 PixelViewId,(double) clone_view->id);
212 clone_view->exception=AcquireExceptionInfo();
213 InheritException(clone_view->exception,pixel_view->exception);
214 clone_view->view=CloneCacheView(pixel_view->view);
215 clone_view->region=pixel_view->region;
216 clone_view->number_threads=pixel_view->number_threads;
217 for (i=0; i < (ssize_t) pixel_view->number_threads; i++)
218 clone_view->pixel_wands[i]=ClonePixelWands((const PixelWand **)
219 pixel_view->pixel_wands[i],pixel_view->region.width);
220 clone_view->debug=pixel_view->debug;
221 if (clone_view->debug != MagickFalse)
222 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_view->name);
223 clone_view->signature=WandSignature;
228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232 % D e s t r o y P i x e l V i e w %
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 % DestroyPixelView() deallocates memory associated with a pixel view.
240 % The format of the DestroyPixelView method is:
242 % PixelView *DestroyPixelView(PixelView *pixel_view,
243 % const size_t number_wands,const size_t number_threads)
245 % A description of each parameter follows:
247 % o pixel_view: the pixel view.
249 % o number_wand: the number of pixel wands.
251 % o number_threads: number of threads.
255 static PixelWand ***DestroyPixelsThreadSet(PixelWand ***pixel_wands,
256 const size_t number_wands,const size_t number_threads)
261 assert(pixel_wands != (PixelWand ***) NULL);
262 for (i=0; i < (ssize_t) number_threads; i++)
263 if (pixel_wands[i] != (PixelWand **) NULL)
264 pixel_wands[i]=DestroyPixelWands(pixel_wands[i],number_wands);
265 pixel_wands=(PixelWand ***) RelinquishAlignedMemory(pixel_wands);
269 WandExport PixelView *DestroyPixelView(PixelView *pixel_view)
271 assert(pixel_view != (PixelView *) NULL);
272 assert(pixel_view->signature == WandSignature);
273 pixel_view->pixel_wands=DestroyPixelsThreadSet(pixel_view->pixel_wands,
274 pixel_view->region.width,pixel_view->number_threads);
275 pixel_view->view=DestroyCacheView(pixel_view->view);
276 pixel_view->exception=DestroyExceptionInfo(pixel_view->exception);
277 pixel_view->signature=(~WandSignature);
278 RelinquishWandId(pixel_view->id);
279 pixel_view=(PixelView *) RelinquishMagickMemory(pixel_view);
284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288 % D u p l e x T r a n s f e r P i x e l V i e w I t e r a t o r %
292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
294 % DuplexTransferPixelViewIterator() iterates over three pixel views in
295 % parallel and calls your transfer method for each scanline of the view. The
296 % source and duplex pixel region is not confined to the image canvas-- that is
297 % you can include negative offsets or widths or heights that exceed the image
298 % dimension. However, the destination pixel view is confined to the image
299 % canvas-- that is no negative offsets or widths or heights that exceed the
300 % image dimension are permitted.
304 % #pragma omp critical
306 % to define a section of code in your callback transfer method that must be
307 % executed by a single thread at a time.
309 % The format of the DuplexTransferPixelViewIterator method is:
311 % MagickBooleanType DuplexTransferPixelViewIterator(PixelView *source,
312 % PixelView *duplex,PixelView *destination,
313 % DuplexTransferPixelViewMethod transfer,void *context)
315 % A description of each parameter follows:
317 % o source: the source pixel view.
319 % o duplex: the duplex pixel view.
321 % o destination: the destination pixel view.
323 % o transfer: the transfer callback method.
325 % o context: the user defined context.
328 WandExport MagickBooleanType DuplexTransferPixelViewIterator(
329 PixelView *source,PixelView *duplex,PixelView *destination,
330 DuplexTransferPixelViewMethod transfer,void *context)
332 #define DuplexTransferPixelViewTag "PixelView/DuplexTransfer"
351 assert(source != (PixelView *) NULL);
352 assert(source->signature == WandSignature);
353 if (transfer == (DuplexTransferPixelViewMethod) NULL)
355 source_image=source->wand->images;
356 duplex_image=duplex->wand->images;
357 destination_image=destination->wand->images;
358 if (SetImageStorageClass(destination_image,DirectClass) == MagickFalse)
362 exception=destination->exception;
363 #if defined(MAGICKCORE_OPENMP_SUPPORT)
364 #pragma omp parallel for schedule(static,1) shared(progress,status)
366 for (y=source->region.y; y < (ssize_t) source->region.height; y++)
371 register const IndexPacket
372 *restrict duplex_indexes,
375 register const PixelPacket
376 *restrict duplex_pixels,
380 *restrict destination_indexes;
387 *restrict destination_pixels;
389 if (status == MagickFalse)
391 id=GetOpenMPThreadId();
392 pixels=GetCacheViewVirtualPixels(source->view,source->region.x,y,
393 source->region.width,1,source->exception);
394 if (pixels == (const PixelPacket *) NULL)
399 indexes=GetCacheViewVirtualIndexQueue(source->view);
400 for (x=0; x < (ssize_t) source->region.width; x++)
401 PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);
402 if (source_image->colorspace == CMYKColorspace)
403 for (x=0; x < (ssize_t) source->region.width; x++)
404 PixelSetBlackQuantum(source->pixel_wands[id][x],indexes[x]);
405 if (source_image->storage_class == PseudoClass)
406 for (x=0; x < (ssize_t) source->region.width; x++)
407 PixelSetIndex(source->pixel_wands[id][x],indexes[x]);
408 duplex_pixels=GetCacheViewVirtualPixels(duplex->view,duplex->region.x,y,
409 duplex->region.width,1,duplex->exception);
410 if (duplex_pixels == (const PixelPacket *) NULL)
415 duplex_indexes=GetCacheViewVirtualIndexQueue(duplex->view);
416 for (x=0; x < (ssize_t) duplex->region.width; x++)
417 PixelSetQuantumColor(duplex->pixel_wands[id][x],duplex_pixels+x);
418 if (duplex_image->colorspace == CMYKColorspace)
419 for (x=0; x < (ssize_t) duplex->region.width; x++)
420 PixelSetBlackQuantum(duplex->pixel_wands[id][x],duplex_indexes[x]);
421 if (duplex_image->storage_class == PseudoClass)
422 for (x=0; x < (ssize_t) duplex->region.width; x++)
423 PixelSetIndex(duplex->pixel_wands[id][x],duplex_indexes[x]);
424 destination_pixels=GetCacheViewAuthenticPixels(destination->view,
425 destination->region.x,y,destination->region.width,1,exception);
426 if (destination_pixels == (PixelPacket *) NULL)
431 destination_indexes=GetCacheViewAuthenticIndexQueue(destination->view);
432 for (x=0; x < (ssize_t) destination->region.width; x++)
433 PixelSetQuantumColor(destination->pixel_wands[id][x],
434 destination_pixels+x);
435 if (destination_image->colorspace == CMYKColorspace)
436 for (x=0; x < (ssize_t) destination->region.width; x++)
437 PixelSetBlackQuantum(destination->pixel_wands[id][x],
438 destination_indexes[x]);
439 if (destination_image->storage_class == PseudoClass)
440 for (x=0; x < (ssize_t) destination->region.width; x++)
441 PixelSetIndex(destination->pixel_wands[id][x],destination_indexes[x]);
442 if (transfer(source,duplex,destination,context) == MagickFalse)
444 for (x=0; x < (ssize_t) destination->region.width; x++)
445 PixelGetQuantumColor(destination->pixel_wands[id][x],
446 destination_pixels+x);
447 if (destination_image->colorspace == CMYKColorspace)
448 for (x=0; x < (ssize_t) destination->region.width; x++)
449 destination_indexes[x]=PixelGetBlackQuantum(
450 destination->pixel_wands[id][x]);
451 sync=SyncCacheViewAuthenticPixels(destination->view,exception);
452 if (sync == MagickFalse)
454 InheritException(destination->exception,GetCacheViewException(
458 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
463 #if defined(MAGICKCORE_OPENMP_SUPPORT)
464 #pragma omp critical (MagickWand_DuplexTransferPixelViewIterator)
466 proceed=SetImageProgress(source_image,DuplexTransferPixelViewTag,
467 progress++,source->region.height);
468 if (proceed == MagickFalse)
476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
480 % G e t P i x e l V i e w E x c e p t i o n %
484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
486 % GetPixelViewException() returns the severity, reason, and description of any
487 % error that occurs when utilizing a pixel view.
489 % The format of the GetPixelViewException method is:
491 % char *GetPixelViewException(const PixelWand *pixel_view,
492 % ExceptionType *severity)
494 % A description of each parameter follows:
496 % o pixel_view: the pixel pixel_view.
498 % o severity: the severity of the error is returned here.
501 WandExport char *GetPixelViewException(const PixelView *pixel_view,
502 ExceptionType *severity)
507 assert(pixel_view != (const PixelView *) NULL);
508 assert(pixel_view->signature == WandSignature);
509 if (pixel_view->debug != MagickFalse)
510 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",pixel_view->name);
511 assert(severity != (ExceptionType *) NULL);
512 *severity=pixel_view->exception->severity;
513 description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent,
514 sizeof(*description));
515 if (description == (char *) NULL)
516 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
519 if (pixel_view->exception->reason != (char *) NULL)
520 (void) CopyMagickString(description,GetLocaleExceptionMessage(
521 pixel_view->exception->severity,pixel_view->exception->reason),
523 if (pixel_view->exception->description != (char *) NULL)
525 (void) ConcatenateMagickString(description," (",MaxTextExtent);
526 (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
527 pixel_view->exception->severity,pixel_view->exception->description),
529 (void) ConcatenateMagickString(description,")",MaxTextExtent);
535 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
539 % G e t P i x e l V i e w H e i g h t %
543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
545 % GetPixelViewHeight() returns the pixel view height.
547 % The format of the GetPixelViewHeight method is:
549 % size_t GetPixelViewHeight(const PixelView *pixel_view)
551 % A description of each parameter follows:
553 % o pixel_view: the pixel view.
556 WandExport size_t GetPixelViewHeight(const PixelView *pixel_view)
558 assert(pixel_view != (PixelView *) NULL);
559 assert(pixel_view->signature == WandSignature);
560 return(pixel_view->region.height);
564 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 % G e t P i x e l V i e w I t e r a t o r %
572 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
574 % GetPixelViewIterator() iterates over the pixel view in parallel and calls
575 % your get method for each scanline of the view. The pixel region is
576 % not confined to the image canvas-- that is you can include negative offsets
577 % or widths or heights that exceed the image dimension. Any updates to
578 % the pixels in your callback are ignored.
582 % #pragma omp critical
584 % to define a section of code in your callback get method that must be
585 % executed by a single thread at a time.
587 % The format of the GetPixelViewIterator method is:
589 % MagickBooleanType GetPixelViewIterator(PixelView *source,
590 % GetPixelViewMethod get,void *context)
592 % A description of each parameter follows:
594 % o source: the source pixel view.
596 % o get: the get callback method.
598 % o context: the user defined context.
601 WandExport MagickBooleanType GetPixelViewIterator(PixelView *source,
602 GetPixelViewMethod get,void *context)
604 #define GetPixelViewTag "PixelView/Get"
618 assert(source != (PixelView *) NULL);
619 assert(source->signature == WandSignature);
620 if (get == (GetPixelViewMethod) NULL)
622 source_image=source->wand->images;
625 #if defined(MAGICKCORE_OPENMP_SUPPORT)
626 #pragma omp parallel for schedule(static,1) shared(progress,status)
628 for (y=source->region.y; y < (ssize_t) source->region.height; y++)
630 register const IndexPacket
633 register const PixelPacket
640 if (status == MagickFalse)
642 id=GetOpenMPThreadId();
643 pixels=GetCacheViewVirtualPixels(source->view,source->region.x,y,
644 source->region.width,1,source->exception);
645 if (pixels == (const PixelPacket *) NULL)
650 indexes=GetCacheViewVirtualIndexQueue(source->view);
651 for (x=0; x < (ssize_t) source->region.width; x++)
652 PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);
653 if (source_image->colorspace == CMYKColorspace)
654 for (x=0; x < (ssize_t) source->region.width; x++)
655 PixelSetBlackQuantum(source->pixel_wands[id][x],indexes[x]);
656 if (source_image->storage_class == PseudoClass)
657 for (x=0; x < (ssize_t) source->region.width; x++)
658 PixelSetIndex(source->pixel_wands[id][x],indexes[x]);
659 if (get(source,context) == MagickFalse)
661 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
666 #if defined(MAGICKCORE_OPENMP_SUPPORT)
667 #pragma omp critical (MagickWand_GetPixelViewIterator)
669 proceed=SetImageProgress(source_image,GetPixelViewTag,progress++,
670 source->region.height);
671 if (proceed == MagickFalse)
679 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
683 % G e t P i x e l V i e w P i x e l s %
687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
689 % GetPixelViewPixels() returns the pixel view pixel_wands.
691 % The format of the GetPixelViewPixels method is:
693 % PixelWand *GetPixelViewPixels(const PixelView *pixel_view)
695 % A description of each parameter follows:
697 % o pixel_view: the pixel view.
700 WandExport PixelWand **GetPixelViewPixels(const PixelView *pixel_view)
705 assert(pixel_view != (PixelView *) NULL);
706 assert(pixel_view->signature == WandSignature);
707 id=GetOpenMPThreadId();
708 return(pixel_view->pixel_wands[id]);
712 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
716 % G e t P i x e l V i e w W a n d %
720 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
722 % GetPixelViewWand() returns the magick wand associated with the pixel view.
724 % The format of the GetPixelViewWand method is:
726 % MagickWand *GetPixelViewWand(const PixelView *pixel_view)
728 % A description of each parameter follows:
730 % o pixel_view: the pixel view.
733 WandExport MagickWand *GetPixelViewWand(const PixelView *pixel_view)
735 assert(pixel_view != (PixelView *) NULL);
736 assert(pixel_view->signature == WandSignature);
737 return(pixel_view->wand);
741 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
745 % G e t P i x e l V i e w W i d t h %
749 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
751 % GetPixelViewWidth() returns the pixel view width.
753 % The format of the GetPixelViewWidth method is:
755 % size_t GetPixelViewWidth(const PixelView *pixel_view)
757 % A description of each parameter follows:
759 % o pixel_view: the pixel view.
762 WandExport size_t GetPixelViewWidth(const PixelView *pixel_view)
764 assert(pixel_view != (PixelView *) NULL);
765 assert(pixel_view->signature == WandSignature);
766 return(pixel_view->region.width);
770 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
774 % G e t P i x e l V i e w X %
778 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
780 % GetPixelViewX() returns the pixel view x offset.
782 % The format of the GetPixelViewX method is:
784 % ssize_t GetPixelViewX(const PixelView *pixel_view)
786 % A description of each parameter follows:
788 % o pixel_view: the pixel view.
791 WandExport ssize_t GetPixelViewX(const PixelView *pixel_view)
793 assert(pixel_view != (PixelView *) NULL);
794 assert(pixel_view->signature == WandSignature);
795 return(pixel_view->region.x);
799 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803 % G e t P i x e l V i e w Y %
807 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
809 % GetPixelViewY() returns the pixel view y offset.
811 % The format of the GetPixelViewY method is:
813 % ssize_t GetPixelViewY(const PixelView *pixel_view)
815 % A description of each parameter follows:
817 % o pixel_view: the pixel view.
820 WandExport ssize_t GetPixelViewY(const PixelView *pixel_view)
822 assert(pixel_view != (PixelView *) NULL);
823 assert(pixel_view->signature == WandSignature);
824 return(pixel_view->region.y);
828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 % I s P i x e l V i e w %
836 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
838 % IsPixelView() returns MagickTrue if the the parameter is verified as a pixel
841 % The format of the IsPixelView method is:
843 % MagickBooleanType IsPixelView(const PixelView *pixel_view)
845 % A description of each parameter follows:
847 % o pixel_view: the pixel view.
850 WandExport MagickBooleanType IsPixelView(const PixelView *pixel_view)
855 if (pixel_view == (const PixelView *) NULL)
857 if (pixel_view->signature != WandSignature)
859 length=strlen(PixelViewId);
860 if (LocaleNCompare(pixel_view->name,PixelViewId,length) != 0)
866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
870 % M a g i c k C l i p P a t h I m a g e %
874 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
876 % MagickClipPathImage() clips along the named paths from the 8BIM profile, if
877 % present. Later operations take effect inside the path. Id may be a number
878 % if preceded with #, to work on a numbered path, e.g., "#1" to use the first
881 % The format of the MagickClipPathImage method is:
883 % MagickBooleanType MagickClipPathImage(MagickWand *wand,
884 % const char *pathname,const MagickBooleanType inside)
886 % A description of each parameter follows:
888 % o wand: the magick wand.
890 % o pathname: name of clipping path resource. If name is preceded by #, use
891 % clipping path numbered by name.
893 % o inside: if non-zero, later operations take effect inside clipping path.
894 % Otherwise later operations take effect outside clipping path.
897 WandExport MagickBooleanType MagickClipPathImage(MagickWand *wand,
898 const char *pathname,const MagickBooleanType inside)
900 return(MagickClipImagePath(wand,pathname,inside));
903 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
907 % D r a w G e t F i l l A l p h a %
911 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
913 % DrawGetFillAlpha() returns the alpha used when drawing using the fill
914 % color or fill texture. Fully opaque is 1.0.
916 % The format of the DrawGetFillAlpha method is:
918 % double DrawGetFillAlpha(const DrawingWand *wand)
920 % A description of each parameter follows:
922 % o wand: the drawing wand.
925 WandExport double DrawGetFillAlpha(const DrawingWand *wand)
927 return(DrawGetFillOpacity(wand));
931 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
935 % D r a w G e t S t r o k e A l p h a %
939 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
941 % DrawGetStrokeAlpha() returns the alpha of stroked object outlines.
943 % The format of the DrawGetStrokeAlpha method is:
945 % double DrawGetStrokeAlpha(const DrawingWand *wand)
947 % A description of each parameter follows:
949 % o wand: the drawing wand.
951 WandExport double DrawGetStrokeAlpha(const DrawingWand *wand)
953 return(DrawGetStrokeOpacity(wand));
957 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
961 % D r a w P e e k G r a p h i c W a n d %
965 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
967 % DrawPeekGraphicWand() returns the current drawing wand.
969 % The format of the PeekDrawingWand method is:
971 % DrawInfo *DrawPeekGraphicWand(const DrawingWand *wand)
973 % A description of each parameter follows:
975 % o wand: the drawing wand.
978 WandExport DrawInfo *DrawPeekGraphicWand(const DrawingWand *wand)
980 return(PeekDrawingWand(wand));
984 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
988 % D r a w P o p G r a p h i c C o n t e x t %
992 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
994 % DrawPopGraphicContext() destroys the current drawing wand and returns to the
995 % previously pushed drawing wand. Multiple drawing wands may exist. It is an
996 % error to attempt to pop more drawing wands than have been pushed, and it is
997 % proper form to pop all drawing wands which have been pushed.
999 % The format of the DrawPopGraphicContext method is:
1001 % MagickBooleanType DrawPopGraphicContext(DrawingWand *wand)
1003 % A description of each parameter follows:
1005 % o wand: the drawing wand.
1008 WandExport void DrawPopGraphicContext(DrawingWand *wand)
1010 (void) PopDrawingWand(wand);
1014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1018 % D r a w P u s h G r a p h i c C o n t e x t %
1022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1024 % DrawPushGraphicContext() clones the current drawing wand to create a new
1025 % drawing wand. The original drawing wand(s) may be returned to by
1026 % invoking PopDrawingWand(). The drawing wands are stored on a drawing wand
1027 % stack. For every Pop there must have already been an equivalent Push.
1029 % The format of the DrawPushGraphicContext method is:
1031 % MagickBooleanType DrawPushGraphicContext(DrawingWand *wand)
1033 % A description of each parameter follows:
1035 % o wand: the drawing wand.
1038 WandExport void DrawPushGraphicContext(DrawingWand *wand)
1040 (void) PushDrawingWand(wand);
1044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1048 % D r a w S e t F i l l A l p h a %
1052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1054 % DrawSetFillAlpha() sets the alpha to use when drawing using the fill
1055 % color or fill texture. Fully opaque is 1.0.
1057 % The format of the DrawSetFillAlpha method is:
1059 % void DrawSetFillAlpha(DrawingWand *wand,const double fill_alpha)
1061 % A description of each parameter follows:
1063 % o wand: the drawing wand.
1065 % o fill_alpha: fill alpha
1068 WandExport void DrawSetFillAlpha(DrawingWand *wand,const double fill_alpha)
1070 DrawSetFillOpacity(wand,fill_alpha);
1074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1078 % D r a w S e t S t r o k e A l p h a %
1082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1084 % DrawSetStrokeAlpha() specifies the alpha of stroked object outlines.
1086 % The format of the DrawSetStrokeAlpha method is:
1088 % void DrawSetStrokeAlpha(DrawingWand *wand,const double stroke_alpha)
1090 % A description of each parameter follows:
1092 % o wand: the drawing wand.
1094 % o stroke_alpha: stroke alpha. The value 1.0 is opaque.
1097 WandExport void DrawSetStrokeAlpha(DrawingWand *wand,const double stroke_alpha)
1099 DrawSetStrokeOpacity(wand,stroke_alpha);
1103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1107 % M a g i c k C o l o r F l o o d f i l l I m a g e %
1111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1113 % MagickColorFloodfillImage() changes the color value of any pixel that matches
1114 % target and is an immediate neighbor. If the method FillToBorderMethod is
1115 % specified, the color value is changed for any neighbor pixel that does not
1116 % match the bordercolor member of image.
1118 % The format of the MagickColorFloodfillImage method is:
1120 % MagickBooleanType MagickColorFloodfillImage(MagickWand *wand,
1121 % const PixelWand *fill,const double fuzz,const PixelWand *bordercolor,
1122 % const ssize_t x,const ssize_t y)
1124 % A description of each parameter follows:
1126 % o wand: the magick wand.
1128 % o fill: the floodfill color pixel wand.
1130 % o fuzz: By default target must match a particular pixel color
1131 % exactly. However, in many cases two colors may differ by a small amount.
1132 % The fuzz member of image defines how much tolerance is acceptable to
1133 % consider two colors as the same. For example, set fuzz to 10 and the
1134 % color red at intensities of 100 and 102 respectively are now interpreted
1135 % as the same color for the purposes of the floodfill.
1137 % o bordercolor: the border color pixel wand.
1139 % o x,y: the starting location of the operation.
1142 WandExport MagickBooleanType MagickColorFloodfillImage(MagickWand *wand,
1143 const PixelWand *fill,const double fuzz,const PixelWand *bordercolor,
1144 const ssize_t x,const ssize_t y)
1155 assert(wand != (MagickWand *) NULL);
1156 assert(wand->signature == WandSignature);
1157 if (wand->debug != MagickFalse)
1158 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1159 if (wand->images == (Image *) NULL)
1160 ThrowWandException(WandError,"ContainsNoImages",wand->name);
1161 draw_info=CloneDrawInfo(wand->image_info,(DrawInfo *) NULL);
1162 PixelGetQuantumColor(fill,&draw_info->fill);
1163 (void) GetOneVirtualPixel(wand->images,x % wand->images->columns,
1164 y % wand->images->rows,&target,wand->exception);
1165 if (bordercolor != (PixelWand *) NULL)
1166 PixelGetQuantumColor(bordercolor,&target);
1167 wand->images->fuzz=fuzz;
1168 status=ColorFloodfillImage(wand->images,draw_info,target,x,y,
1169 bordercolor != (PixelWand *) NULL ? FillToBorderMethod : FloodfillMethod);
1170 if (status == MagickFalse)
1171 InheritException(wand->exception,&wand->images->exception);
1172 draw_info=DestroyDrawInfo(draw_info);
1177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1181 % M a g i c k D e s c r i b e I m a g e %
1185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1187 % MagickDescribeImage() identifies an image by printing its attributes to the
1188 % file. Attributes include the image width, height, size, and others.
1190 % The format of the MagickDescribeImage method is:
1192 % const char *MagickDescribeImage(MagickWand *wand)
1194 % A description of each parameter follows:
1196 % o wand: the magick wand.
1199 WandExport char *MagickDescribeImage(MagickWand *wand)
1201 return(MagickIdentifyImage(wand));
1205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1209 % M a g i c k F l a t t e n I m a g e s %
1213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1215 % MagickFlattenImages() merges a sequence of images. This useful for
1216 % combining Photoshop layers into a single image.
1218 % The format of the MagickFlattenImages method is:
1220 % MagickWand *MagickFlattenImages(MagickWand *wand)
1222 % A description of each parameter follows:
1224 % o wand: the magick wand.
1227 WandExport MagickWand *MagickFlattenImages(MagickWand *wand)
1232 assert(wand != (MagickWand *) NULL);
1233 assert(wand->signature == WandSignature);
1234 if (wand->debug != MagickFalse)
1235 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1236 if (wand->images == (Image *) NULL)
1237 return((MagickWand *) NULL);
1238 flatten_image=FlattenImages(wand->images,wand->exception);
1239 if (flatten_image == (Image *) NULL)
1240 return((MagickWand *) NULL);
1241 return(CloneMagickWandFromImages(wand,flatten_image));
1245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1249 % M a g i c k G e t I m a g e A t t r i b u t e %
1253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1255 % MagickGetImageAttribute() returns a value associated with the specified
1256 % property. Use MagickRelinquishMemory() to free the value when you are
1259 % The format of the MagickGetImageAttribute method is:
1261 % char *MagickGetImageAttribute(MagickWand *wand,const char *property)
1263 % A description of each parameter follows:
1265 % o wand: the magick wand.
1267 % o property: the property.
1270 WandExport char *MagickGetImageAttribute(MagickWand *wand,const char *property)
1272 return(MagickGetImageProperty(wand,property));
1276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1280 + M a g i c k G e t I m a g e I n d e x %
1284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1286 % MagickGetImageIndex() returns the index of the current image.
1288 % The format of the MagickGetImageIndex method is:
1290 % ssize_t MagickGetImageIndex(MagickWand *wand)
1292 % A description of each parameter follows:
1294 % o wand: the magick wand.
1297 WandExport ssize_t MagickGetImageIndex(MagickWand *wand)
1299 return(MagickGetIteratorIndex(wand));
1303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1307 + M a g i c k G e t I m a g e C h a n n e l E x t r e m a %
1311 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1313 % MagickGetImageChannelExtrema() gets the extrema for one or more image
1316 % The format of the MagickGetImageChannelExtrema method is:
1318 % MagickBooleanType MagickGetImageChannelExtrema(MagickWand *wand,
1319 % const ChannelType channel,size_t *minima,size_t *maxima)
1321 % A description of each parameter follows:
1323 % o wand: the magick wand.
1325 % o channel: the image channel(s).
1327 % o minima: The minimum pixel value for the specified channel(s).
1329 % o maxima: The maximum pixel value for the specified channel(s).
1332 WandExport MagickBooleanType MagickGetImageChannelExtrema(MagickWand *wand,
1333 const ChannelType channel,size_t *minima,size_t *maxima)
1338 assert(wand != (MagickWand *) NULL);
1339 assert(wand->signature == WandSignature);
1340 if (wand->debug != MagickFalse)
1341 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1342 if (wand->images == (Image *) NULL)
1343 ThrowWandException(WandError,"ContainsNoImages",wand->name);
1344 status=GetImageChannelExtrema(wand->images,channel,minima,maxima,
1350 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1354 + M a g i c k G e t I m a g e E x t r e m a %
1358 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1360 % MagickGetImageExtrema() gets the extrema for the image.
1362 % The format of the MagickGetImageExtrema method is:
1364 % MagickBooleanType MagickGetImageExtrema(MagickWand *wand,
1365 % size_t *minima,size_t *maxima)
1367 % A description of each parameter follows:
1369 % o wand: the magick wand.
1371 % o minima: The minimum pixel value for the specified channel(s).
1373 % o maxima: The maximum pixel value for the specified channel(s).
1376 WandExport MagickBooleanType MagickGetImageExtrema(MagickWand *wand,
1377 size_t *minima,size_t *maxima)
1382 assert(wand != (MagickWand *) NULL);
1383 assert(wand->signature == WandSignature);
1384 if (wand->debug != MagickFalse)
1385 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1386 if (wand->images == (Image *) NULL)
1387 ThrowWandException(WandError,"ContainsNoImages",wand->name);
1388 status=GetImageExtrema(wand->images,minima,maxima,wand->exception);
1393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1397 % M a g i c k G e t I m a g e M a t t e %
1401 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1403 % MagickGetImageMatte() returns MagickTrue if the image has a matte channel
1404 % otherwise MagickFalse.
1406 % The format of the MagickGetImageMatte method is:
1408 % size_t MagickGetImageMatte(MagickWand *wand)
1410 % A description of each parameter follows:
1412 % o wand: the magick wand.
1415 WandExport MagickBooleanType MagickGetImageMatte(MagickWand *wand)
1417 assert(wand != (MagickWand *) NULL);
1418 assert(wand->signature == WandSignature);
1419 if (wand->debug != MagickFalse)
1420 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1421 if (wand->images == (Image *) NULL)
1422 ThrowWandException(WandError,"ContainsNoImages",wand->name);
1423 return(wand->images->matte);
1427 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1431 % M a g i c k G e t I m a g e P i x e l s %
1435 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1437 % MagickGetImagePixels() extracts pixel data from an image and returns it to
1438 % you. The method returns MagickTrue on success otherwise MagickFalse if an
1439 % error is encountered. The data is returned as char, short int, int, ssize_t,
1440 % float, or double in the order specified by map.
1442 % Suppose you want to extract the first scanline of a 640x480 image as
1443 % character data in red-green-blue order:
1445 % MagickGetImagePixels(wand,0,0,640,1,"RGB",CharPixel,pixels);
1447 % The format of the MagickGetImagePixels method is:
1449 % MagickBooleanType MagickGetImagePixels(MagickWand *wand,
1450 % const ssize_t x,const ssize_t y,const size_t columns,
1451 % const size_t rows,const char *map,const StorageType storage,
1454 % A description of each parameter follows:
1456 % o wand: the magick wand.
1458 % o x, y, columns, rows: These values define the perimeter
1459 % of a region of pixels you want to extract.
1461 % o map: This string reflects the expected ordering of the pixel array.
1462 % It can be any combination or order of R = red, G = green, B = blue,
1463 % A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan,
1464 % Y = yellow, M = magenta, K = black, I = intensity (for grayscale),
1467 % o storage: Define the data type of the pixels. Float and double types are
1468 % expected to be normalized [0..1] otherwise [0..QuantumRange]. Choose from
1469 % these types: CharPixel, DoublePixel, FloatPixel, IntegerPixel,
1470 % LongPixel, QuantumPixel, or ShortPixel.
1472 % o pixels: This array of values contain the pixel components as defined by
1473 % map and type. You must preallocate this array where the expected
1474 % length varies depending on the values of width, height, map, and type.
1477 WandExport MagickBooleanType MagickGetImagePixels(MagickWand *wand,
1478 const ssize_t x,const ssize_t y,const size_t columns,
1479 const size_t rows,const char *map,const StorageType storage,
1482 return(MagickExportImagePixels(wand,x,y,columns,rows,map,storage,pixels));
1486 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1490 % M a g i c k G e t I m a g e S i z e %
1494 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1496 % MagickGetImageSize() returns the image length in bytes.
1498 % The format of the MagickGetImageSize method is:
1500 % MagickBooleanType MagickGetImageSize(MagickWand *wand,
1501 % MagickSizeType *length)
1503 % A description of each parameter follows:
1505 % o wand: the magick wand.
1507 % o length: the image length in bytes.
1510 WandExport MagickSizeType MagickGetImageSize(MagickWand *wand)
1512 assert(wand != (MagickWand *) NULL);
1513 assert(wand->signature == WandSignature);
1514 if (wand->debug != MagickFalse)
1515 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1516 if (wand->images == (Image *) NULL)
1517 ThrowWandException(WandError,"ContainsNoImages",wand->name);
1518 return(GetBlobSize(wand->images));
1522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1526 % M a g i c k M a p I m a g e %
1530 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1532 % MagickMapImage() replaces the colors of an image with the closest color
1533 % from a reference image.
1535 % The format of the MagickMapImage method is:
1537 % MagickBooleanType MagickMapImage(MagickWand *wand,
1538 % const MagickWand *map_wand,const MagickBooleanType dither)
1540 % A description of each parameter follows:
1542 % o wand: the magick wand.
1544 % o map: the map wand.
1546 % o dither: Set this integer value to something other than zero to dither
1550 WandExport MagickBooleanType MagickMapImage(MagickWand *wand,
1551 const MagickWand *map_wand,const MagickBooleanType dither)
1556 assert(wand != (MagickWand *) NULL);
1557 assert(wand->signature == WandSignature);
1558 if (wand->debug != MagickFalse)
1559 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1560 if ((wand->images == (Image *) NULL) || (map_wand->images == (Image *) NULL))
1561 ThrowWandException(WandError,"ContainsNoImages",wand->name);
1562 status=MapImage(wand->images,map_wand->images,dither);
1563 if (status == MagickFalse)
1564 InheritException(wand->exception,&wand->images->exception);
1569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1573 % M a g i c k M a t t e F l o o d f i l l I m a g e %
1577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1579 % MagickMatteFloodfillImage() changes the transparency value of any pixel that
1580 % matches target and is an immediate neighbor. If the method
1581 % FillToBorderMethod is specified, the transparency value is changed for any
1582 % neighbor pixel that does not match the bordercolor member of image.
1584 % The format of the MagickMatteFloodfillImage method is:
1586 % MagickBooleanType MagickMatteFloodfillImage(MagickWand *wand,
1587 % const double alpha,const double fuzz,const PixelWand *bordercolor,
1588 % const ssize_t x,const ssize_t y)
1590 % A description of each parameter follows:
1592 % o wand: the magick wand.
1594 % o alpha: the level of transparency: 1.0 is fully opaque and 0.0 is fully
1597 % o fuzz: By default target must match a particular pixel color
1598 % exactly. However, in many cases two colors may differ by a small amount.
1599 % The fuzz member of image defines how much tolerance is acceptable to
1600 % consider two colors as the same. For example, set fuzz to 10 and the
1601 % color red at intensities of 100 and 102 respectively are now interpreted
1602 % as the same color for the purposes of the floodfill.
1604 % o bordercolor: the border color pixel wand.
1606 % o x,y: the starting location of the operation.
1609 WandExport MagickBooleanType MagickMatteFloodfillImage(MagickWand *wand,
1610 const double alpha,const double fuzz,const PixelWand *bordercolor,
1611 const ssize_t x,const ssize_t y)
1622 assert(wand != (MagickWand *) NULL);
1623 assert(wand->signature == WandSignature);
1624 if (wand->debug != MagickFalse)
1625 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1626 if (wand->images == (Image *) NULL)
1627 ThrowWandException(WandError,"ContainsNoImages",wand->name);
1628 draw_info=CloneDrawInfo(wand->image_info,(DrawInfo *) NULL);
1629 (void) GetOneVirtualPixel(wand->images,x % wand->images->columns,
1630 y % wand->images->rows,&target,wand->exception);
1631 if (bordercolor != (PixelWand *) NULL)
1632 PixelGetQuantumColor(bordercolor,&target);
1633 wand->images->fuzz=fuzz;
1634 status=MatteFloodfillImage(wand->images,target,ClampToQuantum(
1635 (MagickRealType) QuantumRange-QuantumRange*alpha),x,y,bordercolor !=
1636 (PixelWand *) NULL ? FillToBorderMethod : FloodfillMethod);
1637 if (status == MagickFalse)
1638 InheritException(wand->exception,&wand->images->exception);
1639 draw_info=DestroyDrawInfo(draw_info);
1644 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1648 % M a g i c k M a x i m u m I m a g e s %
1652 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1654 % MagickMaximumImages() returns the maximum intensity of an image sequence.
1656 % The format of the MagickMaximumImages method is:
1658 % MagickWand *MagickMaximumImages(MagickWand *wand)
1660 % A description of each parameter follows:
1662 % o wand: the magick wand.
1665 WandExport MagickWand *MagickMaximumImages(MagickWand *wand)
1670 assert(wand != (MagickWand *) NULL);
1671 assert(wand->signature == WandSignature);
1672 if (wand->debug != MagickFalse)
1673 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1674 if (wand->images == (Image *) NULL)
1675 return((MagickWand *) NULL);
1676 maximum_image=EvaluateImages(wand->images,MaxEvaluateOperator,
1678 if (maximum_image == (Image *) NULL)
1679 return((MagickWand *) NULL);
1680 return(CloneMagickWandFromImages(wand,maximum_image));
1684 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1688 % M a g i c k M i n i m u m I m a g e s %
1692 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1694 % MagickMinimumImages() returns the minimum intensity of an image sequence.
1696 % The format of the MagickMinimumImages method is:
1698 % MagickWand *MagickMinimumImages(MagickWand *wand)
1700 % A description of each parameter follows:
1702 % o wand: the magick wand.
1705 WandExport MagickWand *MagickMinimumImages(MagickWand *wand)
1710 assert(wand != (MagickWand *) NULL);
1711 assert(wand->signature == WandSignature);
1712 if (wand->debug != MagickFalse)
1713 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1714 if (wand->images == (Image *) NULL)
1715 return((MagickWand *) NULL);
1716 minimum_image=EvaluateImages(wand->images,MinEvaluateOperator,
1718 if (minimum_image == (Image *) NULL)
1719 return((MagickWand *) NULL);
1720 return(CloneMagickWandFromImages(wand,minimum_image));
1724 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1728 % M a g i c k M o s a i c I m a g e s %
1732 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1734 % MagickMosaicImages() inlays an image sequence to form a single coherent
1735 % picture. It returns a wand with each image in the sequence composited at
1736 % the location defined by the page offset of the image.
1738 % The format of the MagickMosaicImages method is:
1740 % MagickWand *MagickMosaicImages(MagickWand *wand)
1742 % A description of each parameter follows:
1744 % o wand: the magick wand.
1747 WandExport MagickWand *MagickMosaicImages(MagickWand *wand)
1752 assert(wand != (MagickWand *) NULL);
1753 assert(wand->signature == WandSignature);
1754 if (wand->debug != MagickFalse)
1755 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
1756 if (wand->images == (Image *) NULL)
1757 return((MagickWand *) NULL);
1758 mosaic_image=MosaicImages(wand->images,wand->exception);
1759 if (mosaic_image == (Image *) NULL)
1760 return((MagickWand *) NULL);
1761 return(CloneMagickWandFromImages(wand,mosaic_image));
1765 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1769 % M a g i c k O p a q u e I m a g e %
1773 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1775 % MagickOpaqueImage() changes any pixel that matches color with the color
1778 % The format of the MagickOpaqueImage method is:
1780 % MagickBooleanType MagickOpaqueImage(MagickWand *wand,
1781 % const PixelWand *target,const PixelWand *fill,const double fuzz)
1783 % A description of each parameter follows:
1785 % o wand: the magick wand.
1787 % o channel: the channel(s).
1789 % o target: Change this target color to the fill color within the image.
1791 % o fill: the fill pixel wand.
1793 % o fuzz: By default target must match a particular pixel color
1794 % exactly. However, in many cases two colors may differ by a small amount.
1795 % The fuzz member of image defines how much tolerance is acceptable to
1796 % consider two colors as the same. For example, set fuzz to 10 and the
1797 % color red at intensities of 100 and 102 respectively are now interpreted
1798 % as the same color for the purposes of the floodfill.
1801 WandExport MagickBooleanType MagickOpaqueImage(MagickWand *wand,
1802 const PixelWand *target,const PixelWand *fill,const double fuzz)
1804 return(MagickPaintOpaqueImage(wand,target,fill,fuzz));
1808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1812 % M a g i c k P a i n t F l o o d f i l l I m a g e %
1816 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1818 % MagickPaintFloodfillImage() changes the color value of any pixel that matches
1819 % target and is an immediate neighbor. If the method FillToBorderMethod is
1820 % specified, the color value is changed for any neighbor pixel that does not
1821 % match the bordercolor member of image.
1823 % The format of the MagickPaintFloodfillImage method is:
1825 % MagickBooleanType MagickPaintFloodfillImage(MagickWand *wand,
1826 % const ChannelType channel,const PixelWand *fill,const double fuzz,
1827 % const PixelWand *bordercolor,const ssize_t x,const ssize_t y)
1829 % A description of each parameter follows:
1831 % o wand: the magick wand.
1833 % o channel: the channel(s).
1835 % o fill: the floodfill color pixel wand.
1837 % o fuzz: By default target must match a particular pixel color
1838 % exactly. However, in many cases two colors may differ by a small amount.
1839 % The fuzz member of image defines how much tolerance is acceptable to
1840 % consider two colors as the same. For example, set fuzz to 10 and the
1841 % color red at intensities of 100 and 102 respectively are now interpreted
1842 % as the same color for the purposes of the floodfill.
1844 % o bordercolor: the border color pixel wand.
1846 % o x,y: the starting location of the operation.
1849 WandExport MagickBooleanType MagickPaintFloodfillImage(MagickWand *wand,
1850 const ChannelType channel,const PixelWand *fill,const double fuzz,
1851 const PixelWand *bordercolor,const ssize_t x,const ssize_t y)
1856 status=MagickFloodfillPaintImage(wand,channel,fill,fuzz,bordercolor,x,y,
1862 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1866 % M a g i c k P a i n t O p a q u e I m a g e %
1870 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1872 % MagickPaintOpaqueImage() changes any pixel that matches color with the color
1875 % The format of the MagickPaintOpaqueImage method is:
1877 % MagickBooleanType MagickPaintOpaqueImage(MagickWand *wand,
1878 % const PixelWand *target,const PixelWand *fill,const double fuzz)
1879 % MagickBooleanType MagickPaintOpaqueImageChannel(MagickWand *wand,
1880 % const ChannelType channel,const PixelWand *target,
1881 % const PixelWand *fill,const double fuzz)
1883 % A description of each parameter follows:
1885 % o wand: the magick wand.
1887 % o channel: the channel(s).
1889 % o target: Change this target color to the fill color within the image.
1891 % o fill: the fill pixel wand.
1893 % o fuzz: By default target must match a particular pixel color
1894 % exactly. However, in many cases two colors may differ by a small amount.
1895 % The fuzz member of image defines how much tolerance is acceptable to
1896 % consider two colors as the same. For example, set fuzz to 10 and the
1897 % color red at intensities of 100 and 102 respectively are now interpreted
1898 % as the same color for the purposes of the floodfill.
1902 WandExport MagickBooleanType MagickPaintOpaqueImage(MagickWand *wand,
1903 const PixelWand *target,const PixelWand *fill,const double fuzz)
1905 return(MagickPaintOpaqueImageChannel(wand,DefaultChannels,target,fill,fuzz));
1908 WandExport MagickBooleanType MagickPaintOpaqueImageChannel(MagickWand *wand,
1909 const ChannelType channel,const PixelWand *target,const PixelWand *fill,
1915 status=MagickOpaquePaintImageChannel(wand,channel,target,fill,fuzz,
1921 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1925 % M a g i c k P a i n t T r a n s p a r e n t I m a g e %
1929 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1931 % MagickPaintTransparentImage() changes any pixel that matches color with the
1932 % color defined by fill.
1934 % The format of the MagickPaintTransparentImage method is:
1936 % MagickBooleanType MagickPaintTransparentImage(MagickWand *wand,
1937 % const PixelWand *target,const double alpha,const double fuzz)
1939 % A description of each parameter follows:
1941 % o wand: the magick wand.
1943 % o target: Change this target color to specified opacity value within
1946 % o alpha: the level of transparency: 1.0 is fully opaque and 0.0 is fully
1949 % o fuzz: By default target must match a particular pixel color
1950 % exactly. However, in many cases two colors may differ by a small amount.
1951 % The fuzz member of image defines how much tolerance is acceptable to
1952 % consider two colors as the same. For example, set fuzz to 10 and the
1953 % color red at intensities of 100 and 102 respectively are now interpreted
1954 % as the same color for the purposes of the floodfill.
1957 WandExport MagickBooleanType MagickPaintTransparentImage(MagickWand *wand,
1958 const PixelWand *target,const double alpha,const double fuzz)
1960 return(MagickTransparentPaintImage(wand,target,alpha,fuzz,MagickFalse));
1964 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1968 % M a g i c k R e c o l o r I m a g e %
1972 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1974 % MagickRecolorImage() apply color transformation to an image. The method
1975 % permits saturation changes, hue rotation, luminance to alpha, and various
1976 % other effects. Although variable-sized transformation matrices can be used,
1977 % typically one uses a 5x5 matrix for an RGBA image and a 6x6 for CMYKA
1978 % (or RGBA with offsets). The matrix is similar to those used by Adobe Flash
1979 % except offsets are in column 6 rather than 5 (in support of CMYKA images)
1980 % and offsets are normalized (divide Flash offset by 255).
1982 % The format of the MagickRecolorImage method is:
1984 % MagickBooleanType MagickRecolorImage(MagickWand *wand,
1985 % const size_t order,const double *color_matrix)
1987 % A description of each parameter follows:
1989 % o wand: the magick wand.
1991 % o order: the number of columns and rows in the color matrix.
1993 % o color_matrix: An array of doubles representing the color matrix.
1996 WandExport MagickBooleanType MagickRecolorImage(MagickWand *wand,
1997 const size_t order,const double *color_matrix)
2002 assert(wand != (MagickWand *) NULL);
2003 assert(wand->signature == WandSignature);
2004 if (wand->debug != MagickFalse)
2005 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2006 if (color_matrix == (const double *) NULL)
2007 return(MagickFalse);
2008 if (wand->images == (Image *) NULL)
2009 ThrowWandException(WandError,"ContainsNoImages",wand->name);
2010 transform_image=RecolorImage(wand->images,order,color_matrix,
2012 if (transform_image == (Image *) NULL)
2013 return(MagickFalse);
2014 ReplaceImageInList(&wand->images,transform_image);
2019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2023 % M a g i c k S e t I m a g e A t t r i b u t e %
2027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2029 % MagickSetImageAttribute() associates a property with an image.
2031 % The format of the MagickSetImageAttribute method is:
2033 % MagickBooleanType MagickSetImageAttribute(MagickWand *wand,
2034 % const char *property,const char *value)
2036 % A description of each parameter follows:
2038 % o wand: the magick wand.
2040 % o property: the property.
2042 % o value: the value.
2045 WandExport MagickBooleanType MagickSetImageAttribute(MagickWand *wand,
2046 const char *property,const char *value)
2048 return(SetImageProperty(wand->images,property,value));
2052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2056 % M a g i c k S e t I m a g e I n d e x %
2060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2062 % MagickSetImageIndex() set the current image to the position of the list
2063 % specified with the index parameter.
2065 % The format of the MagickSetImageIndex method is:
2067 % MagickBooleanType MagickSetImageIndex(MagickWand *wand,const ssize_t index)
2069 % A description of each parameter follows:
2071 % o wand: the magick wand.
2073 % o index: the scene number.
2076 WandExport MagickBooleanType MagickSetImageIndex(MagickWand *wand,
2077 const ssize_t index)
2079 return(MagickSetIteratorIndex(wand,index));
2083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2087 + M a g i c k S e t I m a g e O p t i o n %
2091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2093 % MagickSetImageOption() associates one or options with a particular image
2094 % format (.e.g MagickSetImageOption(wand,"jpeg","perserve","yes").
2096 % The format of the MagickSetImageOption method is:
2098 % MagickBooleanType MagickSetImageOption(MagickWand *wand,
2099 % const char *format,const char *key,const char *value)
2101 % A description of each parameter follows:
2103 % o wand: the magick wand.
2105 % o format: the image format.
2109 % o value: The value.
2112 WandExport MagickBooleanType MagickSetImageOption(MagickWand *wand,
2113 const char *format,const char *key,const char *value)
2116 option[MaxTextExtent];
2118 assert(wand != (MagickWand *) NULL);
2119 assert(wand->signature == WandSignature);
2120 if (wand->debug != MagickFalse)
2121 (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
2122 (void) FormatMagickString(option,MaxTextExtent,"%s:%s=%s",format,key,value);
2123 return(DefineImageOption(wand->image_info,option));
2127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2131 % M a g i c k T r a n s p a r e n t I m a g e %
2135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2137 % MagickTransparentImage() changes any pixel that matches color with the
2138 % color defined by fill.
2140 % The format of the MagickTransparentImage method is:
2142 % MagickBooleanType MagickTransparentImage(MagickWand *wand,
2143 % const PixelWand *target,const double alpha,const double fuzz)
2145 % A description of each parameter follows:
2147 % o wand: the magick wand.
2149 % o target: Change this target color to specified opacity value within
2152 % o alpha: the level of transparency: 1.0 is fully opaque and 0.0 is fully
2155 % o fuzz: By default target must match a particular pixel color
2156 % exactly. However, in many cases two colors may differ by a small amount.
2157 % The fuzz member of image defines how much tolerance is acceptable to
2158 % consider two colors as the same. For example, set fuzz to 10 and the
2159 % color red at intensities of 100 and 102 respectively are now interpreted
2160 % as the same color for the purposes of the floodfill.
2163 WandExport MagickBooleanType MagickTransparentImage(MagickWand *wand,
2164 const PixelWand *target,const double alpha,const double fuzz)
2166 return(MagickPaintTransparentImage(wand,target,alpha,fuzz));
2170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2174 % M a g i c k R e g i o n O f I n t e r e s t I m a g e %
2178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2180 % MagickRegionOfInterestImage() extracts a region of the image and returns it
2183 % The format of the MagickRegionOfInterestImage method is:
2185 % MagickWand *MagickRegionOfInterestImage(MagickWand *wand,
2186 % const size_t width,const size_t height,const ssize_t x,
2189 % A description of each parameter follows:
2191 % o wand: the magick wand.
2193 % o width: the region width.
2195 % o height: the region height.
2197 % o x: the region x offset.
2199 % o y: the region y offset.
2202 WandExport MagickWand *MagickRegionOfInterestImage(MagickWand *wand,
2203 const size_t width,const size_t height,const ssize_t x,
2206 return(MagickGetImageRegion(wand,width,height,x,y));
2210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2214 % M a g i c k S e t I m a g e P i x e l s %
2218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2220 % MagickSetImagePixels() accepts pixel datand stores it in the image at the
2221 % location you specify. The method returns MagickFalse on success otherwise
2222 % MagickTrue if an error is encountered. The pixel data can be either char,
2223 % short int, int, ssize_t, float, or double in the order specified by map.
2225 % Suppose your want to upload the first scanline of a 640x480 image from
2226 % character data in red-green-blue order:
2228 % MagickSetImagePixels(wand,0,0,640,1,"RGB",CharPixel,pixels);
2230 % The format of the MagickSetImagePixels method is:
2232 % MagickBooleanType MagickSetImagePixels(MagickWand *wand,
2233 % const ssize_t x,const ssize_t y,const size_t columns,
2234 % const size_t rows,const char *map,const StorageType storage,
2235 % const void *pixels)
2237 % A description of each parameter follows:
2239 % o wand: the magick wand.
2241 % o x, y, columns, rows: These values define the perimeter of a region
2242 % of pixels you want to define.
2244 % o map: This string reflects the expected ordering of the pixel array.
2245 % It can be any combination or order of R = red, G = green, B = blue,
2246 % A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan,
2247 % Y = yellow, M = magenta, K = black, I = intensity (for grayscale),
2250 % o storage: Define the data type of the pixels. Float and double types are
2251 % expected to be normalized [0..1] otherwise [0..QuantumRange]. Choose from
2252 % these types: CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel,
2255 % o pixels: This array of values contain the pixel components as defined by
2256 % map and type. You must preallocate this array where the expected
2257 % length varies depending on the values of width, height, map, and type.
2260 WandExport MagickBooleanType MagickSetImagePixels(MagickWand *wand,
2261 const ssize_t x,const ssize_t y,const size_t columns,
2262 const size_t rows,const char *map,const StorageType storage,
2265 return(MagickImportImagePixels(wand,x,y,columns,rows,map,storage,pixels));
2269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2273 % M a g i c k W r i t e I m a g e B l o b %
2277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2279 % MagickWriteImageBlob() implements direct to memory image formats. It
2280 % returns the image as a blob and its length. Use MagickSetFormat() to
2281 % set the format of the returned blob (GIF, JPEG, PNG, etc.).
2283 % Use MagickRelinquishMemory() to free the blob when you are done with it.
2285 % The format of the MagickWriteImageBlob method is:
2287 % unsigned char *MagickWriteImageBlob(MagickWand *wand,size_t *length)
2289 % A description of each parameter follows:
2291 % o wand: the magick wand.
2293 % o length: the length of the blob.
2296 WandExport unsigned char *MagickWriteImageBlob(MagickWand *wand,size_t *length)
2298 return(MagickGetImageBlob(wand,length));
2302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2306 % N e w P i x e l V i e w %
2310 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2312 % NewPixelView() returns a pixel view required for all other methods in the
2315 % The format of the NewPixelView method is:
2317 % PixelView *NewPixelView(MagickWand *wand)
2319 % A description of each parameter follows:
2325 static PixelWand ***AcquirePixelsThreadSet(const size_t number_wands,
2326 const size_t number_threads)
2334 pixel_wands=(PixelWand ***) AcquireAlignedMemory(number_threads,
2335 sizeof(*pixel_wands));
2336 if (pixel_wands == (PixelWand ***) NULL)
2337 return((PixelWand ***) NULL);
2338 (void) ResetMagickMemory(pixel_wands,0,number_threads*sizeof(*pixel_wands));
2339 for (i=0; i < (ssize_t) number_threads; i++)
2341 pixel_wands[i]=NewPixelWands(number_wands);
2342 if (pixel_wands[i] == (PixelWand **) NULL)
2343 return(DestroyPixelsThreadSet(pixel_wands,number_wands,number_threads));
2345 return(pixel_wands);
2348 WandExport PixelView *NewPixelView(MagickWand *wand)
2353 assert(wand != (MagickWand *) NULL);
2354 assert(wand->signature == MagickSignature);
2355 pixel_view=(PixelView *) AcquireAlignedMemory(1,sizeof(*pixel_view));
2356 if (pixel_view == (PixelView *) NULL)
2357 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
2358 GetExceptionMessage(errno));
2359 (void) ResetMagickMemory(pixel_view,0,sizeof(*pixel_view));
2360 pixel_view->id=AcquireWandId();
2361 (void) FormatMagickString(pixel_view->name,MaxTextExtent,"%s-%.20g",
2362 PixelViewId,(double) pixel_view->id);
2363 pixel_view->exception=AcquireExceptionInfo();
2364 pixel_view->wand=wand;
2365 pixel_view->view=AcquireCacheView(pixel_view->wand->images);
2366 pixel_view->region.width=wand->images->columns;
2367 pixel_view->region.height=wand->images->rows;
2368 pixel_view->number_threads=GetOpenMPMaximumThreads();
2369 pixel_view->pixel_wands=AcquirePixelsThreadSet(pixel_view->region.width,
2370 pixel_view->number_threads);
2371 if (pixel_view->pixel_wands == (PixelWand ***) NULL)
2372 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
2373 GetExceptionMessage(errno));
2374 pixel_view->debug=IsEventLogging();
2375 pixel_view->signature=WandSignature;
2380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2384 % N e w P i x e l V i e w R e g i o n %
2388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2390 % NewPixelViewRegion() returns a pixel view required for all other methods
2391 % in the Pixel View API.
2393 % The format of the NewPixelViewRegion method is:
2395 % PixelView *NewPixelViewRegion(MagickWand *wand,const ssize_t x,
2396 % const ssize_t y,const size_t width,const size_t height)
2398 % A description of each parameter follows:
2400 % o wand: the magick wand.
2402 % o x,y,columns,rows: These values define the perimeter of a region of
2406 WandExport PixelView *NewPixelViewRegion(MagickWand *wand,const ssize_t x,
2407 const ssize_t y,const size_t width,const size_t height)
2412 assert(wand != (MagickWand *) NULL);
2413 assert(wand->signature == MagickSignature);
2414 pixel_view=(PixelView *) AcquireAlignedMemory(1,sizeof(*pixel_view));
2415 if (pixel_view == (PixelView *) NULL)
2416 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
2417 GetExceptionMessage(errno));
2418 (void) ResetMagickMemory(pixel_view,0,sizeof(*pixel_view));
2419 pixel_view->id=AcquireWandId();
2420 (void) FormatMagickString(pixel_view->name,MaxTextExtent,"%s-%.20g",
2421 PixelViewId,(double) pixel_view->id);
2422 pixel_view->exception=AcquireExceptionInfo();
2423 pixel_view->view=AcquireCacheView(pixel_view->wand->images);
2424 pixel_view->wand=wand;
2425 pixel_view->region.width=width;
2426 pixel_view->region.height=height;
2427 pixel_view->region.x=x;
2428 pixel_view->region.y=y;
2429 pixel_view->number_threads=GetOpenMPMaximumThreads();
2430 pixel_view->pixel_wands=AcquirePixelsThreadSet(pixel_view->region.width,
2431 pixel_view->number_threads);
2432 if (pixel_view->pixel_wands == (PixelWand ***) NULL)
2433 ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
2434 GetExceptionMessage(errno));
2435 pixel_view->debug=IsEventLogging();
2436 pixel_view->signature=WandSignature;
2441 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2445 % P i x e l G e t N e x t R o w %
2449 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2451 % PixelGetNextRow() returns the next row as an array of pixel wands from the
2454 % The format of the PixelGetNextRow method is:
2456 % PixelWand **PixelGetNextRow(PixelIterator *iterator,
2457 % size_t *number_wands)
2459 % A description of each parameter follows:
2461 % o iterator: the pixel iterator.
2463 % o number_wands: the number of pixel wands.
2466 WandExport PixelWand **PixelGetNextRow(PixelIterator *iterator)
2471 return(PixelGetNextIteratorRow(iterator,&number_wands));
2475 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2479 % P i x e l I t e r a t o r G e t E x c e p t i o n %
2483 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2485 % PixelIteratorGetException() returns the severity, reason, and description of
2486 % any error that occurs when using other methods in this API.
2488 % The format of the PixelIteratorGetException method is:
2490 % char *PixelIteratorGetException(const Pixeliterator *iterator,
2491 % ExceptionType *severity)
2493 % A description of each parameter follows:
2495 % o iterator: the pixel iterator.
2497 % o severity: the severity of the error is returned here.
2500 WandExport char *PixelIteratorGetException(const PixelIterator *iterator,
2501 ExceptionType *severity)
2503 return(PixelGetIteratorException(iterator,severity));
2507 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2511 % S e t P i x e l V i e w I t e r a t o r %
2515 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2517 % SetPixelViewIterator() iterates over the pixel view in parallel and calls
2518 % your set method for each scanline of the view. The pixel region is
2519 % confined to the image canvas-- that is no negative offsets or widths or
2520 % heights that exceed the image dimension. The pixels are initiallly
2521 % undefined and any settings you make in the callback method are automagically
2522 % synced back to your image.
2526 % #pragma omp critical
2528 % to define a section of code in your callback set method that must be
2529 % executed by a single thread at a time.
2531 % The format of the SetPixelViewIterator method is:
2533 % MagickBooleanType SetPixelViewIterator(PixelView *destination,
2534 % SetPixelViewMethod set,void *context)
2536 % A description of each parameter follows:
2538 % o destination: the pixel view.
2540 % o set: the set callback method.
2542 % o context: the user defined context.
2545 WandExport MagickBooleanType SetPixelViewIterator(PixelView *destination,
2546 SetPixelViewMethod set,void *context)
2548 #define SetPixelViewTag "PixelView/Set"
2565 assert(destination != (PixelView *) NULL);
2566 assert(destination->signature == WandSignature);
2567 if (set == (SetPixelViewMethod) NULL)
2568 return(MagickFalse);
2569 destination_image=destination->wand->images;
2570 if (SetImageStorageClass(destination_image,DirectClass) == MagickFalse)
2571 return(MagickFalse);
2574 exception=destination->exception;
2575 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2576 #pragma omp parallel for schedule(static,1) shared(progress,status)
2578 for (y=destination->region.y; y < (ssize_t) destination->region.height; y++)
2583 register IndexPacket
2590 register PixelPacket
2593 if (status == MagickFalse)
2595 id=GetOpenMPThreadId();
2596 pixels=GetCacheViewAuthenticPixels(destination->view,destination->region.x,
2597 y,destination->region.width,1,exception);
2598 if (pixels == (PixelPacket *) NULL)
2600 InheritException(destination->exception,GetCacheViewException(
2601 destination->view));
2605 indexes=GetCacheViewAuthenticIndexQueue(destination->view);
2606 if (set(destination,context) == MagickFalse)
2608 for (x=0; x < (ssize_t) destination->region.width; x++)
2609 PixelGetQuantumColor(destination->pixel_wands[id][x],pixels+x);
2610 if (destination_image->colorspace == CMYKColorspace)
2611 for (x=0; x < (ssize_t) destination->region.width; x++)
2612 indexes[x]=PixelGetBlackQuantum(destination->pixel_wands[id][x]);
2613 sync=SyncCacheViewAuthenticPixels(destination->view,exception);
2614 if (sync == MagickFalse)
2616 InheritException(destination->exception,GetCacheViewException(
2617 destination->view));
2620 if (destination_image->progress_monitor != (MagickProgressMonitor) NULL)
2625 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2626 #pragma omp critical (MagickWand_SetPixelViewIterator)
2628 proceed=SetImageProgress(destination_image,SetPixelViewTag,progress++,
2629 destination->region.height);
2630 if (proceed == MagickFalse)
2638 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2642 % T r a n s f e r P i x e l V i e w I t e r a t o r %
2646 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2648 % TransferPixelViewIterator() iterates over two pixel views in parallel and
2649 % calls your transfer method for each scanline of the view. The source pixel
2650 % region is not confined to the image canvas-- that is you can include
2651 % negative offsets or widths or heights that exceed the image dimension.
2652 % However, the destination pixel view is confined to the image canvas-- that
2653 % is no negative offsets or widths or heights that exceed the image dimension
2658 % #pragma omp critical
2660 % to define a section of code in your callback transfer method that must be
2661 % executed by a single thread at a time.
2663 % The format of the TransferPixelViewIterator method is:
2665 % MagickBooleanType TransferPixelViewIterator(PixelView *source,
2666 % PixelView *destination,TransferPixelViewMethod transfer,void *context)
2668 % A description of each parameter follows:
2670 % o source: the source pixel view.
2672 % o destination: the destination pixel view.
2674 % o transfer: the transfer callback method.
2676 % o context: the user defined context.
2679 WandExport MagickBooleanType TransferPixelViewIterator(PixelView *source,
2680 PixelView *destination,TransferPixelViewMethod transfer,void *context)
2682 #define TransferPixelViewTag "PixelView/Transfer"
2700 assert(source != (PixelView *) NULL);
2701 assert(source->signature == WandSignature);
2702 if (transfer == (TransferPixelViewMethod) NULL)
2703 return(MagickFalse);
2704 source_image=source->wand->images;
2705 destination_image=destination->wand->images;
2706 if (SetImageStorageClass(destination_image,DirectClass) == MagickFalse)
2707 return(MagickFalse);
2710 exception=destination->exception;
2711 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2712 #pragma omp parallel for schedule(static,1) shared(progress,status)
2714 for (y=source->region.y; y < (ssize_t) source->region.height; y++)
2719 register const IndexPacket
2722 register const PixelPacket
2725 register IndexPacket
2726 *restrict destination_indexes;
2732 register PixelPacket
2733 *restrict destination_pixels;
2735 if (status == MagickFalse)
2737 id=GetOpenMPThreadId();
2738 pixels=GetCacheViewVirtualPixels(source->view,source->region.x,y,
2739 source->region.width,1,source->exception);
2740 if (pixels == (const PixelPacket *) NULL)
2745 indexes=GetCacheViewVirtualIndexQueue(source->view);
2746 for (x=0; x < (ssize_t) source->region.width; x++)
2747 PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);
2748 if (source_image->colorspace == CMYKColorspace)
2749 for (x=0; x < (ssize_t) source->region.width; x++)
2750 PixelSetBlackQuantum(source->pixel_wands[id][x],indexes[x]);
2751 if (source_image->storage_class == PseudoClass)
2752 for (x=0; x < (ssize_t) source->region.width; x++)
2753 PixelSetIndex(source->pixel_wands[id][x],indexes[x]);
2754 destination_pixels=GetCacheViewAuthenticPixels(destination->view,
2755 destination->region.x,y,destination->region.width,1,exception);
2756 if (destination_pixels == (PixelPacket *) NULL)
2761 destination_indexes=GetCacheViewAuthenticIndexQueue(destination->view);
2762 for (x=0; x < (ssize_t) destination->region.width; x++)
2763 PixelSetQuantumColor(destination->pixel_wands[id][x],pixels+x);
2764 if (destination_image->colorspace == CMYKColorspace)
2765 for (x=0; x < (ssize_t) destination->region.width; x++)
2766 PixelSetBlackQuantum(destination->pixel_wands[id][x],indexes[x]);
2767 if (destination_image->storage_class == PseudoClass)
2768 for (x=0; x < (ssize_t) destination->region.width; x++)
2769 PixelSetIndex(destination->pixel_wands[id][x],indexes[x]);
2770 if (transfer(source,destination,context) == MagickFalse)
2772 for (x=0; x < (ssize_t) destination->region.width; x++)
2773 PixelGetQuantumColor(destination->pixel_wands[id][x],
2774 destination_pixels+x);
2775 if (destination_image->colorspace == CMYKColorspace)
2776 for (x=0; x < (ssize_t) destination->region.width; x++)
2777 destination_indexes[x]=PixelGetBlackQuantum(
2778 destination->pixel_wands[id][x]);
2779 sync=SyncCacheViewAuthenticPixels(destination->view,exception);
2780 if (sync == MagickFalse)
2782 InheritException(destination->exception,GetCacheViewException(
2786 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
2791 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2792 #pragma omp critical (MagickWand_TransferPixelViewIterator)
2794 proceed=SetImageProgress(source_image,TransferPixelViewTag,progress++,
2795 source->region.height);
2796 if (proceed == MagickFalse)
2804 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2808 % U p d a t e P i x e l V i e w I t e r a t o r %
2812 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2814 % UpdatePixelViewIterator() iterates over the pixel view in parallel and calls
2815 % your update method for each scanline of the view. The pixel region is
2816 % confined to the image canvas-- that is no negative offsets or widths or
2817 % heights that exceed the image dimension are permitted. Updates to pixels
2818 % in your callback are automagically synced back to the image.
2822 % #pragma omp critical
2824 % to define a section of code in your callback update method that must be
2825 % executed by a single thread at a time.
2827 % The format of the UpdatePixelViewIterator method is:
2829 % MagickBooleanType UpdatePixelViewIterator(PixelView *source,
2830 % UpdatePixelViewMethod update,void *context)
2832 % A description of each parameter follows:
2834 % o source: the source pixel view.
2836 % o update: the update callback method.
2838 % o context: the user defined context.
2841 WandExport MagickBooleanType UpdatePixelViewIterator(PixelView *source,
2842 UpdatePixelViewMethod update,void *context)
2844 #define UpdatePixelViewTag "PixelView/Update"
2861 assert(source != (PixelView *) NULL);
2862 assert(source->signature == WandSignature);
2863 if (update == (UpdatePixelViewMethod) NULL)
2864 return(MagickFalse);
2865 source_image=source->wand->images;
2866 if (SetImageStorageClass(source_image,DirectClass) == MagickFalse)
2867 return(MagickFalse);
2870 exception=source->exception;
2871 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2872 #pragma omp parallel for schedule(static,1) shared(progress,status)
2874 for (y=source->region.y; y < (ssize_t) source->region.height; y++)
2876 register IndexPacket
2883 register PixelPacket
2886 if (status == MagickFalse)
2888 id=GetOpenMPThreadId();
2889 pixels=GetCacheViewAuthenticPixels(source->view,source->region.x,y,
2890 source->region.width,1,exception);
2891 if (pixels == (PixelPacket *) NULL)
2893 InheritException(source->exception,GetCacheViewException(
2898 indexes=GetCacheViewAuthenticIndexQueue(source->view);
2899 for (x=0; x < (ssize_t) source->region.width; x++)
2900 PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);
2901 if (source_image->colorspace == CMYKColorspace)
2902 for (x=0; x < (ssize_t) source->region.width; x++)
2903 PixelSetBlackQuantum(source->pixel_wands[id][x],indexes[x]);
2904 if (update(source,context) == MagickFalse)
2906 for (x=0; x < (ssize_t) source->region.width; x++)
2907 PixelGetQuantumColor(source->pixel_wands[id][x],pixels+x);
2908 if (source_image->colorspace == CMYKColorspace)
2909 for (x=0; x < (ssize_t) source->region.width; x++)
2910 indexes[x]=PixelGetBlackQuantum(source->pixel_wands[id][x]);
2911 if (SyncCacheViewAuthenticPixels(source->view,exception) == MagickFalse)
2913 InheritException(source->exception,GetCacheViewException(source->view));
2916 if (source_image->progress_monitor != (MagickProgressMonitor) NULL)
2921 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2922 #pragma omp critical (MagickWand_UpdatePixelViewIterator)
2924 proceed=SetImageProgress(source_image,UpdatePixelViewTag,progress++,
2925 source->region.height);
2926 if (proceed == MagickFalse)