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 % MagickCore 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 "magick/studio.h"
44 #include "magick/property.h"
45 #include "magick/blob.h"
46 #include "magick/blob-private.h"
47 #include "magick/cache.h"
48 #include "magick/cache-view.h"
49 #include "magick/client.h"
50 #include "magick/color.h"
51 #include "magick/color-private.h"
52 #include "magick/colormap.h"
53 #include "magick/colormap-private.h"
54 #include "magick/colorspace.h"
55 #include "magick/composite.h"
56 #include "magick/composite-private.h"
57 #include "magick/constitute.h"
58 #include "magick/deprecate.h"
59 #include "magick/draw.h"
60 #include "magick/draw-private.h"
61 #include "magick/effect.h"
62 #include "magick/enhance.h"
63 #include "magick/exception.h"
64 #include "magick/exception-private.h"
65 #include "magick/fx.h"
66 #include "magick/geometry.h"
67 #include "magick/identify.h"
68 #include "magick/image.h"
69 #include "magick/image-private.h"
70 #include "magick/list.h"
71 #include "magick/log.h"
72 #include "magick/memory_.h"
73 #include "magick/magick.h"
74 #include "magick/monitor.h"
75 #include "magick/monitor-private.h"
76 #include "magick/morphology.h"
77 #include "magick/paint.h"
78 #include "magick/pixel.h"
79 #include "magick/pixel-private.h"
80 #include "magick/quantize.h"
81 #include "magick/random_.h"
82 #include "magick/resource_.h"
83 #include "magick/semaphore.h"
84 #include "magick/segment.h"
85 #include "magick/splay-tree.h"
86 #include "magick/statistic.h"
87 #include "magick/string_.h"
88 #include "magick/threshold.h"
89 #include "magick/transform.h"
90 #include "magick/utility.h"
92 #if !defined(MAGICKCORE_EXCLUDE_DEPRECATED)
97 monitor_handler = (MonitorHandler) NULL;
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 % A c q u i r e C a c h e V i e w I n d e x e s %
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 % AcquireCacheViewIndexes() returns the indexes associated with the specified
113 % The format of the AcquireCacheViewIndexes method is:
115 % const IndexPacket *AcquireCacheViewIndexes(const CacheView *cache_view)
117 % A description of each parameter follows:
119 % o cache_view: the cache view.
122 MagickExport const IndexPacket *AcquireCacheViewIndexes(
123 const CacheView *cache_view)
125 return(GetCacheViewVirtualIndexQueue(cache_view));
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133 % A c q u i r e C a c h e V i e w P i x e l s %
137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139 % AcquireCacheViewPixels() gets pixels from the in-memory or disk pixel cache
140 % as defined by the geometry parameters. A pointer to the pixels is returned
141 % if the pixels are transferred, otherwise a NULL is returned.
143 % The format of the AcquireCacheViewPixels method is:
145 % const PixelPacket *AcquireCacheViewPixels(const CacheView *cache_view,
146 % const long x,const long y,const unsigned long columns,
147 % const unsigned long rows,ExceptionInfo *exception)
149 % A description of each parameter follows:
151 % o cache_view: the cache view.
153 % o x,y,columns,rows: These values define the perimeter of a region of
156 % o exception: return any errors or warnings in this structure.
159 MagickExport const PixelPacket *AcquireCacheViewPixels(
160 const CacheView *cache_view,const long x,const long y,
161 const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
163 return(GetCacheViewVirtualPixels(cache_view,x,y,columns,rows,exception));
167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171 % A c q u i r e I m a g e P i x e l s %
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 % AcquireImagePixels() returns an immutable pixel region. If the
177 % region is successfully accessed, a pointer to it is returned, otherwise
178 % NULL is returned. The returned pointer may point to a temporary working
179 % copy of the pixels or it may point to the original pixels in memory.
180 % Performance is maximized if the selected region is part of one row, or one
181 % or more full rows, since there is opportunity to access the pixels in-place
182 % (without a copy) if the image is in RAM, or in a memory-mapped file. The
183 % returned pointer should *never* be deallocated by the user.
185 % Pixels accessed via the returned pointer represent a simple array of type
186 % PixelPacket. If the image type is CMYK or the storage class is PseudoClass,
187 % call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to access
188 % the black color component or to obtain the colormap indexes (of type
189 % IndexPacket) corresponding to the region.
191 % If you plan to modify the pixels, use GetAuthenticPixels() instead.
193 % Note, the AcquireImagePixels() and GetAuthenticPixels() methods are not
194 % thread-safe. In a threaded environment, use GetCacheViewVirtualPixels() or
195 % GetCacheViewAuthenticPixels() instead.
197 % The format of the AcquireImagePixels() method is:
199 % const PixelPacket *AcquireImagePixels(const Image *image,const long x,
200 % const long y,const unsigned long columns,const unsigned long rows,
201 % ExceptionInfo *exception)
203 % A description of each parameter follows:
205 % o image: the image.
207 % o x,y,columns,rows: These values define the perimeter of a region of
210 % o exception: return any errors or warnings in this structure.
213 MagickExport const PixelPacket *AcquireImagePixels(const Image *image,
214 const long x,const long y,const unsigned long columns,
215 const unsigned long rows,ExceptionInfo *exception)
217 return(GetVirtualPixels(image,x,y,columns,rows,exception));
221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
225 % A c q u i r e I n d e x e s %
229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231 % AcquireIndexes() returns the black channel or the colormap indexes
232 % associated with the last call to QueueAuthenticPixels() or GetVirtualPixels().
233 % NULL is returned if the black channel or colormap indexes are not available.
235 % The format of the AcquireIndexes() method is:
237 % const IndexPacket *AcquireIndexes(const Image *image)
239 % A description of each parameter follows:
241 % o indexes: AcquireIndexes() returns the indexes associated with the last
242 % call to QueueAuthenticPixels() or GetVirtualPixels().
244 % o image: the image.
247 MagickExport const IndexPacket *AcquireIndexes(const Image *image)
249 return(GetVirtualIndexQueue(image));
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257 % A c q u i r e M e m o r y %
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
263 % AcquireMemory() returns a pointer to a block of memory at least size bytes
264 % suitably aligned for any use.
266 % The format of the AcquireMemory method is:
268 % void *AcquireMemory(const size_t size)
270 % A description of each parameter follows:
272 % o size: the size of the memory in bytes to allocate.
275 MagickExport void *AcquireMemory(const size_t size)
281 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
282 allocation=malloc(size);
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
291 % A c q u i r e O n e C a c h e V i e w P i x e l %
295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
297 % AcquireOneCacheViewPixel() returns a single pixel at the specified (x,y)
298 % location. The image background color is returned if an error occurs. If
299 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
301 % The format of the AcquireOneCacheViewPixel method is:
303 % MagickBooleanType AcquireOneCacheViewPixel(const CacheView *cache_view,
304 % const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
306 % A description of each parameter follows:
308 % o cache_view: the cache view.
310 % o x,y: These values define the offset of the pixel.
312 % o pixel: return a pixel at the specified (x,y) location.
314 % o exception: return any errors or warnings in this structure.
317 MagickExport MagickBooleanType AcquireOneCacheViewPixel(
318 const CacheView *cache_view,const long x,const long y,PixelPacket *pixel,
319 ExceptionInfo *exception)
321 return(GetOneCacheViewVirtualPixel(cache_view,x,y,pixel,exception));
325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
329 % A c q u i r e O n e C a c h e V i e w V i r t u a l P i x e l %
333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
335 % AcquireOneCacheViewVirtualPixel() returns a single pixel at the specified
336 % (x,y) location. The image background color is returned if an error occurs.
337 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
339 % The format of the AcquireOneCacheViewPixel method is:
341 % MagickBooleanType AcquireOneCacheViewVirtualPixel(
342 % const CacheView *cache_view,
343 % const VirtualPixelMethod virtual_pixel_method,const long x,
344 % const long y,PixelPacket *pixel,ExceptionInfo *exception)
346 % A description of each parameter follows:
348 % o cache_view: the cache view.
350 % o virtual_pixel_method: the virtual pixel method.
352 % o x,y: These values define the offset of the pixel.
354 % o pixel: return a pixel at the specified (x,y) location.
356 % o exception: return any errors or warnings in this structure.
359 MagickExport MagickBooleanType AcquireOneCacheViewVirtualPixel(
360 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
361 const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
366 status=GetOneCacheViewVirtualMethodPixel(cache_view,virtual_pixel_method,
367 x,y,pixel,exception);
372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 % A c q u i r e O n e M a g i c k P i x e l %
380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
382 % AcquireOneMagickPixel() returns a single pixel at the specified (x,y)
383 % location. The image background color is returned if an error occurs. If
384 % you plan to modify the pixel, use GetOnePixel() instead.
386 % The format of the AcquireOneMagickPixel() method is:
388 % MagickPixelPacket AcquireOneMagickPixel(const Image image,const long x,
389 % const long y,ExceptionInfo exception)
391 % A description of each parameter follows:
393 % o image: the image.
395 % o x,y: These values define the location of the pixel to return.
397 % o exception: return any errors or warnings in this structure.
400 MagickExport MagickPixelPacket AcquireOneMagickPixel(const Image *image,
401 const long x,const long y,ExceptionInfo *exception)
406 (void) GetOneVirtualMagickPixel(image,x,y,&pixel,exception);
411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
415 % A c q u i r e O n e P i x e l %
419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
421 % AcquireOnePixel() returns a single pixel at the specified (x,y) location.
422 % The image background color is returned if an error occurs. If you plan to
423 % modify the pixel, use GetOnePixel() instead.
425 % The format of the AcquireOnePixel() method is:
427 % PixelPacket AcquireOnePixel(const Image image,const long x,
428 % const long y,ExceptionInfo exception)
430 % A description of each parameter follows:
432 % o image: the image.
434 % o x,y: These values define the location of the pixel to return.
436 % o exception: return any errors or warnings in this structure.
439 MagickExport PixelPacket AcquireOnePixel(const Image *image,const long x,
440 const long y,ExceptionInfo *exception)
445 (void) GetOneVirtualPixel(image,x,y,&pixel,exception);
450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
454 % A c q u i r e O n e V i r t u a l P i x e l %
458 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
460 % AcquireOneVirtualPixel() returns a single pixel at the specified (x,y)
461 % location as defined by specified pixel method. The image background color
462 % is returned if an error occurs. If you plan to modify the pixel, use
463 % GetOnePixel() instead.
465 % The format of the AcquireOneVirtualPixel() method is:
467 % PixelPacket AcquireOneVirtualPixel(const Image image,
468 % const VirtualPixelMethod virtual_pixel_method,const long x,
469 % const long y,ExceptionInfo exception)
471 % A description of each parameter follows:
473 % o virtual_pixel_method: the virtual pixel method.
475 % o image: the image.
477 % o x,y: These values define the location of the pixel to return.
479 % o exception: return any errors or warnings in this structure.
482 MagickExport PixelPacket AcquireOneVirtualPixel(const Image *image,
483 const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
484 ExceptionInfo *exception)
489 (void) GetOneVirtualMethodPixel(image,virtual_pixel_method,x,y,&pixel,
495 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
499 % A c q u i r e P i x e l s %
503 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
505 % AcquirePixels() returns the pixels associated with the last call to
506 % QueueAuthenticPixels() or GetVirtualPixels().
508 % The format of the AcquirePixels() method is:
510 % const PixelPacket *AcquirePixels(const Image image)
512 % A description of each parameter follows:
514 % o image: the image.
517 MagickExport const PixelPacket *AcquirePixels(const Image *image)
519 return(GetVirtualPixelQueue(image));
523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
527 % A f f i n i t y I m a g e %
531 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
533 % AffinityImage() replaces the colors of an image with the closest color from
536 % The format of the AffinityImage method is:
538 % MagickBooleanType AffinityImage(const QuantizeInfo *quantize_info,
539 % Image *image,const Image *affinity_image)
541 % A description of each parameter follows:
543 % o quantize_info: Specifies a pointer to an QuantizeInfo structure.
545 % o image: the image.
547 % o affinity_image: the reference image.
550 MagickExport MagickBooleanType AffinityImage(const QuantizeInfo *quantize_info,
551 Image *image,const Image *affinity_image)
553 return(RemapImage(quantize_info,image,affinity_image));
557 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
561 % A f f i n i t y I m a g e s %
565 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
567 % AffinityImages() replaces the colors of a sequence of images with the
568 % closest color from a reference image.
570 % The format of the AffinityImage method is:
572 % MagickBooleanType AffinityImages(const QuantizeInfo *quantize_info,
573 % Image *images,Image *affinity_image)
575 % A description of each parameter follows:
577 % o quantize_info: Specifies a pointer to an QuantizeInfo structure.
579 % o images: the image sequence.
581 % o affinity_image: the reference image.
584 MagickExport MagickBooleanType AffinityImages(const QuantizeInfo *quantize_info,
585 Image *images,const Image *affinity_image)
587 return(RemapImages(quantize_info,images,affinity_image));
591 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595 % A l l o c a t e I m a g e %
599 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
601 % AllocateImage() returns a pointer to an image structure initialized to
604 % The format of the AllocateImage method is:
606 % Image *AllocateImage(const ImageInfo *image_info)
608 % A description of each parameter follows:
610 % o image_info: Many of the image default values are set from this
611 % structure. For example, filename, compression, depth, background color,
615 MagickExport Image *AllocateImage(const ImageInfo *image_info)
617 return(AcquireImage(image_info));
621 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
625 % A l l o c a t e I m a g e C o l o r m a p %
629 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
631 % AllocateImageColormap() allocates an image colormap and initializes
632 % it to a linear gray colorspace. If the image already has a colormap,
633 % it is replaced. AllocateImageColormap() returns MagickTrue if successful,
634 % otherwise MagickFalse if there is not enough memory.
636 % The format of the AllocateImageColormap method is:
638 % MagickBooleanType AllocateImageColormap(Image *image,
639 % const unsigned long colors)
641 % A description of each parameter follows:
643 % o image: the image.
645 % o colors: the number of colors in the image colormap.
648 MagickExport MagickBooleanType AllocateImageColormap(Image *image,
649 const unsigned long colors)
651 return(AcquireImageColormap(image,colors));
655 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
659 % A l l o c a t e N e x t I m a g e %
663 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
665 % AllocateNextImage() initializes the next image in a sequence to
666 % default values. The next member of image points to the newly allocated
667 % image. If there is a memory shortage, next is assigned NULL.
669 % The format of the AllocateNextImage method is:
671 % void AllocateNextImage(const ImageInfo *image_info,Image *image)
673 % A description of each parameter follows:
675 % o image_info: Many of the image default values are set from this
676 % structure. For example, filename, compression, depth, background color,
679 % o image: the image.
682 MagickExport void AllocateNextImage(const ImageInfo *image_info,Image *image)
684 AcquireNextImage(image_info,image);
688 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
692 % A l l o c a t e S t r i n g %
696 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
698 % AllocateString() allocates memory for a string and copies the source string
699 % to that memory location (and returns it).
701 % The format of the AllocateString method is:
703 % char *AllocateString(const char *source)
705 % A description of each parameter follows:
707 % o source: A character string.
710 MagickExport char *AllocateString(const char *source)
718 assert(source != (const char *) NULL);
719 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
720 length=strlen(source)+MaxTextExtent+1;
721 destination=(char *) AcquireQuantumMemory(length,sizeof(*destination));
722 if (destination == (char *) NULL)
723 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
725 if (source != (char *) NULL)
726 (void) CopyMagickString(destination,source,length);
731 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
735 % A v e r a g e I m a g e s %
739 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
741 % AverageImages() takes a set of images and averages them together. Each
742 % image in the set must have the same width and height. AverageImages()
743 % returns a single image with each corresponding pixel component of each
744 % image averaged. On failure, a NULL image is returned and exception
745 % describes the reason for the failure.
747 % The format of the AverageImages method is:
749 % Image *AverageImages(Image *images,ExceptionInfo *exception)
751 % A description of each parameter follows:
753 % o image: the image sequence.
755 % o exception: return any errors or warnings in this structure.
758 MagickExport Image *AverageImages(const Image *images,ExceptionInfo *exception)
760 return(EvaluateImages(images,MeanEvaluateOperator,exception));
764 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
768 % C h a n n e l I m a g e %
772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
774 % Extract a channel from the image. A channel is a particular color component
775 % of each pixel in the image.
777 % The format of the ChannelImage method is:
779 % unsigned int ChannelImage(Image *image,const ChannelType channel)
781 % A description of each parameter follows:
783 % o image: the image.
785 % o channel: Identify which channel to extract: RedChannel, GreenChannel,
786 % BlueChannel, OpacityChannel, CyanChannel, MagentaChannel, YellowChannel,
790 MagickExport unsigned int ChannelImage(Image *image,const ChannelType channel)
792 return(SeparateImageChannel(image,channel));
796 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
800 % C h a n n e l T h r e s h o l d I m a g e %
804 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
806 % ChannelThresholdImage() changes the value of individual pixels based on
807 % the intensity of each pixel channel. The result is a high-contrast image.
809 % The format of the ChannelThresholdImage method is:
811 % unsigned int ChannelThresholdImage(Image *image,const char *level)
813 % A description of each parameter follows:
815 % o image: the image.
817 % o level: define the threshold values.
820 MagickExport unsigned int ChannelThresholdImage(Image *image,const char *level)
832 assert(image != (Image *) NULL);
833 assert(image->signature == MagickSignature);
834 if (image->debug != MagickFalse)
835 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
836 if (image->debug != MagickFalse)
837 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
838 if (level == (char *) NULL)
840 flags=ParseGeometry(level,&geometry_info);
841 threshold.red=geometry_info.rho;
842 threshold.green=geometry_info.sigma;
843 if ((flags & SigmaValue) == 0)
844 threshold.green=threshold.red;
845 threshold.blue=geometry_info.xi;
846 if ((flags & XiValue) == 0)
847 threshold.blue=threshold.red;
848 status=BilevelImageChannel(image,RedChannel,threshold.red);
849 status|=BilevelImageChannel(image,GreenChannel,threshold.green);
850 status|=BilevelImageChannel(image,BlueChannel,threshold.blue);
855 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
859 % C l i p I m a g e P a t h %
863 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
865 % ClipPathImage() sets the image clip mask based any clipping path information
868 % The format of the ClipImage method is:
870 % MagickBooleanType ClipPathImage(Image *image,const char *pathname,
871 % const MagickBooleanType inside)
873 % A description of each parameter follows:
875 % o image: the image.
877 % o pathname: name of clipping path resource. If name is preceded by #, use
878 % clipping path numbered by name.
880 % o inside: if non-zero, later operations take effect inside clipping path.
881 % Otherwise later operations take effect outside clipping path.
884 MagickExport MagickBooleanType ClipPathImage(Image *image,const char *pathname,
885 const MagickBooleanType inside)
887 return(ClipImagePath(image,pathname,inside));
891 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
895 % C l o n e I m a g e A t t r i b u t e s %
899 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
901 % CloneImageAttributes() clones one or more image attributes.
903 % The format of the CloneImageAttributes method is:
905 % MagickBooleanType CloneImageAttributes(Image *image,
906 % const Image *clone_image)
908 % A description of each parameter follows:
910 % o image: the image.
912 % o clone_image: the clone image.
915 MagickExport MagickBooleanType CloneImageAttributes(Image *image,
916 const Image *clone_image)
918 return(CloneImageProperties(image,clone_image));
922 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
926 % C l o n e M e m o r y %
930 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
932 % CloneMemory() copies size bytes from memory area source to the destination.
933 % Copying between objects that overlap will take place correctly. It returns
936 % The format of the CloneMemory method is:
938 % void *CloneMemory(void *destination,const void *source,
941 % A description of each parameter follows:
943 % o destination: the destination.
945 % o source: the source.
947 % o size: the size of the memory in bytes to allocate.
950 MagickExport void *CloneMemory(void *destination,const void *source,
953 register const unsigned char
956 register unsigned char
962 assert(destination != (void *) NULL);
963 assert(source != (const void *) NULL);
964 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
965 p=(const unsigned char *) source;
966 q=(unsigned char *) destination;
967 if ((p <= q) || ((p+size) >= q))
968 return(CopyMagickMemory(destination,source,size));
970 Overlap, copy backwards.
974 for (i=(long) (size-1); i >= 0; i--)
980 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
984 % C l o s e C a c h e V i e w %
988 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
990 % CloseCacheView() closes the specified view returned by a previous call to
993 % The format of the CloseCacheView method is:
995 % CacheView *CloseCacheView(CacheView *view_info)
997 % A description of each parameter follows:
999 % o view_info: the address of a structure of type CacheView.
1002 MagickExport CacheView *CloseCacheView(CacheView *view_info)
1004 return(DestroyCacheView(view_info));
1008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012 % C o l o r F l o o d f i l l I m a g e %
1016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1018 % ColorFloodfill() changes the color value of any pixel that matches
1019 % target and is an immediate neighbor. If the method FillToBorderMethod is
1020 % specified, the color value is changed for any neighbor pixel that does not
1021 % match the bordercolor member of image.
1023 % By default target must match a particular pixel color exactly.
1024 % However, in many cases two colors may differ by a small amount. The
1025 % fuzz member of image defines how much tolerance is acceptable to
1026 % consider two colors as the same. For example, set fuzz to 10 and the
1027 % color red at intensities of 100 and 102 respectively are now
1028 % interpreted as the same color for the purposes of the floodfill.
1030 % The format of the ColorFloodfillImage method is:
1032 % MagickBooleanType ColorFloodfillImage(Image *image,
1033 % const DrawInfo *draw_info,const PixelPacket target,
1034 % const long x_offset,const long y_offset,const PaintMethod method)
1036 % A description of each parameter follows:
1038 % o image: the image.
1040 % o draw_info: the draw info.
1042 % o target: the RGB value of the target color.
1044 % o x,y: the starting location of the operation.
1046 % o method: Choose either FloodfillMethod or FillToBorderMethod.
1050 #define MaxStacksize (1UL << 15)
1051 #define PushSegmentStack(up,left,right,delta) \
1053 if (s >= (segment_stack+MaxStacksize)) \
1054 ThrowBinaryException(DrawError,"SegmentStackOverflow",image->filename) \
1057 if ((((up)+(delta)) >= 0) && (((up)+(delta)) < (long) image->rows)) \
1059 s->x1=(double) (left); \
1060 s->y1=(double) (up); \
1061 s->x2=(double) (right); \
1062 s->y2=(double) (delta); \
1068 MagickExport MagickBooleanType ColorFloodfillImage(Image *image,
1069 const DrawInfo *draw_info,const PixelPacket target,const long x_offset,
1070 const long y_offset,const PaintMethod method)
1089 register SegmentInfo
1096 Check boundary conditions.
1098 assert(image != (Image *) NULL);
1099 assert(image->signature == MagickSignature);
1100 if (image->debug != MagickFalse)
1101 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1102 assert(draw_info != (DrawInfo *) NULL);
1103 assert(draw_info->signature == MagickSignature);
1104 if ((x_offset < 0) || (x_offset >= (long) image->columns))
1105 return(MagickFalse);
1106 if ((y_offset < 0) || (y_offset >= (long) image->rows))
1107 return(MagickFalse);
1108 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1109 return(MagickFalse);
1110 if (image->matte == MagickFalse)
1111 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
1112 floodplane_image=CloneImage(image,image->columns,image->rows,MagickTrue,
1114 if (floodplane_image == (Image *) NULL)
1115 return(MagickFalse);
1116 (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel);
1118 Set floodfill color.
1120 segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
1121 sizeof(*segment_stack));
1122 if (segment_stack == (SegmentInfo *) NULL)
1124 floodplane_image=DestroyImage(floodplane_image);
1125 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
1129 Push initial segment on stack.
1135 PushSegmentStack(y,x,x,1);
1136 PushSegmentStack(y+1,x,x,-1);
1137 while (s > segment_stack)
1139 register const PixelPacket
1145 register PixelPacket
1149 Pop segment off stack.
1154 offset=(long) s->y2;
1155 y=(long) s->y1+offset;
1157 Recolor neighboring pixels.
1159 p=GetVirtualPixels(image,0,y,(unsigned long) (x1+1),1,&image->exception);
1160 q=GetAuthenticPixels(floodplane_image,0,y,(unsigned long) (x1+1),1,
1162 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
1166 for (x=x1; x >= 0; x--)
1168 if (q->opacity == (Quantum) TransparentOpacity)
1170 if (method == FloodfillMethod)
1172 if (IsColorSimilar(image,p,&target) == MagickFalse)
1176 if (IsColorSimilar(image,p,&target) != MagickFalse)
1178 q->opacity=(Quantum) TransparentOpacity;
1182 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
1184 skip=x >= x1 ? MagickTrue : MagickFalse;
1185 if (skip == MagickFalse)
1189 PushSegmentStack(y,start,x1-1,-offset);
1194 if (skip == MagickFalse)
1196 if (x < (long) image->columns)
1198 p=GetVirtualPixels(image,x,y,image->columns-x,1,
1200 q=GetAuthenticPixels(floodplane_image,x,y,image->columns-x,1,
1202 if ((p == (const PixelPacket *) NULL) ||
1203 (q == (PixelPacket *) NULL))
1205 for ( ; x < (long) image->columns; x++)
1207 if (q->opacity == (Quantum) TransparentOpacity)
1209 if (method == FloodfillMethod)
1211 if (IsColorSimilar(image,p,&target) == MagickFalse)
1215 if (IsColorSimilar(image,p,&target) != MagickFalse)
1217 q->opacity=(Quantum) TransparentOpacity;
1221 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
1224 PushSegmentStack(y,start,x-1,offset);
1226 PushSegmentStack(y,x2+1,x-1,-offset);
1232 p=GetVirtualPixels(image,x,y,(unsigned long) (x2-x+1),1,
1234 q=GetAuthenticPixels(floodplane_image,x,y,(unsigned long) (x2-x+1),1,
1236 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
1238 for ( ; x <= x2; x++)
1240 if (q->opacity == (Quantum) TransparentOpacity)
1242 if (method == FloodfillMethod)
1244 if (IsColorSimilar(image,p,&target) != MagickFalse)
1248 if (IsColorSimilar(image,p,&target) == MagickFalse)
1257 for (y=0; y < (long) image->rows; y++)
1259 register const PixelPacket
1265 register PixelPacket
1269 Tile fill color onto floodplane.
1271 p=GetVirtualPixels(floodplane_image,0,y,image->columns,1,
1273 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
1274 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
1276 for (x=0; x < (long) image->columns; x++)
1278 if (p->opacity != OpaqueOpacity)
1280 (void) GetFillColor(draw_info,x,y,&fill_color);
1281 MagickCompositeOver(&fill_color,(MagickRealType) fill_color.opacity,q,
1282 (MagickRealType) q->opacity,q);
1287 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
1290 segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
1291 floodplane_image=DestroyImage(floodplane_image);
1292 return(y == (long) image->rows ? MagickTrue : MagickFalse);
1296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1300 % D e l e t e I m a g e A t t r i b u t e %
1304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1306 % DeleteImageAttribute() deletes an attribute from the image.
1308 % The format of the DeleteImageAttribute method is:
1310 % MagickBooleanType DeleteImageAttribute(Image *image,const char *key)
1312 % A description of each parameter follows:
1314 % o image: the image info.
1316 % o key: the image key.
1319 MagickExport MagickBooleanType DeleteImageAttribute(Image *image,
1322 return(DeleteImageProperty(image,key));
1326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1330 % D e l e t e I m a g e L i s t %
1334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1336 % DeleteImageList() deletes an image at the specified position in the list.
1338 % The format of the DeleteImageList method is:
1340 % unsigned int DeleteImageList(Image *images,const long offset)
1342 % A description of each parameter follows:
1344 % o images: the image list.
1346 % o offset: the position within the list.
1349 MagickExport unsigned int DeleteImageList(Image *images,const long offset)
1354 if (images->debug != MagickFalse)
1355 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
1356 while (GetPreviousImageInList(images) != (Image *) NULL)
1357 images=GetPreviousImageInList(images);
1358 for (i=0; i < offset; i++)
1360 if (GetNextImageInList(images) == (Image *) NULL)
1361 return(MagickFalse);
1362 images=GetNextImageInList(images);
1364 DeleteImageFromList(&images);
1369 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1373 % D e l e t e M a g i c k R e g i s t r y %
1377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1379 % DeleteMagickRegistry() deletes an entry in the registry as defined by the id.
1380 % It returns MagickTrue if the entry is deleted otherwise MagickFalse if no
1381 % entry is found in the registry that matches the id.
1383 % The format of the DeleteMagickRegistry method is:
1385 % MagickBooleanType DeleteMagickRegistry(const long id)
1387 % A description of each parameter follows:
1389 % o id: the registry id.
1392 MagickExport MagickBooleanType DeleteMagickRegistry(const long id)
1397 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
1398 return(DeleteImageRegistry(key));
1402 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1406 + D e s t r o y M a g i c k R e g i s t r y %
1410 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1412 % DestroyMagickRegistry() deallocates memory associated the magick registry.
1414 % The format of the DestroyMagickRegistry method is:
1416 % void DestroyMagickRegistry(void)
1419 MagickExport void DestroyMagickRegistry(void)
1421 RegistryComponentTerminus();
1425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1429 % D e s c r i b e I m a g e %
1433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1435 % DescribeImage() describes an image by printing its attributes to the file.
1436 % Attributes include the image width, height, size, and others.
1438 % The format of the DescribeImage method is:
1440 % MagickBooleanType DescribeImage(Image *image,FILE *file,
1441 % const MagickBooleanType verbose)
1443 % A description of each parameter follows:
1445 % o image: the image.
1447 % o file: the file, typically stdout.
1449 % o verbose: A value other than zero prints more detailed information
1453 MagickExport MagickBooleanType DescribeImage(Image *image,FILE *file,
1454 const MagickBooleanType verbose)
1456 return(IdentifyImage(image,file,verbose));
1460 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1464 % D e s t r o y I m a g e A t t r i b u t e s %
1468 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1470 % DestroyImageAttributes() deallocates memory associated with the image
1473 % The format of the DestroyImageAttributes method is:
1475 % DestroyImageAttributes(Image *image)
1477 % A description of each parameter follows:
1479 % o image: the image.
1482 MagickExport void DestroyImageAttributes(Image *image)
1484 assert(image != (Image *) NULL);
1485 assert(image->signature == MagickSignature);
1486 if (image->debug != MagickFalse)
1487 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1488 if (image->attributes != (void *) NULL)
1489 image->attributes=(void *) DestroySplayTree((SplayTreeInfo *)
1494 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1498 % D e s t r o y I m a g e s %
1502 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1504 % DestroyImages() destroys an image list.
1506 % The format of the DestroyImages method is:
1508 % void DestroyImages(Image *image)
1510 % A description of each parameter follows:
1512 % o image: the image sequence.
1515 MagickExport void DestroyImages(Image *image)
1517 if (image == (Image *) NULL)
1519 if (image->debug != MagickFalse)
1520 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.3");
1521 image=DestroyImageList(image);
1525 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1529 % D e s t r o y M a g i c k %
1533 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1535 % DestroyMagick() destroys the ImageMagick environment.
1537 % The format of the DestroyMagick function is:
1539 % DestroyMagick(void)
1542 MagickExport void DestroyMagick(void)
1544 MagickCoreTerminus();
1548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1552 % D i s p a t c h I m a g e %
1556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1558 % DispatchImage() extracts pixel data from an image and returns it to you.
1559 % The method returns MagickFalse on success otherwise MagickTrue if an error is
1560 % encountered. The data is returned as char, short int, int, long, float,
1561 % or double in the order specified by map.
1563 % Suppose you want to extract the first scanline of a 640x480 image as
1564 % character data in red-green-blue order:
1566 % DispatchImage(image,0,0,640,1,"RGB",CharPixel,pixels,exception);
1568 % The format of the DispatchImage method is:
1570 % unsigned int DispatchImage(const Image *image,const long x_offset,
1571 % const long y_offset,const unsigned long columns,
1572 % const unsigned long rows,const char *map,const StorageType type,
1573 % void *pixels,ExceptionInfo *exception)
1575 % A description of each parameter follows:
1577 % o image: the image.
1579 % o x_offset, y_offset, columns, rows: These values define the perimeter
1580 % of a region of pixels you want to extract.
1582 % o map: This string reflects the expected ordering of the pixel array.
1583 % It can be any combination or order of R = red, G = green, B = blue,
1584 % A = alpha, C = cyan, Y = yellow, M = magenta, K = black, or
1585 % I = intensity (for grayscale).
1587 % o type: Define the data type of the pixels. Float and double types are
1588 % normalized to [0..1] otherwise [0..QuantumRange]. Choose from these
1589 % types: CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel, or
1592 % o pixels: This array of values contain the pixel components as defined by
1593 % map and type. You must preallocate this array where the expected
1594 % length varies depending on the values of width, height, map, and type.
1596 % o exception: return any errors or warnings in this structure.
1599 MagickExport unsigned int DispatchImage(const Image *image,const long x_offset,
1600 const long y_offset,const unsigned long columns,const unsigned long rows,
1601 const char *map,const StorageType type,void *pixels,ExceptionInfo *exception)
1606 if (image->debug != MagickFalse)
1607 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
1608 status=ExportImagePixels(image,x_offset,y_offset,columns,rows,map,type,pixels,
1614 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1618 % E x t r a c t S u b i m a g e F r o m I m a g e %
1622 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1624 % ExtractSubimageFromImageImage() extracts a region of the image that most
1625 % closely resembles the reference.
1627 % The format of the ExtractSubimageFromImageImage method is:
1629 % Image *ExtractSubimageFromImage(const Image *image,const Image *reference,
1630 % ExceptionInfo *exception)
1632 % A description of each parameter follows:
1634 % o image: the image.
1636 % o reference: find an area of the image that closely resembles this image.
1638 % o exception: return any errors or warnings in this structure.
1642 static double GetSimilarityMetric(const Image *image,const Image *reference,
1643 const long x_offset,const long y_offset,const double similarity_threshold,
1644 ExceptionInfo *exception)
1655 normalized_similarity,
1659 Compute the similarity in pixels between two images.
1661 normalized_similarity=1.0;
1664 if ((image->matte != MagickFalse) && (reference->matte != MagickFalse))
1666 if ((image->colorspace == CMYKColorspace) &&
1667 (reference->colorspace == CMYKColorspace))
1669 image_view=AcquireCacheView(image);
1670 reference_view=AcquireCacheView(reference);
1671 for (y=0; y < (long) reference->rows; y++)
1673 register const IndexPacket
1677 register const PixelPacket
1684 p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset+y,
1685 reference->columns,1,exception);
1686 q=GetCacheViewVirtualPixels(reference_view,0,y,reference->columns,1,
1688 if ((p == (const PixelPacket *) NULL) || (q == (const PixelPacket *) NULL))
1690 indexes=GetCacheViewVirtualIndexQueue(image_view);
1691 reference_indexes=GetCacheViewVirtualIndexQueue(reference_view);
1692 for (x=0; x < (long) reference->columns; x++)
1697 pixel=QuantumScale*(p->red-(double) q->red);
1698 similarity+=pixel*pixel;
1699 pixel=QuantumScale*(p->green-(double) q->green);
1700 similarity+=pixel*pixel;
1701 pixel=QuantumScale*(p->blue-(double) q->blue);
1702 similarity+=pixel*pixel;
1703 if ((image->matte != MagickFalse) && (reference->matte != MagickFalse))
1705 pixel=QuantumScale*(p->opacity-(double) q->opacity);
1706 similarity+=pixel*pixel;
1708 if ((image->colorspace == CMYKColorspace) &&
1709 (reference->colorspace == CMYKColorspace))
1711 pixel=QuantumScale*(indexes[x]-(double) reference_indexes[x]);
1712 similarity+=pixel*pixel;
1717 normalized_similarity=sqrt(similarity)/reference->columns/reference->rows/
1719 if (normalized_similarity > similarity_threshold)
1722 reference_view=DestroyCacheView(reference_view);
1723 image_view=DestroyCacheView(image_view);
1724 return(normalized_similarity);
1727 MagickExport Image *ExtractSubimageFromImage(Image *image,
1728 const Image *reference,ExceptionInfo *exception)
1734 similarity_threshold;
1740 Extract reference from image.
1742 if ((reference->columns > image->columns) || (reference->rows > image->rows))
1743 return((Image *) NULL);
1744 similarity_threshold=(double) image->columns*image->rows;
1745 SetGeometry(reference,&offset);
1746 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1747 #pragma omp parallel for schedule(dynamic,4)
1749 for (y=0; y < (long) (image->rows-reference->rows); y++)
1757 for (x=0; x < (long) (image->columns-reference->columns); x++)
1759 similarity=GetSimilarityMetric(image,reference,x,y,similarity_threshold,
1761 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1762 #pragma omp critical (MagickCore_ExtractSubimageFromImage)
1764 if (similarity < similarity_threshold)
1766 similarity_threshold=similarity;
1772 if (similarity_threshold > (QuantumScale*reference->fuzz/100.0))
1773 return((Image *) NULL);
1774 return(CropImage(image,&offset,exception));
1778 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1782 % F l a t t e n I m a g e %
1786 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1788 % FlattenImages() Obsolete Function: Use MergeImageLayers() instead.
1790 % The format of the FlattenImage method is:
1792 % Image *FlattenImage(Image *image,ExceptionInfo *exception)
1794 % A description of each parameter follows:
1796 % o image: the image sequence.
1798 % o exception: return any errors or warnings in this structure.
1801 MagickExport Image *FlattenImages(Image *image,ExceptionInfo *exception)
1803 return(MergeImageLayers(image,FlattenLayer,exception));
1807 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1811 % F o r m a t I m a g e A t t r i b u t e %
1815 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1817 % FormatImageAttribute() permits formatted key/value pairs to be saved as an
1820 % The format of the FormatImageAttribute method is:
1822 % MagickBooleanType FormatImageAttribute(Image *image,const char *key,
1823 % const char *format,...)
1825 % A description of each parameter follows.
1827 % o image: The image.
1829 % o key: The attribute key.
1831 % o format: A string describing the format to use to write the remaining
1836 MagickExport MagickBooleanType FormatImageAttributeList(Image *image,
1837 const char *key,const char *format,va_list operands)
1840 value[MaxTextExtent];
1845 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
1846 n=vsnprintf(value,MaxTextExtent,format,operands);
1848 n=vsprintf(value,format,operands);
1851 value[MaxTextExtent-1]='\0';
1852 return(SetImageProperty(image,key,value));
1855 MagickExport MagickBooleanType FormatImageAttribute(Image *image,
1856 const char *key,const char *format,...)
1864 va_start(operands,format);
1865 status=FormatImagePropertyList(image,key,format,operands);
1871 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1875 % F o r m a t S t r i n g %
1879 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1881 % FormatString() prints formatted output of a variable argument list.
1883 % The format of the FormatString method is:
1885 % void FormatString(char *string,const char *format,...)
1887 % A description of each parameter follows.
1889 % o string: Method FormatString returns the formatted string in this
1892 % o format: A string describing the format to use to write the remaining
1897 MagickExport void FormatStringList(char *string,const char *format,
1903 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
1904 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
1905 n=vsnprintf(string,MaxTextExtent,format,operands);
1907 n=vsprintf(string,format,operands);
1910 string[MaxTextExtent-1]='\0';
1913 MagickExport void FormatString(char *string,const char *format,...)
1918 va_start(operands,format);
1919 (void) FormatMagickStringList(string,MaxTextExtent,format,operands);
1925 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1929 + F u z z y C o l o r M a t c h %
1933 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1935 % FuzzyColorMatch() returns true if two pixels are identical in color.
1937 % The format of the ColorMatch method is:
1939 % void FuzzyColorMatch(const PixelPacket *p,const PixelPacket *q,
1940 % const double fuzz)
1942 % A description of each parameter follows:
1948 % o distance: Define how much tolerance is acceptable to consider
1949 % two colors as the same.
1952 MagickExport unsigned int FuzzyColorMatch(const PixelPacket *p,
1953 const PixelPacket *q,const double fuzz)
1958 register MagickRealType
1961 if ((fuzz == 0.0) && (p->red == q->red) && (p->green == q->green) &&
1962 (p->blue == q->blue))
1964 pixel.red=p->red-(MagickRealType) q->red;
1965 distance=pixel.red*pixel.red;
1966 if (distance > (fuzz*fuzz))
1967 return(MagickFalse);
1968 pixel.green=p->green-(MagickRealType) q->green;
1969 distance+=pixel.green*pixel.green;
1970 if (distance > (fuzz*fuzz))
1971 return(MagickFalse);
1972 pixel.blue=p->blue-(MagickRealType) q->blue;
1973 distance+=pixel.blue*pixel.blue;
1974 if (distance > (fuzz*fuzz))
1975 return(MagickFalse);
1980 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1984 + F u z z y C o l o r C o m p a r e %
1988 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1990 % FuzzyColorCompare() returns MagickTrue if the distance between two colors is
1991 % less than the specified distance in a linear three dimensional color space.
1992 % This method is used by ColorFloodFill() and other algorithms which
1993 % compare two colors.
1995 % The format of the FuzzyColorCompare method is:
1997 % void FuzzyColorCompare(const Image *image,const PixelPacket *p,
1998 % const PixelPacket *q)
2000 % A description of each parameter follows:
2002 % o image: the image.
2009 MagickExport MagickBooleanType FuzzyColorCompare(const Image *image,
2010 const PixelPacket *p,const PixelPacket *q)
2012 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.5");
2013 return(IsColorSimilar(image,p,q));
2017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2021 + F u z z y O p a c i t y C o m p a r e %
2025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2027 % FuzzyOpacityCompare() returns true if the distance between two opacity
2028 % values is less than the specified distance in a linear color space. This
2029 % method is used by MatteFloodFill() and other algorithms which compare
2030 % two opacity values.
2032 % The format of the FuzzyOpacityCompare method is:
2034 % void FuzzyOpacityCompare(const Image *image,const PixelPacket *p,
2035 % const PixelPacket *q)
2037 % A description of each parameter follows:
2039 % o image: the image.
2046 MagickExport MagickBooleanType FuzzyOpacityCompare(const Image *image,
2047 const PixelPacket *p,const PixelPacket *q)
2049 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.5");
2050 return(IsOpacitySimilar(image,p,q));
2054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2058 % G e t C o n f i g u r e B l o b %
2062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2064 % GetConfigureBlob() returns the specified configure file as a blob.
2066 % The format of the GetConfigureBlob method is:
2068 % void *GetConfigureBlob(const char *filename,ExceptionInfo *exception)
2070 % A description of each parameter follows:
2072 % o filename: the configure file name.
2074 % o path: return the full path information of the configure file.
2076 % o length: This pointer to a size_t integer sets the initial length of the
2077 % blob. On return, it reflects the actual length of the blob.
2079 % o exception: return any errors or warnings in this structure.
2082 MagickExport void *GetConfigureBlob(const char *filename,char *path,
2083 size_t *length,ExceptionInfo *exception)
2088 assert(filename != (const char *) NULL);
2089 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
2090 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
2091 assert(path != (char *) NULL);
2092 assert(length != (size_t *) NULL);
2093 assert(exception != (ExceptionInfo *) NULL);
2095 (void) CopyMagickString(path,filename,MaxTextExtent);
2096 #if defined(MAGICKCORE_INSTALLED_SUPPORT)
2097 #if defined(MAGICKCORE_LIBRARY_PATH)
2098 if (blob == (void *) NULL)
2101 Search hard coded paths.
2103 (void) FormatMagickString(path,MaxTextExtent,"%s%s",
2104 MAGICKCORE_LIBRARY_PATH,filename);
2105 if (IsPathAccessible(path) != MagickFalse)
2106 blob=FileToBlob(path,~0,length,exception);
2109 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !(defined(MAGICKCORE_CONFIGURE_PATH) || defined(MAGICKCORE_SHARE_CONFIGURE_PATH))
2110 if (blob == (void *) NULL)
2116 Locate file via registry key.
2118 key_value=NTRegistryKeyLookup("ConfigurePath");
2119 if (key_value != (char *) NULL)
2121 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",key_value,
2122 DirectorySeparator,filename);
2123 if (IsPathAccessible(path) != MagickFalse)
2124 blob=FileToBlob(path,~0,length,exception);
2129 if (blob == (void *) NULL)
2134 home=GetEnvironmentValue("MAGICK_HOME");
2135 if (home != (char *) NULL)
2140 #if !defined(MAGICKCORE_POSIX_SUPPORT)
2141 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",home,
2142 DirectorySeparator,filename);
2144 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/%s",home,
2145 MAGICKCORE_LIBRARY_RELATIVE_PATH,filename);
2147 if (IsPathAccessible(path) != MagickFalse)
2148 blob=FileToBlob(path,~0,length,exception);
2149 home=DestroyString(home);
2151 home=GetEnvironmentValue("HOME");
2152 if (home == (char *) NULL)
2153 home=GetEnvironmentValue("USERPROFILE");
2154 if (home != (char *) NULL)
2157 Search $HOME/.magick.
2159 (void) FormatMagickString(path,MaxTextExtent,"%s%s.magick%s%s",home,
2160 DirectorySeparator,DirectorySeparator,filename);
2161 if ((IsPathAccessible(path) != MagickFalse) && (blob == (void *) NULL))
2162 blob=FileToBlob(path,~0,length,exception);
2163 home=DestroyString(home);
2166 if ((blob == (void *) NULL) && (*GetClientPath() != '\0'))
2168 #if !defined(MAGICKCORE_POSIX_SUPPORT)
2169 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",GetClientPath(),
2170 DirectorySeparator,filename);
2173 prefix[MaxTextExtent];
2176 Search based on executable directory if directory is known.
2178 (void) CopyMagickString(prefix,GetClientPath(),
2180 ChopPathComponents(prefix,1);
2181 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/%s",prefix,
2182 MAGICKCORE_LIBRARY_RELATIVE_PATH,filename);
2184 if (IsPathAccessible(path) != MagickFalse)
2185 blob=FileToBlob(path,~0,length,exception);
2188 Search current directory.
2190 if ((blob == (void *) NULL) && (IsPathAccessible(path) != MagickFalse))
2191 blob=FileToBlob(path,~0,length,exception);
2192 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
2194 Search Windows registry.
2196 if (blob == (void *) NULL)
2197 blob=NTResourceToBlob(filename);
2200 if (blob == (void *) NULL)
2201 (void) ThrowMagickException(exception,GetMagickModule(),ConfigureWarning,
2202 "UnableToOpenConfigureFile","`%s'",path);
2207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2211 % G e t C a c h e V i e w %
2215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2217 % GetCacheView() gets pixels from the in-memory or disk pixel cache as
2218 % defined by the geometry parameters. A pointer to the pixels is returned if
2219 % the pixels are transferred, otherwise a NULL is returned.
2221 % The format of the GetCacheView method is:
2223 % PixelPacket *GetCacheView(CacheView *cache_view,const long x,
2224 % const long y,const unsigned long columns,const unsigned long rows)
2226 % A description of each parameter follows:
2228 % o cache_view: the address of a structure of type CacheView.
2230 % o x,y,columns,rows: These values define the perimeter of a region of
2234 MagickExport PixelPacket *GetCacheView(CacheView *cache_view,const long x,
2235 const long y,const unsigned long columns,const unsigned long rows)
2240 pixels=GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2241 GetCacheViewException(cache_view));
2246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2250 % G e t C a c h e V i e w I n d e x e s %
2254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2256 % GetCacheViewIndexes() returns the indexes associated with the specified
2259 % The format of the GetCacheViewIndexes method is:
2261 % IndexPacket *GetCacheViewIndexes(CacheView *cache_view)
2263 % A description of each parameter follows:
2265 % o cache_view: the cache view.
2268 MagickExport IndexPacket *GetCacheViewIndexes(CacheView *cache_view)
2270 return(GetCacheViewAuthenticIndexQueue(cache_view));
2274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2278 % G e t C a c h e V i e w P i x e l s %
2282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2284 % GetCacheViewPixels() gets pixels from the in-memory or disk pixel cache as
2285 % defined by the geometry parameters. A pointer to the pixels is returned if
2286 % the pixels are transferred, otherwise a NULL is returned.
2288 % The format of the GetCacheViewPixels method is:
2290 % PixelPacket *GetCacheViewPixels(CacheView *cache_view,const long x,
2291 % const long y,const unsigned long columns,const unsigned long rows)
2293 % A description of each parameter follows:
2295 % o cache_view: the cache view.
2297 % o x,y,columns,rows: These values define the perimeter of a region of
2301 MagickExport PixelPacket *GetCacheViewPixels(CacheView *cache_view,const long x,
2302 const long y,const unsigned long columns,const unsigned long rows)
2307 pixels=GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2308 GetCacheViewException(cache_view));
2313 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2317 % G e t I m a g e A t t r i b u t e %
2321 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2323 % GetImageAttribute() searches the list of image attributes and returns
2324 % a pointer to the attribute if it exists otherwise NULL.
2326 % The format of the GetImageAttribute method is:
2328 % const ImageAttribute *GetImageAttribute(const Image *image,
2331 % A description of each parameter follows:
2333 % o image: the image.
2335 % o key: These character strings are the name of an image attribute to
2340 static void *DestroyAttribute(void *attribute)
2342 register ImageAttribute
2345 p=(ImageAttribute *) attribute;
2346 if (p->value != (char *) NULL)
2347 p->value=DestroyString(p->value);
2348 return(RelinquishMagickMemory(p));
2351 MagickExport const ImageAttribute *GetImageAttribute(const Image *image,
2360 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
2361 value=GetImageProperty(image,key);
2362 if (value == (const char *) NULL)
2363 return((const ImageAttribute *) NULL);
2364 if (image->attributes == (void *) NULL)
2365 ((Image *) image)->attributes=NewSplayTree(CompareSplayTreeString,
2366 RelinquishMagickMemory,DestroyAttribute);
2369 const ImageAttribute
2372 attribute=(const ImageAttribute *) GetValueFromSplayTree((SplayTreeInfo *)
2373 image->attributes,key);
2374 if (attribute != (const ImageAttribute *) NULL)
2377 attribute=(ImageAttribute *) AcquireAlignedMemory(1,sizeof(*attribute));
2378 if (attribute == (ImageAttribute *) NULL)
2379 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
2380 (void) ResetMagickMemory(attribute,0,sizeof(*attribute));
2381 attribute->key=ConstantString(key);
2382 attribute->value=ConstantString(value);
2383 (void) AddValueToSplayTree((SplayTreeInfo *) ((Image *) image)->attributes,
2384 attribute->key,attribute);
2385 return((const ImageAttribute *) attribute);
2389 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2393 % G e t I m a g e C l i p p i n g P a t h A t t r i b u t e %
2397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2399 % GetImageClippingPathAttribute() searches the list of image attributes and
2400 % returns a pointer to a clipping path if it exists otherwise NULL.
2402 % The format of the GetImageClippingPathAttribute method is:
2404 % const ImageAttribute *GetImageClippingPathAttribute(Image *image)
2406 % A description of each parameter follows:
2408 % o attribute: Method GetImageClippingPathAttribute returns the clipping
2409 % path if it exists otherwise NULL.
2411 % o image: the image.
2414 MagickExport const ImageAttribute *GetImageClippingPathAttribute(Image *image)
2416 return(GetImageAttribute(image,"8BIM:1999,2998"));
2420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2424 % G e t I m a g e F r o m M a g i c k R e g i s t r y %
2428 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2430 % GetImageFromMagickRegistry() gets an image from the registry as defined by
2431 % its name. If the image is not found, a NULL image is returned.
2433 % The format of the GetImageFromMagickRegistry method is:
2435 % Image *GetImageFromMagickRegistry(const char *name,long *id,
2436 % ExceptionInfo *exception)
2438 % A description of each parameter follows:
2440 % o name: the name of the image to retrieve from the registry.
2442 % o id: the registry id.
2444 % o exception: return any errors or warnings in this structure.
2447 MagickExport Image *GetImageFromMagickRegistry(const char *name,long *id,
2448 ExceptionInfo *exception)
2451 return((Image *) GetImageRegistry(ImageRegistryType,name,exception));
2455 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2459 % G e t M a g i c k R e g i s t r y %
2463 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2465 % GetMagickRegistry() gets a blob from the registry as defined by the id. If
2466 % the blob that matches the id is not found, NULL is returned.
2468 % The format of the GetMagickRegistry method is:
2470 % const void *GetMagickRegistry(const long id,RegistryType *type,
2471 % size_t *length,ExceptionInfo *exception)
2473 % A description of each parameter follows:
2475 % o id: the registry id.
2477 % o type: the registry type.
2479 % o length: the blob length in number of bytes.
2481 % o exception: return any errors or warnings in this structure.
2484 MagickExport void *GetMagickRegistry(const long id,RegistryType *type,
2485 size_t *length,ExceptionInfo *exception)
2493 *type=UndefinedRegistryType;
2495 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
2496 blob=(void *) GetImageRegistry(ImageRegistryType,key,exception);
2497 if (blob != (void *) NULL)
2499 blob=(void *) GetImageRegistry(ImageInfoRegistryType,key,exception);
2500 if (blob != (void *) NULL)
2502 return((void *) GetImageRegistry(UndefinedRegistryType,key,exception));
2506 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2510 % G e t I m a g e G e o m e t r y %
2514 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2516 % GetImageGeometry() returns a region as defined by the geometry string with
2517 % respect to the image and its gravity.
2519 % The format of the GetImageGeometry method is:
2521 % int GetImageGeometry(Image *image,const char *geometry,
2522 % const unsigned int size_to_fit,RectangeInfo *region_info)
2524 % A description of each parameter follows:
2526 % o flags: Method GetImageGeometry returns a bitmask that indicates
2527 % which of the four values were located in the geometry string.
2529 % o geometry: The geometry (e.g. 100x100+10+10).
2531 % o size_to_fit: A value other than 0 means to scale the region so it
2532 % fits within the specified width and height.
2534 % o region_info: the region as defined by the geometry string with
2535 % respect to the image and its gravity.
2538 MagickExport int GetImageGeometry(Image *image,const char *geometry,
2539 const unsigned int size_to_fit,RectangleInfo *region_info)
2541 if (image->debug != MagickFalse)
2542 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.4");
2543 if (size_to_fit != MagickFalse)
2544 return((int) ParseRegionGeometry(image,geometry,region_info,&image->exception));
2545 return((int) ParsePageGeometry(image,geometry,region_info,&image->exception));
2549 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2553 % G e t I m a g e L i s t %
2557 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2559 % GetImageList() returns an image at the specified position in the list.
2561 % The format of the GetImageList method is:
2563 % Image *GetImageList(const Image *images,const long offset,
2564 % ExceptionInfo *exception)
2566 % A description of each parameter follows:
2568 % o images: the image list.
2570 % o offset: the position within the list.
2572 % o exception: return any errors or warnings in this structure.
2575 MagickExport Image *GetImageList(const Image *images,const long offset,
2576 ExceptionInfo *exception)
2581 if (images->debug != MagickFalse)
2582 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2583 image=CloneImage(GetImageFromList(images,(long) offset),0,0,MagickTrue,
2589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2593 % G e t I m a g e L i s t I n d e x %
2597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2599 % GetImageListIndex() returns the position in the list of the specified
2602 % The format of the GetImageListIndex method is:
2604 % long GetImageListIndex(const Image *images)
2606 % A description of each parameter follows:
2608 % o images: the image list.
2611 MagickExport long GetImageListIndex(const Image *images)
2613 if (images->debug != MagickFalse)
2614 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2615 return(GetImageIndexInList(images));
2619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2623 % G e t I m a g e L i s t S i z e %
2627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2629 % GetImageListSize() returns the number of images in the list.
2631 % The format of the GetImageListSize method is:
2633 % unsigned long GetImageListSize(const Image *images)
2635 % A description of each parameter follows:
2637 % o images: the image list.
2640 MagickExport unsigned long GetImageListSize(const Image *images)
2642 if (images->debug != MagickFalse)
2643 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2644 return(GetImageListLength(images));
2648 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2652 % G e t I m a g e P i x e l s %
2656 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2658 % GetImagePixels() obtains a pixel region for read/write access. If the
2659 % region is successfully accessed, a pointer to a PixelPacket array
2660 % representing the region is returned, otherwise NULL is returned.
2662 % The returned pointer may point to a temporary working copy of the pixels
2663 % or it may point to the original pixels in memory. Performance is maximized
2664 % if the selected region is part of one row, or one or more full rows, since
2665 % then there is opportunity to access the pixels in-place (without a copy)
2666 % if the image is in RAM, or in a memory-mapped file. The returned pointer
2667 % should *never* be deallocated by the user.
2669 % Pixels accessed via the returned pointer represent a simple array of type
2670 % PixelPacket. If the image type is CMYK or if the storage class is
2671 % PseduoClass, call GetAuthenticIndexQueue() after invoking GetImagePixels()
2672 % to obtain the black color component or colormap indexes (of type IndexPacket)
2673 % corresponding to the region. Once the PixelPacket (and/or IndexPacket)
2674 % array has been updated, the changes must be saved back to the underlying
2675 % image using SyncAuthenticPixels() or they may be lost.
2677 % The format of the GetImagePixels() method is:
2679 % PixelPacket *GetImagePixels(Image *image,const long x,const long y,
2680 % const unsigned long columns,const unsigned long rows)
2682 % A description of each parameter follows:
2684 % o image: the image.
2686 % o x,y,columns,rows: These values define the perimeter of a region of
2690 MagickExport PixelPacket *GetImagePixels(Image *image,const long x,const long y,
2691 const unsigned long columns,const unsigned long rows)
2693 return(GetAuthenticPixels(image,x,y,columns,rows,&image->exception));
2697 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2701 % G e t I n d e x e s %
2705 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2707 % GetIndexes() returns the black channel or the colormap indexes associated
2708 % with the last call to QueueAuthenticPixels() or GetVirtualPixels(). NULL is
2709 % returned if the black channel or colormap indexes are not available.
2711 % The format of the GetIndexes() method is:
2713 % IndexPacket *GetIndexes(const Image *image)
2715 % A description of each parameter follows:
2717 % o indexes: GetIndexes() returns the indexes associated with the last
2718 % call to QueueAuthenticPixels() or GetAuthenticPixels().
2720 % o image: the image.
2723 MagickExport IndexPacket *GetIndexes(const Image *image)
2725 return(GetAuthenticIndexQueue(image));
2729 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2733 + G e t M a g i c k G e o m e t r y %
2737 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2739 % GetMagickGeometry() is similar to GetGeometry() except the returned
2740 % geometry is modified as determined by the meta characters: %, !, <, >,
2743 % The format of the GetMagickGeometry method is:
2745 % unsigned int GetMagickGeometry(const char *geometry,long *x,long *y,
2746 % unsigned long *width,unsigned long *height)
2748 % A description of each parameter follows:
2750 % o geometry: Specifies a character string representing the geometry
2753 % o x,y: A pointer to an integer. The x and y offset as determined by
2754 % the geometry specification is returned here.
2756 % o width,height: A pointer to an unsigned integer. The width and height
2757 % as determined by the geometry specification is returned here.
2760 MagickExport unsigned int GetMagickGeometry(const char *geometry,long *x,
2761 long *y,unsigned long *width,unsigned long *height)
2763 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.3");
2764 return(ParseMetaGeometry(geometry,x,y,width,height));
2768 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2772 % G e t N e x t I m a g e %
2776 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2778 % GetNextImage() returns the next image in a list.
2780 % The format of the GetNextImage method is:
2782 % Image *GetNextImage(const Image *images)
2784 % A description of each parameter follows:
2786 % o images: the image list.
2789 MagickExport Image *GetNextImage(const Image *images)
2791 if (images->debug != MagickFalse)
2792 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2793 return(GetNextImageInList(images));
2797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2801 % G e t N e x t I m a g e A t t r i b u t e %
2805 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2807 % GetNextImageAttribute() gets the next image attribute.
2809 % The format of the GetNextImageAttribute method is:
2811 % const ImageAttribute *GetNextImageAttribute(const Image *image)
2813 % A description of each parameter follows:
2815 % o image: the image.
2818 MagickExport const ImageAttribute *GetNextImageAttribute(const Image *image)
2823 property=GetNextImageProperty(image);
2824 if (property == (const char *) NULL)
2825 return((const ImageAttribute *) NULL);
2826 return(GetImageAttribute(image,property));
2830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2834 % G e t N u m b e r S c e n e s %
2838 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2840 % GetNumberScenes() returns the number of images in the list.
2842 % The format of the GetNumberScenes method is:
2844 % unsigned int GetNumberScenes(const Image *images)
2846 % A description of each parameter follows:
2848 % o images: the image list.
2851 MagickExport unsigned int GetNumberScenes(const Image *image)
2853 if (image->debug != MagickFalse)
2854 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2855 return((unsigned int) GetImageListLength(image));
2859 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2863 % G e t O n e P i x e l %
2867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2869 % GetOnePixel() returns a single pixel at the specified (x,y) location.
2870 % The image background color is returned if an error occurs.
2872 % The format of the GetOnePixel() method is:
2874 % PixelPacket GetOnePixel(const Image image,const long x,const long y)
2876 % A description of each parameter follows:
2878 % o image: the image.
2880 % o x,y: These values define the location of the pixel to return.
2883 MagickExport PixelPacket GetOnePixel(Image *image,const long x,const long y)
2888 (void) GetOneAuthenticPixel(image,x,y,&pixel,&image->exception);
2893 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2897 % G e t P i x e l s %
2901 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2903 % GetPixels() returns the pixels associated with the last call to
2904 % QueueAuthenticPixels() or GetAuthenticPixels().
2906 % The format of the GetPixels() method is:
2908 % PixelPacket *GetPixels(const Image image)
2910 % A description of each parameter follows:
2912 % o pixels: GetPixels() returns the pixels associated with the last call
2913 % to QueueAuthenticPixels() or GetAuthenticPixels().
2915 % o image: the image.
2918 MagickExport PixelPacket *GetPixels(const Image *image)
2920 return(GetAuthenticPixelQueue(image));
2924 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2928 % G e t P r e v i o u s I m a g e %
2932 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2934 % GetPreviousImage() returns the previous image in a list.
2936 % The format of the GetPreviousImage method is:
2938 % Image *GetPreviousImage(const Image *images)
2940 % A description of each parameter follows:
2942 % o images: the image list.
2945 MagickExport Image *GetPreviousImage(const Image *images)
2947 if (images->debug != MagickFalse)
2948 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2949 return(GetPreviousImageInList(images));
2953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2957 % H S L T r a n s f o r m %
2961 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2963 % HSLTransform() converts a (hue, saturation, lightness) to a (red, green,
2966 % The format of the HSLTransformImage method is:
2968 % void HSLTransform(const double hue,const double saturation,
2969 % const double lightness,Quantum *red,Quantum *green,Quantum *blue)
2971 % A description of each parameter follows:
2973 % o hue, saturation, lightness: A double value representing a
2974 % component of the HSL color space.
2976 % o red, green, blue: A pointer to a pixel component of type Quantum.
2980 static inline MagickRealType HueToRGB(MagickRealType m1,MagickRealType m2,
2987 if ((6.0*hue) < 1.0)
2988 return(m1+6.0*(m2-m1)*hue);
2989 if ((2.0*hue) < 1.0)
2991 if ((3.0*hue) < 2.0)
2992 return(m1+6.0*(m2-m1)*(2.0/3.0-hue));
2996 MagickExport void HSLTransform(const double hue,const double saturation,
2997 const double lightness,Quantum *red,Quantum *green,Quantum *blue)
3007 Convert HSL to RGB colorspace.
3009 assert(red != (Quantum *) NULL);
3010 assert(green != (Quantum *) NULL);
3011 assert(blue != (Quantum *) NULL);
3012 if (lightness <= 0.5)
3013 m2=lightness*(saturation+1.0);
3015 m2=lightness+saturation-lightness*saturation;
3016 m1=2.0*lightness-m2;
3017 r=HueToRGB(m1,m2,hue+1.0/3.0);
3018 g=HueToRGB(m1,m2,hue);
3019 b=HueToRGB(m1,m2,hue-1.0/3.0);
3020 *red=ClampToQuantum((MagickRealType) QuantumRange*r);
3021 *green=ClampToQuantum((MagickRealType) QuantumRange*g);
3022 *blue=ClampToQuantum((MagickRealType) QuantumRange*b);
3026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3030 % I d e n t i t y A f f i n e %
3034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3036 % IdentityAffine() initializes the affine transform to the identity matrix.
3038 % The format of the IdentityAffine method is:
3040 % IdentityAffine(AffineMatrix *affine)
3042 % A description of each parameter follows:
3044 % o affine: A pointer the affine transform of type AffineMatrix.
3047 MagickExport void IdentityAffine(AffineMatrix *affine)
3049 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3050 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3051 assert(affine != (AffineMatrix *) NULL);
3052 (void) ResetMagickMemory(affine,0,sizeof(AffineMatrix));
3058 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3062 % I n i t i a l i z e M a g i c k %
3066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3068 % InitializeMagick() initializes the ImageMagick environment.
3070 % The format of the InitializeMagick function is:
3072 % InitializeMagick(const char *path)
3074 % A description of each parameter follows:
3076 % o path: the execution path of the current ImageMagick client.
3079 MagickExport void InitializeMagick(const char *path)
3081 MagickCoreGenesis(path,MagickFalse);
3085 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3089 % I n t e r p o l a t e P i x e l C o l o r %
3093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3095 % InterpolatePixelColor() applies bi-linear or tri-linear interpolation
3096 % between a pixel and it's neighbors.
3098 % The format of the InterpolatePixelColor method is:
3100 % MagickPixelPacket InterpolatePixelColor(const Image *image,
3101 % CacheView *view_info,InterpolatePixelMethod method,const double x,
3102 % const double y,ExceptionInfo *exception)
3104 % A description of each parameter follows:
3106 % o image: the image.
3108 % o image_view: the image cache view.
3110 % o type: the type of pixel color interpolation.
3112 % o x,y: A double representing the current (x,y) position of the pixel.
3114 % o exception: return any errors or warnings in this structure.
3118 static inline double MagickMax(const double x,const double y)
3125 static void BicubicInterpolate(const MagickPixelPacket *pixels,const double dx,
3126 MagickPixelPacket *pixel)
3136 p=(pixels[3].red-pixels[2].red)-(pixels[0].red-pixels[1].red);
3137 q=(pixels[0].red-pixels[1].red)-p;
3138 r=pixels[2].red-pixels[0].red;
3140 pixel->red=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3141 p=(pixels[3].green-pixels[2].green)-(pixels[0].green-pixels[1].green);
3142 q=(pixels[0].green-pixels[1].green)-p;
3143 r=pixels[2].green-pixels[0].green;
3145 pixel->green=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3146 p=(pixels[3].blue-pixels[2].blue)-(pixels[0].blue-pixels[1].blue);
3147 q=(pixels[0].blue-pixels[1].blue)-p;
3148 r=pixels[2].blue-pixels[0].blue;
3150 pixel->blue=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3151 p=(pixels[3].opacity-pixels[2].opacity)-(pixels[0].opacity-pixels[1].opacity);
3152 q=(pixels[0].opacity-pixels[1].opacity)-p;
3153 r=pixels[2].opacity-pixels[0].opacity;
3154 s=pixels[1].opacity;
3155 pixel->opacity=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3156 if (pixel->colorspace == CMYKColorspace)
3158 p=(pixels[3].index-pixels[2].index)-(pixels[0].index-pixels[1].index);
3159 q=(pixels[0].index-pixels[1].index)-p;
3160 r=pixels[2].index-pixels[0].index;
3162 pixel->index=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3166 static inline MagickRealType CubicWeightingFunction(const MagickRealType x)
3172 alpha=MagickMax(x+2.0,0.0);
3173 gamma=1.0*alpha*alpha*alpha;
3174 alpha=MagickMax(x+1.0,0.0);
3175 gamma-=4.0*alpha*alpha*alpha;
3176 alpha=MagickMax(x+0.0,0.0);
3177 gamma+=6.0*alpha*alpha*alpha;
3178 alpha=MagickMax(x-1.0,0.0);
3179 gamma-=4.0*alpha*alpha*alpha;
3183 static inline double MeshInterpolate(const PointInfo *delta,const double p,
3184 const double x,const double y)
3186 return(delta->x*x+delta->y*y+(1.0-delta->x-delta->y)*p);
3189 static inline long NearestNeighbor(MagickRealType x)
3192 return((long) (x+0.5));
3193 return((long) (x-0.5));
3196 MagickExport MagickPixelPacket InterpolatePixelColor(const Image *image,
3197 CacheView *image_view,const InterpolatePixelMethod method,const double x,
3198 const double y,ExceptionInfo *exception)
3203 register const IndexPacket
3206 register const PixelPacket
3212 assert(image != (Image *) NULL);
3213 assert(image->signature == MagickSignature);
3214 assert(image_view != (CacheView *) NULL);
3215 GetMagickPixelPacket(image,&pixel);
3218 case AverageInterpolatePixel:
3227 p=GetCacheViewVirtualPixels(image_view,(long) floor(x)-1,(long) floor(y)-
3229 if (p == (const PixelPacket *) NULL)
3231 indexes=GetCacheViewVirtualIndexQueue(image_view);
3232 for (i=0; i < 16L; i++)
3234 GetMagickPixelPacket(image,pixels+i);
3235 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3237 if (image->matte != MagickFalse)
3239 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3240 pixels[i].red*=alpha[i];
3241 pixels[i].green*=alpha[i];
3242 pixels[i].blue*=alpha[i];
3243 if (image->colorspace == CMYKColorspace)
3244 pixels[i].index*=alpha[i];
3247 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3248 pixel.red+=gamma*0.0625*pixels[i].red;
3249 pixel.green+=gamma*0.0625*pixels[i].green;
3250 pixel.blue+=gamma*0.0625*pixels[i].blue;
3251 pixel.opacity+=0.0625*pixels[i].opacity;
3252 if (image->colorspace == CMYKColorspace)
3253 pixel.index+=gamma*0.0625*pixels[i].index;
3258 case BicubicInterpolatePixel:
3270 p=GetCacheViewVirtualPixels(image_view,(long) floor(x)-1,(long) floor(y)-
3272 if (p == (const PixelPacket *) NULL)
3274 indexes=GetCacheViewVirtualIndexQueue(image_view);
3275 for (i=0; i < 16L; i++)
3277 GetMagickPixelPacket(image,pixels+i);
3278 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3280 if (image->matte != MagickFalse)
3282 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3283 pixels[i].red*=alpha[i];
3284 pixels[i].green*=alpha[i];
3285 pixels[i].blue*=alpha[i];
3286 if (image->colorspace == CMYKColorspace)
3287 pixels[i].index*=alpha[i];
3292 for (i=0; i < 4L; i++)
3293 BicubicInterpolate(pixels+4*i,delta.x,u+i);
3295 BicubicInterpolate(u,delta.y,&pixel);
3298 case BilinearInterpolatePixel:
3311 p=GetCacheViewVirtualPixels(image_view,(long) floor(x),(long) floor(y),2,
3313 if (p == (const PixelPacket *) NULL)
3315 indexes=GetCacheViewVirtualIndexQueue(image_view);
3316 for (i=0; i < 4L; i++)
3318 GetMagickPixelPacket(image,pixels+i);
3319 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3321 if (image->matte != MagickFalse)
3323 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3324 pixels[i].red*=alpha[i];
3325 pixels[i].green*=alpha[i];
3326 pixels[i].blue*=alpha[i];
3327 if (image->colorspace == CMYKColorspace)
3328 pixels[i].index*=alpha[i];
3334 gamma=(((1.0-delta.y)*((1.0-delta.x)*alpha[0]+delta.x*alpha[1])+delta.y*
3335 ((1.0-delta.x)*alpha[2]+delta.x*alpha[3])));
3336 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3337 pixel.red=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].red+delta.x*
3338 pixels[1].red)+delta.y*((1.0-delta.x)*pixels[2].red+delta.x*
3340 pixel.green=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].green+delta.x*
3341 pixels[1].green)+delta.y*((1.0-delta.x)*pixels[2].green+
3342 delta.x*pixels[3].green));
3343 pixel.blue=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].blue+delta.x*
3344 pixels[1].blue)+delta.y*((1.0-delta.x)*pixels[2].blue+delta.x*
3346 pixel.opacity=((1.0-delta.y)*((1.0-delta.x)*pixels[0].opacity+delta.x*
3347 pixels[1].opacity)+delta.y*((1.0-delta.x)*pixels[2].opacity+delta.x*
3348 pixels[3].opacity));
3349 if (image->colorspace == CMYKColorspace)
3350 pixel.index=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].index+delta.x*
3351 pixels[1].index)+delta.y*((1.0-delta.x)*pixels[2].index+delta.x*
3355 case FilterInterpolatePixel:
3369 geometry.x=(long) floor(x)-1L;
3370 geometry.y=(long) floor(y)-1L;
3371 excerpt_image=ExcerptImage(image,&geometry,exception);
3372 if (excerpt_image == (Image *) NULL)
3374 filter_image=ResizeImage(excerpt_image,1,1,image->filter,image->blur,
3376 excerpt_image=DestroyImage(excerpt_image);
3377 if (filter_image == (Image *) NULL)
3379 p=GetVirtualPixels(filter_image,0,0,1,1,exception);
3380 if (p == (const PixelPacket *) NULL)
3382 filter_image=DestroyImage(filter_image);
3385 indexes=GetVirtualIndexQueue(filter_image);
3386 GetMagickPixelPacket(image,pixels);
3387 SetMagickPixelPacket(image,p,indexes,&pixel);
3388 filter_image=DestroyImage(filter_image);
3391 case IntegerInterpolatePixel:
3396 p=GetCacheViewVirtualPixels(image_view,(long) floor(x),(long) floor(y),1,
3398 if (p == (const PixelPacket *) NULL)
3400 indexes=GetCacheViewVirtualIndexQueue(image_view);
3401 GetMagickPixelPacket(image,pixels);
3402 SetMagickPixelPacket(image,p,indexes,&pixel);
3405 case MeshInterpolatePixel:
3418 p=GetCacheViewVirtualPixels(image_view,(long) floor(x),(long) floor(y),
3420 if (p == (const PixelPacket *) NULL)
3422 indexes=GetCacheViewVirtualIndexQueue(image_view);
3423 for (i=0; i < 4L; i++)
3425 GetMagickPixelPacket(image,pixels+i);
3426 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3428 if (image->matte != MagickFalse)
3430 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3431 pixels[i].red*=alpha[i];
3432 pixels[i].green*=alpha[i];
3433 pixels[i].blue*=alpha[i];
3434 if (image->colorspace == CMYKColorspace)
3435 pixels[i].index*=alpha[i];
3441 luminance.x=MagickPixelLuminance(pixels+0)-MagickPixelLuminance(pixels+3);
3442 luminance.y=MagickPixelLuminance(pixels+1)-MagickPixelLuminance(pixels+2);
3443 if (fabs(luminance.x) < fabs(luminance.y))
3448 if (delta.x <= delta.y)
3451 Bottom-left triangle (pixel:2, diagonal: 0-3).
3453 delta.y=1.0-delta.y;
3454 gamma=MeshInterpolate(&delta,alpha[2],alpha[3],alpha[0]);
3455 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3456 pixel.red=gamma*MeshInterpolate(&delta,pixels[2].red,
3457 pixels[3].red,pixels[0].red);
3458 pixel.green=gamma*MeshInterpolate(&delta,pixels[2].green,
3459 pixels[3].green,pixels[0].green);
3460 pixel.blue=gamma*MeshInterpolate(&delta,pixels[2].blue,
3461 pixels[3].blue,pixels[0].blue);
3462 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[2].opacity,
3463 pixels[3].opacity,pixels[0].opacity);
3464 if (image->colorspace == CMYKColorspace)
3465 pixel.index=gamma*MeshInterpolate(&delta,pixels[2].index,
3466 pixels[3].index,pixels[0].index);
3471 Top-right triangle (pixel:1, diagonal: 0-3).
3473 delta.x=1.0-delta.x;
3474 gamma=MeshInterpolate(&delta,alpha[1],alpha[0],alpha[3]);
3475 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3476 pixel.red=gamma*MeshInterpolate(&delta,pixels[1].red,
3477 pixels[0].red,pixels[3].red);
3478 pixel.green=gamma*MeshInterpolate(&delta,pixels[1].green,
3479 pixels[0].green,pixels[3].green);
3480 pixel.blue=gamma*MeshInterpolate(&delta,pixels[1].blue,
3481 pixels[0].blue,pixels[3].blue);
3482 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[1].opacity,
3483 pixels[0].opacity,pixels[3].opacity);
3484 if (image->colorspace == CMYKColorspace)
3485 pixel.index=gamma*MeshInterpolate(&delta,pixels[1].index,
3486 pixels[0].index,pixels[3].index);
3494 if (delta.x <= (1.0-delta.y))
3497 Top-left triangle (pixel 0, diagonal: 1-2).
3499 gamma=MeshInterpolate(&delta,alpha[0],alpha[1],alpha[2]);
3500 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3501 pixel.red=gamma*MeshInterpolate(&delta,pixels[0].red,
3502 pixels[1].red,pixels[2].red);
3503 pixel.green=gamma*MeshInterpolate(&delta,pixels[0].green,
3504 pixels[1].green,pixels[2].green);
3505 pixel.blue=gamma*MeshInterpolate(&delta,pixels[0].blue,
3506 pixels[1].blue,pixels[2].blue);
3507 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[0].opacity,
3508 pixels[1].opacity,pixels[2].opacity);
3509 if (image->colorspace == CMYKColorspace)
3510 pixel.index=gamma*MeshInterpolate(&delta,pixels[0].index,
3511 pixels[1].index,pixels[2].index);
3516 Bottom-right triangle (pixel: 3, diagonal: 1-2).
3518 delta.x=1.0-delta.x;
3519 delta.y=1.0-delta.y;
3520 gamma=MeshInterpolate(&delta,alpha[3],alpha[2],alpha[1]);
3521 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3522 pixel.red=gamma*MeshInterpolate(&delta,pixels[3].red,
3523 pixels[2].red,pixels[1].red);
3524 pixel.green=gamma*MeshInterpolate(&delta,pixels[3].green,
3525 pixels[2].green,pixels[1].green);
3526 pixel.blue=gamma*MeshInterpolate(&delta,pixels[3].blue,
3527 pixels[2].blue,pixels[1].blue);
3528 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[3].opacity,
3529 pixels[2].opacity,pixels[1].opacity);
3530 if (image->colorspace == CMYKColorspace)
3531 pixel.index=gamma*MeshInterpolate(&delta,pixels[3].index,
3532 pixels[2].index,pixels[1].index);
3537 case NearestNeighborInterpolatePixel:
3542 p=GetCacheViewVirtualPixels(image_view,NearestNeighbor(x),
3543 NearestNeighbor(y),1,1,exception);
3544 if (p == (const PixelPacket *) NULL)
3546 indexes=GetCacheViewVirtualIndexQueue(image_view);
3547 GetMagickPixelPacket(image,pixels);
3548 SetMagickPixelPacket(image,p,indexes,&pixel);
3551 case SplineInterpolatePixel:
3569 p=GetCacheViewVirtualPixels(image_view,(long) floor(x)-1,(long) floor(y)-
3571 if (p == (const PixelPacket *) NULL)
3573 indexes=GetCacheViewVirtualIndexQueue(image_view);
3577 for (i=(-1); i < 3L; i++)
3579 dy=CubicWeightingFunction((MagickRealType) i-delta.y);
3580 for (j=(-1); j < 3L; j++)
3582 GetMagickPixelPacket(image,pixels+n);
3583 SetMagickPixelPacket(image,p,indexes+n,pixels+n);
3585 if (image->matte != MagickFalse)
3587 alpha[n]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3588 pixels[n].red*=alpha[n];
3589 pixels[n].green*=alpha[n];
3590 pixels[n].blue*=alpha[n];
3591 if (image->colorspace == CMYKColorspace)
3592 pixels[n].index*=alpha[n];
3594 dx=CubicWeightingFunction(delta.x-(MagickRealType) j);
3596 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3597 pixel.red+=gamma*dx*dy*pixels[n].red;
3598 pixel.green+=gamma*dx*dy*pixels[n].green;
3599 pixel.blue+=gamma*dx*dy*pixels[n].blue;
3600 if (image->matte != MagickFalse)
3601 pixel.opacity+=dx*dy*pixels[n].opacity;
3602 if (image->colorspace == CMYKColorspace)
3603 pixel.index+=gamma*dx*dy*pixels[n].index;
3615 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3619 % I n t e r p r e t I m a g e A t t r i b u t e s %
3623 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3625 % InterpretImageAttributes() replaces any embedded formatting characters with
3626 % the appropriate image attribute and returns the translated text.
3628 % The format of the InterpretImageAttributes method is:
3630 % char *InterpretImageAttributes(const ImageInfo *image_info,Image *image,
3631 % const char *embed_text)
3633 % A description of each parameter follows:
3635 % o image_info: the image info.
3637 % o image: the image.
3639 % o embed_text: the address of a character string containing the embedded
3640 % formatting characters.
3643 MagickExport char *InterpretImageAttributes(const ImageInfo *image_info,
3644 Image *image,const char *embed_text)
3646 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
3647 return(InterpretImageProperties(image_info,image,embed_text));
3651 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3655 + I s S u b i m a g e %
3659 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3661 % IsSubimage() returns MagickTrue if the geometry is a valid subimage
3662 % specification (e.g. [1], [1-9], [1,7,4]).
3664 % The format of the IsSubimage method is:
3666 % unsigned int IsSubimage(const char *geometry,const unsigned int pedantic)
3668 % A description of each parameter follows:
3670 % o geometry: This string is the geometry specification.
3672 % o pedantic: A value other than 0 invokes a more restrictive set of
3673 % conditions for a valid specification (e.g. [1], [1-4], [4-1]).
3676 MagickExport unsigned int IsSubimage(const char *geometry,
3677 const unsigned int pedantic)
3679 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3680 if (geometry == (const char *) NULL)
3681 return(MagickFalse);
3682 if ((strchr(geometry,'x') != (char *) NULL) ||
3683 (strchr(geometry,'X') != (char *) NULL))
3684 return(MagickFalse);
3685 if ((pedantic != MagickFalse) && (strchr(geometry,',') != (char *) NULL))
3686 return(MagickFalse);
3691 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3695 % L e v e l I m a g e C o l o r s %
3699 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3701 % LevelImageColor() will map the given color to "black" and "white"
3702 % values, limearly spreading out the colors, and level values on a channel by
3703 % channel bases, as per LevelImage(). The given colors allows you to specify
3704 % different level ranges for each of the color channels seperatally.
3706 % If the boolean 'invert' is set true the image values will modifyed in the
3707 % reverse direction. That is any existing "black" and "white" colors in the
3708 % image will become the color values given, with all other values compressed
3709 % appropriatally. This effectivally maps a greyscale gradient into the given
3712 % The format of the LevelImageColors method is:
3714 % MagickBooleanType LevelImageColors(Image *image,const ChannelType channel,
3715 % const MagickPixelPacket *black_color,const MagickPixelPacket *white_color,
3716 % const MagickBooleanType invert)
3718 % A description of each parameter follows:
3720 % o image: the image.
3722 % o channel: the channel.
3724 % o black_color: The color to map black to/from
3726 % o white_point: The color to map white to/from
3728 % o invert: if true map the colors (levelize), rather than from (level)
3731 MagickBooleanType LevelImageColors(Image *image,const ChannelType channel,
3732 const MagickPixelPacket *black_color,const MagickPixelPacket *white_color,
3733 const MagickBooleanType invert)
3735 return(LevelColorsImageChannel(image,channel,black_color,white_color,invert));
3739 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3743 % L i b e r a t e M e m o r y %
3747 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3749 % LiberateMemory() frees memory that has already been allocated, and NULL's
3750 % the pointer to it.
3752 % The format of the LiberateMemory method is:
3754 % void LiberateMemory(void **memory)
3756 % A description of each parameter follows:
3758 % o memory: A pointer to a block of memory to free for reuse.
3761 MagickExport void LiberateMemory(void **memory)
3763 assert(memory != (void **) NULL);
3764 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3765 if (*memory == (void *) NULL)
3768 *memory=(void *) NULL;
3772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3776 % L i b e r a t e S e m a p h o r e I n f o %
3780 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3782 % LiberateSemaphoreInfo() relinquishes a semaphore.
3784 % The format of the LiberateSemaphoreInfo method is:
3786 % LiberateSemaphoreInfo(void **semaphore_info)
3788 % A description of each parameter follows:
3790 % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
3793 MagickExport void LiberateSemaphoreInfo(SemaphoreInfo **semaphore_info)
3795 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3796 UnlockSemaphoreInfo(*semaphore_info);
3800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3804 % M a g i c k I n c a r n a t e %
3808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3810 % MagickIncarnate() initializes the ImageMagick environment.
3812 % The format of the MagickIncarnate function is:
3814 % MagickIncarnate(const char *path)
3816 % A description of each parameter follows:
3818 % o path: the execution path of the current ImageMagick client.
3822 MagickExport void MagickIncarnate(const char *path)
3824 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
3825 MagickCoreGenesis(path,MagickFalse);
3829 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3833 % M a g i c k M o n i t o r %
3837 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3839 % MagickMonitor() calls the monitor handler method with a text string that
3840 % describes the task and a measure of completion. The method returns
3841 % MagickTrue on success otherwise MagickFalse if an error is encountered, e.g.
3842 % if there was a user interrupt.
3844 % The format of the MagickMonitor method is:
3846 % MagickBooleanType MagickMonitor(const char *text,
3847 % const MagickOffsetType offset,const MagickSizeType span,
3848 % void *client_data)
3850 % A description of each parameter follows:
3852 % o offset: the position relative to the span parameter which represents
3853 % how much progress has been made toward completing a task.
3855 % o span: the span relative to completing a task.
3857 % o client_data: the client data.
3860 MagickExport MagickBooleanType MagickMonitor(const char *text,
3861 const MagickOffsetType offset,const MagickSizeType span,
3862 void *magick_unused(client_data))
3870 assert(text != (const char *) NULL);
3871 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",text);
3872 ProcessPendingEvents(text);
3874 exception=AcquireExceptionInfo();
3875 if (monitor_handler != (MonitorHandler) NULL)
3876 status=(*monitor_handler)(text,offset,span,exception);
3877 exception=DestroyExceptionInfo(exception);
3882 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3892 % MapImage() replaces the colors of an image with the closest color from a
3895 % The format of the MapImage method is:
3897 % MagickBooleanType MapImage(Image *image,const Image *map_image,
3898 % const MagickBooleanType dither)
3900 % A description of each parameter follows:
3902 % o image: Specifies a pointer to an Image structure.
3904 % o map_image: the image. Reduce image to a set of colors represented by
3907 % o dither: Set this integer value to something other than zero to
3908 % dither the mapped image.
3911 MagickExport MagickBooleanType MapImage(Image *image,const Image *map_image,
3912 const MagickBooleanType dither)
3918 Initialize color cube.
3920 assert(image != (Image *) NULL);
3921 assert(image->signature == MagickSignature);
3922 if (image->debug != MagickFalse)
3923 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3924 assert(map_image != (Image *) NULL);
3925 assert(map_image->signature == MagickSignature);
3926 GetQuantizeInfo(&quantize_info);
3927 quantize_info.dither=dither;
3928 return(RemapImage(&quantize_info,image,map_image));
3932 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3936 % M a p I m a g e s %
3940 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3942 % MapImages() replaces the colors of a sequence of images with the closest
3943 % color from a reference image.
3945 % The format of the MapImage method is:
3947 % MagickBooleanType MapImages(Image *images,Image *map_image,
3948 % const MagickBooleanType dither)
3950 % A description of each parameter follows:
3952 % o image: Specifies a pointer to a set of Image structures.
3954 % o map_image: the image. Reduce image to a set of colors represented by
3957 % o dither: Set this integer value to something other than zero to
3958 % dither the quantized image.
3961 MagickExport MagickBooleanType MapImages(Image *images,const Image *map_image,
3962 const MagickBooleanType dither)
3967 assert(images != (Image *) NULL);
3968 assert(images->signature == MagickSignature);
3969 if (images->debug != MagickFalse)
3970 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3971 GetQuantizeInfo(&quantize_info);
3972 quantize_info.dither=dither;
3973 return(RemapImages(&quantize_info,images,map_image));
3977 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3981 % M a t t e F l o o d f i l l I m a g e %
3985 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3987 % MatteFloodfill() changes the transparency value of any pixel that matches
3988 % target and is an immediate neighbor. If the method FillToBorderMethod
3989 % is specified, the transparency value is changed for any neighbor pixel
3990 % that does not match the bordercolor member of image.
3992 % By default target must match a particular pixel transparency exactly.
3993 % However, in many cases two transparency values may differ by a
3994 % small amount. The fuzz member of image defines how much tolerance is
3995 % acceptable to consider two transparency values as the same. For example,
3996 % set fuzz to 10 and the opacity values of 100 and 102 respectively are
3997 % now interpreted as the same value for the purposes of the floodfill.
3999 % The format of the MatteFloodfillImage method is:
4001 % MagickBooleanType MatteFloodfillImage(Image *image,
4002 % const PixelPacket target,const Quantum opacity,const long x_offset,
4003 % const long y_offset,const PaintMethod method)
4005 % A description of each parameter follows:
4007 % o image: the image.
4009 % o target: the RGB value of the target color.
4011 % o opacity: the level of transparency: 0 is fully opaque and QuantumRange is
4012 % fully transparent.
4014 % o x,y: the starting location of the operation.
4016 % o method: Choose either FloodfillMethod or FillToBorderMethod.
4019 MagickExport MagickBooleanType MatteFloodfillImage(Image *image,
4020 const PixelPacket target,const Quantum opacity,const long x_offset,
4021 const long y_offset,const PaintMethod method)
4037 register SegmentInfo
4044 Check boundary conditions.
4046 assert(image != (Image *) NULL);
4047 assert(image->signature == MagickSignature);
4048 if (image->debug != MagickFalse)
4049 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4050 if ((x_offset < 0) || (x_offset >= (long) image->columns))
4051 return(MagickFalse);
4052 if ((y_offset < 0) || (y_offset >= (long) image->rows))
4053 return(MagickFalse);
4054 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
4055 return(MagickFalse);
4056 if (image->matte == MagickFalse)
4057 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
4058 floodplane_image=CloneImage(image,image->columns,image->rows,MagickTrue,
4060 if (floodplane_image == (Image *) NULL)
4061 return(MagickFalse);
4062 (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel);
4064 Set floodfill color.
4066 segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
4067 sizeof(*segment_stack));
4068 if (segment_stack == (SegmentInfo *) NULL)
4070 floodplane_image=DestroyImage(floodplane_image);
4071 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
4075 Push initial segment on stack.
4081 PushSegmentStack(y,x,x,1);
4082 PushSegmentStack(y+1,x,x,-1);
4083 while (s > segment_stack)
4085 register const PixelPacket
4091 register PixelPacket
4095 Pop segment off stack.
4100 offset=(long) s->y2;
4101 y=(long) s->y1+offset;
4103 Recolor neighboring pixels.
4105 p=GetVirtualPixels(image,0,y,(unsigned long) (x1+1),1,&image->exception);
4106 q=GetAuthenticPixels(floodplane_image,0,y,(unsigned long) (x1+1),1,
4108 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4112 for (x=x1; x >= 0; x--)
4114 if (q->opacity == (Quantum) TransparentOpacity)
4116 if (method == FloodfillMethod)
4118 if (IsColorSimilar(image,p,&target) == MagickFalse)
4122 if (IsColorSimilar(image,p,&target) != MagickFalse)
4124 q->opacity=(Quantum) TransparentOpacity;
4128 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
4130 skip=x >= x1 ? MagickTrue : MagickFalse;
4131 if (skip == MagickFalse)
4135 PushSegmentStack(y,start,x1-1,-offset);
4140 if (skip == MagickFalse)
4142 if (x < (long) image->columns)
4144 p=GetVirtualPixels(image,x,y,image->columns-x,1,
4146 q=GetAuthenticPixels(floodplane_image,x,y,image->columns-x,1,
4148 if ((p == (const PixelPacket *) NULL) ||
4149 (q == (PixelPacket *) NULL))
4151 for ( ; x < (long) image->columns; x++)
4153 if (q->opacity == (Quantum) TransparentOpacity)
4155 if (method == FloodfillMethod)
4157 if (IsColorSimilar(image,p,&target) == MagickFalse)
4161 if (IsColorSimilar(image,p,&target) != MagickFalse)
4163 q->opacity=(Quantum) TransparentOpacity;
4167 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
4170 PushSegmentStack(y,start,x-1,offset);
4172 PushSegmentStack(y,x2+1,x-1,-offset);
4178 p=GetVirtualPixels(image,x,y,(unsigned long) (x2-x+1),1,
4180 q=GetAuthenticPixels(floodplane_image,x,y,(unsigned long) (x2-x+1),1,
4182 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4184 for ( ; x <= x2; x++)
4186 if (q->opacity == (Quantum) TransparentOpacity)
4188 if (method == FloodfillMethod)
4190 if (IsColorSimilar(image,p,&target) != MagickFalse)
4194 if (IsColorSimilar(image,p,&target) == MagickFalse)
4203 for (y=0; y < (long) image->rows; y++)
4205 register const PixelPacket
4211 register PixelPacket
4215 Tile fill color onto floodplane.
4217 p=GetVirtualPixels(floodplane_image,0,y,image->columns,1,
4219 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4220 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4222 for (x=0; x < (long) image->columns; x++)
4224 if (p->opacity != OpaqueOpacity)
4229 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4232 segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
4233 floodplane_image=DestroyImage(floodplane_image);
4234 return(y == (long) image->rows ? MagickTrue : MagickFalse);
4238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4242 % M a x i m u m I m a g e s %
4246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4248 % MaximumImages() returns the maximum intensity of an image sequence.
4250 % The format of the MaxImages method is:
4252 % Image *MaximumImages(Image *images,ExceptionInfo *exception)
4254 % A description of each parameter follows:
4256 % o images: the image sequence.
4258 % o exception: return any errors or warnings in this structure.
4261 MagickExport Image *MaximumImages(const Image *images,ExceptionInfo *exception)
4263 return(EvaluateImages(images,MinEvaluateOperator,exception));
4267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4271 % M i n i m u m I m a g e s %
4275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4277 % MinimumImages() returns the minimum intensity of an image sequence.
4279 % The format of the MinimumImages method is:
4281 % Image *MinimumImages(Image *images,ExceptionInfo *exception)
4283 % A description of each parameter follows:
4285 % o images: the image sequence.
4287 % o exception: return any errors or warnings in this structure.
4290 MagickExport Image *MinimumImages(const Image *images,ExceptionInfo *exception)
4292 return(EvaluateImages(images,MinEvaluateOperator,exception));
4296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4300 % M o s a i c I m a g e s %
4304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4306 % MosaicImages() Obsolete Function: Use MergeImageLayers() instead.
4308 % The format of the MosaicImage method is:
4310 % Image *MosaicImages(const Image *image,ExceptionInfo *exception)
4312 % A description of each parameter follows:
4314 % o image: the image list to be composited together
4316 % o exception: return any errors or warnings in this structure.
4319 MagickExport Image *MosaicImages(Image *image,ExceptionInfo *exception)
4321 return(MergeImageLayers(image,MosaicLayer,exception));
4325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4329 % O p a q u e I m a g e %
4333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4335 % OpaqueImage() changes any pixel that matches color with the color
4338 % By default color must match a particular pixel color exactly. However,
4339 % in many cases two colors may differ by a small amount. Fuzz defines
4340 % how much tolerance is acceptable to consider two colors as the same.
4341 % For example, set fuzz to 10 and the color red at intensities of 100 and
4342 % 102 respectively are now interpreted as the same color.
4344 % The format of the OpaqueImage method is:
4346 % MagickBooleanType OpaqueImage(Image *image,
4347 % const PixelPacket *target,const PixelPacket fill)
4349 % A description of each parameter follows:
4351 % o image: the image.
4353 % o target: the RGB value of the target color.
4355 % o fill: the replacement color.
4358 MagickExport MagickBooleanType OpaqueImage(Image *image,
4359 const PixelPacket target,const PixelPacket fill)
4361 #define OpaqueImageTag "Opaque/Image"
4373 Make image color opaque.
4375 assert(image != (Image *) NULL);
4376 assert(image->signature == MagickSignature);
4377 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.1.0");
4378 if (image->debug != MagickFalse)
4379 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4380 switch (image->storage_class)
4386 Make DirectClass image opaque.
4388 for (y=0; y < (long) image->rows; y++)
4393 register PixelPacket
4396 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4397 if (q == (PixelPacket *) NULL)
4399 for (x=0; x < (long) image->columns; x++)
4401 if (IsColorSimilar(image,q,&target) != MagickFalse)
4405 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4407 proceed=SetImageProgress(image,OpaqueImageTag,y,image->rows);
4408 if (proceed == MagickFalse)
4416 Make PseudoClass image opaque.
4418 for (i=0; i < (long) image->colors; i++)
4420 if (IsColorSimilar(image,&image->colormap[i],&target) != MagickFalse)
4421 image->colormap[i]=fill;
4423 if (fill.opacity != OpaqueOpacity)
4425 for (y=0; y < (long) image->rows; y++)
4430 register PixelPacket
4433 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4434 if (q == (PixelPacket *) NULL)
4436 for (x=0; x < (long) image->columns; x++)
4438 if (IsColorSimilar(image,q,&target) != MagickFalse)
4439 q->opacity=fill.opacity;
4442 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4446 (void) SyncImage(image);
4450 if (fill.opacity != OpaqueOpacity)
4451 image->matte=MagickTrue;
4456 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4460 % O p e n C a c h e V i e w %
4464 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4466 % OpenCacheView() opens a view into the pixel cache, using the
4467 % VirtualPixelMethod that is defined within the given image itself.
4469 % The format of the OpenCacheView method is:
4471 % CacheView *OpenCacheView(const Image *image)
4473 % A description of each parameter follows:
4475 % o image: the image.
4478 MagickExport CacheView *OpenCacheView(const Image *image)
4480 return(AcquireCacheView(image));
4484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4488 % P a i n t F l o o d f i l l I m a g e %
4492 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4494 % PaintFloodfill() changes the color value of any pixel that matches
4495 % target and is an immediate neighbor. If the method FillToBorderMethod is
4496 % specified, the color value is changed for any neighbor pixel that does not
4497 % match the bordercolor member of image.
4499 % By default target must match a particular pixel color exactly.
4500 % However, in many cases two colors may differ by a small amount. The
4501 % fuzz member of image defines how much tolerance is acceptable to
4502 % consider two colors as the same. For example, set fuzz to 10 and the
4503 % color red at intensities of 100 and 102 respectively are now
4504 % interpreted as the same color for the purposes of the floodfill.
4506 % The format of the PaintFloodfillImage method is:
4508 % MagickBooleanType PaintFloodfillImage(Image *image,
4509 % const ChannelType channel,const MagickPixelPacket target,const long x,
4510 % const long y,const DrawInfo *draw_info,const PaintMethod method)
4512 % A description of each parameter follows:
4514 % o image: the image.
4516 % o channel: the channel(s).
4518 % o target: the RGB value of the target color.
4520 % o x,y: the starting location of the operation.
4522 % o draw_info: the draw info.
4524 % o method: Choose either FloodfillMethod or FillToBorderMethod.
4527 MagickExport MagickBooleanType PaintFloodfillImage(Image *image,
4528 const ChannelType channel,const MagickPixelPacket *target,const long x,
4529 const long y,const DrawInfo *draw_info,const PaintMethod method)
4534 status=FloodfillPaintImage(image,channel,draw_info,target,x,y,
4535 method == FloodfillMethod ? MagickFalse : MagickTrue);
4540 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4543 % P a i n t O p a q u e I m a g e %
4546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4548 % PaintOpaqueImage() changes any pixel that matches color with the color
4551 % By default color must match a particular pixel color exactly. However,
4552 % in many cases two colors may differ by a small amount. Fuzz defines
4553 % how much tolerance is acceptable to consider two colors as the same.
4554 % For example, set fuzz to 10 and the color red at intensities of 100 and
4555 % 102 respectively are now interpreted as the same color.
4557 % The format of the PaintOpaqueImage method is:
4559 % MagickBooleanType PaintOpaqueImage(Image *image,
4560 % const PixelPacket *target,const PixelPacket *fill)
4561 % MagickBooleanType PaintOpaqueImageChannel(Image *image,
4562 % const ChannelType channel,const PixelPacket *target,
4563 % const PixelPacket *fill)
4565 % A description of each parameter follows:
4567 % o image: the image.
4569 % o channel: the channel(s).
4571 % o target: the RGB value of the target color.
4573 % o fill: the replacement color.
4577 MagickExport MagickBooleanType PaintOpaqueImage(Image *image,
4578 const MagickPixelPacket *target,const MagickPixelPacket *fill)
4583 status=OpaquePaintImageChannel(image,DefaultChannels,target,fill,MagickFalse);
4587 MagickExport MagickBooleanType PaintOpaqueImageChannel(Image *image,
4588 const ChannelType channel,const MagickPixelPacket *target,
4589 const MagickPixelPacket *fill)
4591 return(OpaquePaintImageChannel(image,channel,target,fill,MagickFalse));
4595 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4599 % P a i n t T r a n s p a r e n t I m a g e %
4603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4605 % PaintTransparentImage() changes the opacity value associated with any pixel
4606 % that matches color to the value defined by opacity.
4608 % By default color must match a particular pixel color exactly. However,
4609 % in many cases two colors may differ by a small amount. Fuzz defines
4610 % how much tolerance is acceptable to consider two colors as the same.
4611 % For example, set fuzz to 10 and the color red at intensities of 100 and
4612 % 102 respectively are now interpreted as the same color.
4614 % The format of the PaintTransparentImage method is:
4616 % MagickBooleanType PaintTransparentImage(Image *image,
4617 % const MagickPixelPacket *target,const Quantum opacity)
4619 % A description of each parameter follows:
4621 % o image: the image.
4623 % o target: the RGB value of the target color.
4625 % o opacity: the replacement opacity value.
4628 MagickExport MagickBooleanType PaintTransparentImage(Image *image,
4629 const MagickPixelPacket *target,const Quantum opacity)
4631 return(TransparentPaintImage(image,target,opacity,MagickFalse));
4635 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4639 + P a r s e I m a g e G e o m e t r y %
4643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4645 % ParseImageGeometry() is similar to GetGeometry() except the returned
4646 % geometry is modified as determined by the meta characters: %, !, <,
4649 % The format of the ParseImageGeometry method is:
4651 % int ParseImageGeometry(char *geometry,long *x,long *y,
4652 % unsigned long *width,unsigned long *height)
4654 % A description of each parameter follows:
4656 % o flags: Method ParseImageGeometry returns a bitmask that indicates
4657 % which of the four values were located in the geometry string.
4659 % o image_geometry: Specifies a character string representing the geometry
4662 % o x,y: A pointer to an integer. The x and y offset as determined by
4663 % the geometry specification is returned here.
4665 % o width,height: A pointer to an unsigned integer. The width and height
4666 % as determined by the geometry specification is returned here.
4669 MagickExport int ParseImageGeometry(const char *geometry,long *x,long *y,
4670 unsigned long *width,unsigned long *height)
4672 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
4673 return((int) ParseMetaGeometry(geometry,x,y,width,height));
4677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4681 % P a r s e S i z e G e o m e t r y %
4685 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4687 % ParseSizeGeometry() returns a region as defined by the geometry string with
4688 % respect to the image dimensions and aspect ratio.
4690 % The format of the ParseSizeGeometry method is:
4692 % MagickStatusType ParseSizeGeometry(const Image *image,
4693 % const char *geometry,RectangeInfo *region_info)
4695 % A description of each parameter follows:
4697 % o geometry: The geometry (e.g. 100x100+10+10).
4699 % o region_info: the region as defined by the geometry string.
4702 MagickExport MagickStatusType ParseSizeGeometry(const Image *image,
4703 const char *geometry,RectangleInfo *region_info)
4708 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.4.7");
4709 SetGeometry(image,region_info);
4710 flags=ParseMetaGeometry(geometry,®ion_info->x,®ion_info->y,
4711 ®ion_info->width,®ion_info->height);
4716 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4720 % P o p I m a g e L i s t %
4724 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4726 % PopImageList() removes the last image in the list.
4728 % The format of the PopImageList method is:
4730 % Image *PopImageList(Image **images)
4732 % A description of each parameter follows:
4734 % o images: the image list.
4737 MagickExport Image *PopImageList(Image **images)
4739 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
4740 return(RemoveLastImageFromList(images));
4744 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4748 % P o p I m a g e P i x e l s %
4752 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4754 % PopImagePixels() transfers one or more pixel components from the image pixel
4755 % cache to a user supplied buffer. The pixels are returned in network byte
4756 % order. MagickTrue is returned if the pixels are successfully transferred,
4757 % otherwise MagickFalse.
4759 % The format of the PopImagePixels method is:
4761 % size_t PopImagePixels(Image *,const QuantumType quantum,
4762 % unsigned char *destination)
4764 % A description of each parameter follows:
4766 % o image: the image.
4768 % o quantum: Declare which pixel components to transfer (RGB, RGBA, etc).
4770 % o destination: The components are transferred to this buffer.
4773 MagickExport size_t PopImagePixels(Image *image,const QuantumType quantum,
4774 unsigned char *destination)
4782 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
4783 if (quantum_info == (QuantumInfo *) NULL)
4785 length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
4786 quantum,destination,&image->exception);
4787 quantum_info=DestroyQuantumInfo(quantum_info);
4792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4796 % P o s t s c r i p t G e o m e t r y %
4800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4802 % PostscriptGeometry() replaces any page mneumonic with the equivalent size in
4805 % The format of the PostscriptGeometry method is:
4807 % char *PostscriptGeometry(const char *page)
4809 % A description of each parameter follows.
4811 % o page: Specifies a pointer to an array of characters.
4812 % The string is either a Postscript page name (e.g. A4) or a postscript
4813 % page geometry (e.g. 612x792+36+36).
4816 MagickExport char *PostscriptGeometry(const char *page)
4818 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
4819 return(GetPageGeometry(page));
4823 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4827 % P u s h I m a g e L i s t %
4831 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4833 % PushImageList() adds an image to the end of the list.
4835 % The format of the PushImageList method is:
4837 % unsigned int PushImageList(Image *images,const Image *image,
4838 % ExceptionInfo *exception)
4840 % A description of each parameter follows:
4842 % o images: the image list.
4844 % o image: the image.
4846 % o exception: return any errors or warnings in this structure.
4849 MagickExport unsigned int PushImageList(Image **images,const Image *image,
4850 ExceptionInfo *exception)
4852 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
4853 AppendImageToList(images,CloneImageList(image,exception));
4858 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4862 % P u s h I m a g e P i x e l s %
4866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4868 % PushImagePixels() transfers one or more pixel components from a user
4869 % supplied buffer into the image pixel cache of an image. The pixels are
4870 % expected in network byte order. It returns MagickTrue if the pixels are
4871 % successfully transferred, otherwise MagickFalse.
4873 % The format of the PushImagePixels method is:
4875 % size_t PushImagePixels(Image *image,const QuantumType quantum,
4876 % const unsigned char *source)
4878 % A description of each parameter follows:
4880 % o image: the image.
4882 % o quantum: Declare which pixel components to transfer (red, green, blue,
4883 % opacity, RGB, or RGBA).
4885 % o source: The pixel components are transferred from this buffer.
4888 MagickExport size_t PushImagePixels(Image *image,const QuantumType quantum,
4889 const unsigned char *source)
4897 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
4898 if (quantum_info == (QuantumInfo *) NULL)
4900 length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,quantum,
4901 source,&image->exception);
4902 quantum_info=DestroyQuantumInfo(quantum_info);
4907 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4911 % Q u a n t i z a t i o n E r r o r %
4915 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4917 % QuantizationError() measures the difference between the original and
4918 % quantized images. This difference is the total quantization error. The
4919 % error is computed by summing over all pixels in an image the distance
4920 % squared in RGB space between each reference pixel value and its quantized
4921 % value. These values are computed:
4923 % o mean_error_per_pixel: This value is the mean error for any single
4924 % pixel in the image.
4926 % o normalized_mean_square_error: This value is the normalized mean
4927 % quantization error for any single pixel in the image. This distance
4928 % measure is normalized to a range between 0 and 1. It is independent
4929 % of the range of red, green, and blue values in the image.
4931 % o normalized_maximum_square_error: Thsi value is the normalized
4932 % maximum quantization error for any single pixel in the image. This
4933 % distance measure is normalized to a range between 0 and 1. It is
4934 % independent of the range of red, green, and blue values in your image.
4937 % The format of the QuantizationError method is:
4939 % unsigned int QuantizationError(Image *image)
4941 % A description of each parameter follows.
4943 % o image: Specifies a pointer to an Image structure; returned from
4947 MagickExport unsigned int QuantizationError(Image *image)
4949 if (image->debug != MagickFalse)
4950 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.3");
4951 return(GetImageQuantizeError(image));
4955 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4958 % R a n d o m C h a n n e l T h r e s h o l d I m a g e %
4962 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4964 % RandomChannelThresholdImage() changes the value of individual pixels based
4965 % on the intensity of each pixel compared to a random threshold. The result
4966 % is a low-contrast, two color image.
4968 % The format of the RandomChannelThresholdImage method is:
4970 % unsigned int RandomChannelThresholdImage(Image *image,
4971 % const char *channel, const char *thresholds,
4972 % ExceptionInfo *exception)
4974 % A description of each parameter follows:
4976 % o image: the image.
4978 % o channel: the channel or channels to be thresholded.
4980 % o thresholds: a geometry string containing LOWxHIGH thresholds.
4981 % If the string contains 2x2, 3x3, or 4x4, then an ordered
4982 % dither of order 2, 3, or 4 will be performed instead.
4984 % o exception: return any errors or warnings in this structure.
4987 MagickExport unsigned int RandomChannelThresholdImage(Image *image,const char
4988 *channel,const char *thresholds,ExceptionInfo *exception)
4990 #define RandomChannelThresholdImageText " RandomChannelThreshold image... "
5003 static MagickRealType
5004 o2[4]={0.2f, 0.6f, 0.8f, 0.4f},
5005 o3[9]={0.1f, 0.6f, 0.3f, 0.7f, 0.5f, 0.8f, 0.4f, 0.9f, 0.2f},
5006 o4[16]={0.1f, 0.7f, 1.1f, 0.3f, 1.0f, 0.5f, 1.5f, 0.8f, 1.4f, 1.6f, 0.6f,
5007 1.2f, 0.4f, 0.9f, 1.3f, 0.2f},
5016 assert(image != (Image *) NULL);
5017 assert(image->signature == MagickSignature);
5018 if (image->debug != MagickFalse)
5019 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
5020 assert(exception != (ExceptionInfo *) NULL);
5021 assert(exception->signature == MagickSignature);
5022 if (image->debug != MagickFalse)
5023 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5024 if (thresholds == (const char *) NULL)
5026 if (LocaleCompare(thresholds,"2x2") == 0)
5029 if (LocaleCompare(thresholds,"3x3") == 0)
5032 if (LocaleCompare(thresholds,"4x4") == 0)
5039 count=sscanf(thresholds,"%lf[/x%%]%lf",&lower_threshold,
5041 if (strchr(thresholds,'%') != (char *) NULL)
5043 upper_threshold*=(.01*QuantumRange);
5044 lower_threshold*=(.01*QuantumRange);
5047 upper_threshold=(MagickRealType) QuantumRange-lower_threshold;
5049 if (image->debug != MagickFalse)
5050 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
5051 " RandomChannelThresholdImage: channel type=%s",channel);
5052 if (image->debug != MagickFalse)
5053 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
5054 " Thresholds: %s (%fx%f)",thresholds,lower_threshold,upper_threshold);
5055 if (LocaleCompare(channel,"all") == 0 ||
5056 LocaleCompare(channel,"intensity") == 0)
5057 if (AcquireImageColormap(image,2) == MagickFalse)
5058 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
5060 random_info=AcquireRandomInfo();
5061 for (y=0; y < (long) image->rows; y++)
5066 register IndexPacket
5070 register PixelPacket
5073 q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
5074 if (q == (PixelPacket *) NULL)
5076 if (LocaleCompare(channel,"all") == 0 ||
5077 LocaleCompare(channel,"intensity") == 0)
5079 indexes=GetAuthenticIndexQueue(image);
5080 for (x=0; x < (long) image->columns; x++)
5085 intensity=(MagickRealType) PixelIntensityToQuantum(q);
5088 if (intensity < lower_threshold)
5089 threshold=lower_threshold;
5090 else if (intensity > upper_threshold)
5091 threshold=upper_threshold;
5093 threshold=(MagickRealType) (QuantumRange*
5094 GetPseudoRandomValue(random_info));
5096 else if (order == 2)
5097 threshold=(MagickRealType) QuantumRange*o2[(x%2)+2*(y%2)];
5098 else if (order == 3)
5099 threshold=(MagickRealType) QuantumRange*o3[(x%3)+3*(y%3)];
5100 else if (order == 4)
5101 threshold=(MagickRealType) QuantumRange*o4[(x%4)+4*(y%4)];
5102 q->red=q->green=q->blue=(Quantum) (intensity <=
5103 threshold ? 0 : QuantumRange);
5104 index=(IndexPacket) (intensity <= threshold ? 0 : 1);
5106 q->red=q->green=q->blue=image->colormap[(long) index].red;
5110 if (LocaleCompare(channel,"opacity") == 0 ||
5111 LocaleCompare(channel,"all") == 0 ||
5112 LocaleCompare(channel,"matte") == 0)
5114 if (image->matte != MagickFalse)
5115 for (x=0; x < (long) image->columns; x++)
5119 if ((MagickRealType) q->opacity < lower_threshold)
5120 threshold=lower_threshold;
5121 else if ((MagickRealType) q->opacity > upper_threshold)
5122 threshold=upper_threshold;
5124 threshold=(MagickRealType) (QuantumRange*
5125 GetPseudoRandomValue(random_info));
5127 else if (order == 2)
5128 threshold=(MagickRealType) QuantumRange*o2[(x%2)+2*(y%2)];
5129 else if (order == 3)
5130 threshold=(MagickRealType) QuantumRange*o3[(x%3)+3*(y%3)];
5131 else if (order == 4)
5132 threshold=(MagickRealType) QuantumRange*o4[(x%4)+4*(y%4)]/1.7;
5133 q->opacity=(Quantum) ((MagickRealType) q->opacity <= threshold ?
5140 /* To Do: red, green, blue, cyan, magenta, yellow, black */
5141 if (LocaleCompare(channel,"intensity") != 0)
5142 ThrowBinaryException(OptionError,"UnrecognizedChannelType",
5145 if (SyncAuthenticPixels(image,exception) == MagickFalse)
5148 random_info=DestroyRandomInfo(random_info);
5153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5157 % R e a c q u i r e M e m o r y %
5161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5163 % ReacquireMemory() changes the size of the memory and returns a pointer to
5164 % the (possibly moved) block. The contents will be unchanged up to the
5165 % lesser of the new and old sizes.
5167 % The format of the ReacquireMemory method is:
5169 % void ReacquireMemory(void **memory,const size_t size)
5171 % A description of each parameter follows:
5173 % o memory: A pointer to a memory allocation. On return the pointer
5174 % may change but the contents of the original allocation will not.
5176 % o size: the new size of the allocated memory.
5179 MagickExport void ReacquireMemory(void **memory,const size_t size)
5184 assert(memory != (void **) NULL);
5185 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5186 if (*memory == (void *) NULL)
5188 *memory=AcquireMagickMemory(size);
5191 allocation=realloc(*memory,size);
5192 if (allocation == (void *) NULL)
5193 *memory=RelinquishMagickMemory(*memory);
5198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5202 % R e c o l o r I m a g e %
5206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5208 % RecolorImage() apply color transformation to an image. The method permits
5209 % saturation changes, hue rotation, luminance to alpha, and various other
5210 % effects. Although variable-sized transformation matrices can be used,
5211 % typically one uses a 5x5 matrix for an RGBA image and a 6x6 for CMYKA
5212 % (or RGBA with offsets). The matrix is similar to those used by Adobe Flash
5213 % except offsets are in column 6 rather than 5 (in support of CMYKA images)
5214 % and offsets are normalized (divide Flash offset by 255).
5216 % The format of the RecolorImage method is:
5218 % Image *RecolorImage(const Image *image,const unsigned long order,
5219 % const double *color_matrix,ExceptionInfo *exception)
5221 % A description of each parameter follows:
5223 % o image: the image.
5225 % o order: the number of columns and rows in the recolor matrix.
5227 % o color_matrix: An array of double representing the recolor matrix.
5229 % o exception: return any errors or warnings in this structure.
5232 MagickExport Image *RecolorImage(const Image *image,const unsigned long order,
5233 const double *color_matrix,ExceptionInfo *exception)
5241 kernel_info=AcquireKernelInfo("1");
5242 if (kernel_info == (KernelInfo *) NULL)
5243 return((Image *) NULL);
5244 kernel_info->width=order;
5245 kernel_info->height=order;
5246 kernel_info->values=(double *) color_matrix;
5247 recolor_image=ColorMatrixImage(image,kernel_info,exception);
5248 kernel_info->values=(double *) NULL;
5249 kernel_info=DestroyKernelInfo(kernel_info);
5250 return(recolor_image);
5254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5258 % R e s e t I m a g e A t t r i b u t e I t e r a t o r %
5262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5264 % ResetImageAttributeIterator() resets the image attributes iterator. Use it
5265 % in conjunction with GetNextImageAttribute() to iterate over all the values
5266 % associated with an image.
5268 % The format of the ResetImageAttributeIterator method is:
5270 % ResetImageAttributeIterator(const ImageInfo *image)
5272 % A description of each parameter follows:
5274 % o image: the image.
5277 MagickExport void ResetImageAttributeIterator(const Image *image)
5279 ResetImagePropertyIterator(image);
5283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5287 % S e t C a c h e V i e w P i x e l s %
5291 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5293 % SetCacheViewPixels() gets pixels from the in-memory or disk pixel cache as
5294 % defined by the geometry parameters. A pointer to the pixels is returned
5295 % if the pixels are transferred, otherwise a NULL is returned.
5297 % The format of the SetCacheViewPixels method is:
5299 % PixelPacket *SetCacheViewPixels(CacheView *cache_view,const long x,
5300 % const long y,const unsigned long columns,const unsigned long rows)
5302 % A description of each parameter follows:
5304 % o cache_view: the cache view.
5306 % o x,y,columns,rows: These values define the perimeter of a region of
5310 MagickExport PixelPacket *SetCacheViewPixels(CacheView *cache_view,const long x,
5311 const long y,const unsigned long columns,const unsigned long rows)
5316 pixels=QueueCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
5317 GetCacheViewException(cache_view));
5322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5326 + S e t C a c h e T h e s h o l d %
5330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5332 % SetCacheThreshold() sets the amount of free memory allocated for the pixel
5333 % cache. Once this threshold is exceeded, all subsequent pixels cache
5334 % operations are to/from disk.
5336 % The format of the SetCacheThreshold() method is:
5338 % void SetCacheThreshold(const size_t threshold)
5340 % A description of each parameter follows:
5342 % o threshold: the number of megabytes of memory available to the pixel
5346 MagickExport void SetCacheThreshold(const unsigned long size)
5348 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
5349 (void) SetMagickResourceLimit(MemoryResource,size*1024*1024);
5350 (void) SetMagickResourceLimit(MapResource,2*size*1024*1024);
5354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5358 % S e t E x c e p t i o n I n f o %
5362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5364 % SetExceptionInfo() sets the exception severity.
5366 % The format of the SetExceptionInfo method is:
5368 % MagickBooleanType SetExceptionInfo(ExceptionInfo *exception,
5369 % ExceptionType severity)
5371 % A description of each parameter follows:
5373 % o exception: the exception info.
5375 % o severity: the exception severity.
5378 MagickExport MagickBooleanType SetExceptionInfo(ExceptionInfo *exception,
5379 ExceptionType severity)
5381 assert(exception != (ExceptionInfo *) NULL);
5382 ClearMagickException(exception);
5383 exception->severity=severity;
5388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5398 % SetImage() sets the red, green, and blue components of each pixel to
5399 % the image background color and the opacity component to the specified
5400 % level of transparency. The background color is defined by the
5401 % background_color member of the image.
5403 % The format of the SetImage method is:
5405 % void SetImage(Image *image,const Quantum opacity)
5407 % A description of each parameter follows:
5409 % o image: the image.
5411 % o opacity: Set each pixel to this level of transparency.
5414 MagickExport void SetImage(Image *image,const Quantum opacity)
5422 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.0");
5423 assert(image != (Image *) NULL);
5424 if (image->debug != MagickFalse)
5425 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
5426 assert(image->signature == MagickSignature);
5427 background_color=image->background_color;
5428 if (opacity != OpaqueOpacity)
5429 background_color.opacity=opacity;
5430 if (background_color.opacity != OpaqueOpacity)
5432 (void) SetImageStorageClass(image,DirectClass);
5433 image->matte=MagickTrue;
5435 if ((image->storage_class == PseudoClass) ||
5436 (image->colorspace == CMYKColorspace))
5439 Set colormapped or CMYK image.
5441 for (y=0; y < (long) image->rows; y++)
5443 register IndexPacket
5449 register PixelPacket
5452 q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
5453 if (q == (PixelPacket *) NULL)
5455 for (x=0; x < (long) image->columns; x++)
5456 *q++=background_color;
5457 indexes=GetAuthenticIndexQueue(image);
5458 for (x=0; x < (long) image->columns; x++)
5459 indexes[x]=(IndexPacket) 0;
5460 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
5466 Set DirectClass image.
5468 for (y=0; y < (long) image->rows; y++)
5473 register PixelPacket
5476 q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
5477 if (q == (PixelPacket *) NULL)
5479 for (x=0; x < (long) image->columns; x++)
5480 *q++=background_color;
5481 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
5487 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5491 % S e t I m a g e A t t r i b u t e %
5495 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5497 % SetImageAttribute() searches the list of image attributes and replaces the
5498 % attribute value. If it is not found in the list, the attribute name
5499 % and value is added to the list.
5501 % The format of the SetImageAttribute method is:
5503 % MagickBooleanType SetImageAttribute(Image *image,const char *key,
5504 % const char *value)
5506 % A description of each parameter follows:
5508 % o image: the image.
5512 % o value: the value.
5515 MagickExport MagickBooleanType SetImageAttribute(Image *image,const char *key,
5518 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
5519 return(SetImageProperty(image,key,value));
5523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5527 % S e t I m a g e L i s t %
5531 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5533 % SetImageList() inserts an image into the list at the specified position.
5535 % The format of the SetImageList method is:
5537 % unsigned int SetImageList(Image *images,const Image *image,
5538 % const long offset,ExceptionInfo *exception)
5540 % A description of each parameter follows:
5542 % o images: the image list.
5544 % o image: the image.
5546 % o offset: the position within the list.
5548 % o exception: return any errors or warnings in this structure.
5551 MagickExport unsigned int SetImageList(Image **images,const Image *image,
5552 const long offset,ExceptionInfo *exception)
5560 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5561 clone=CloneImageList(image,exception);
5562 while (GetPreviousImageInList(*images) != (Image *) NULL)
5563 (*images)=GetPreviousImageInList(*images);
5564 for (i=0; i < offset; i++)
5566 if (GetNextImageInList(*images) == (Image *) NULL)
5567 return(MagickFalse);
5568 (*images)=GetNextImageInList(*images);
5570 InsertImageInList(images,clone);
5575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5579 % S e t I m a g e P i x e l s %
5583 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5585 % SetImagePixels() queues a mutable pixel region.
5586 % If the region is successfully intialized a pointer to a PixelPacket
5587 % array representing the region is returned, otherwise NULL is returned.
5588 % The returned pointer may point to a temporary working buffer for the
5589 % pixels or it may point to the final location of the pixels in memory.
5591 % Write-only access means that any existing pixel values corresponding to
5592 % the region are ignored. This useful while the initial image is being
5593 % created from scratch, or if the existing pixel values are to be
5594 % completely replaced without need to refer to their pre-existing values.
5595 % The application is free to read and write the pixel buffer returned by
5596 % SetImagePixels() any way it pleases. SetImagePixels() does not initialize
5597 % the pixel array values. Initializing pixel array values is the
5598 % application's responsibility.
5600 % Performance is maximized if the selected region is part of one row, or
5601 % one or more full rows, since then there is opportunity to access the
5602 % pixels in-place (without a copy) if the image is in RAM, or in a
5603 % memory-mapped file. The returned pointer should *never* be deallocated
5606 % Pixels accessed via the returned pointer represent a simple array of type
5607 % PixelPacket. If the image type is CMYK or the storage class is PseudoClass,
5608 % call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to obtain
5609 % the black color component or the colormap indexes (of type IndexPacket)
5610 % corresponding to the region. Once the PixelPacket (and/or IndexPacket)
5611 % array has been updated, the changes must be saved back to the underlying
5612 % image using SyncAuthenticPixels() or they may be lost.
5614 % The format of the SetImagePixels() method is:
5616 % PixelPacket *SetImagePixels(Image *image,const long x,const long y,
5617 % const unsigned long columns,const unsigned long rows)
5619 % A description of each parameter follows:
5621 % o pixels: SetImagePixels returns a pointer to the pixels if they are
5622 % transferred, otherwise a NULL is returned.
5624 % o image: the image.
5626 % o x,y,columns,rows: These values define the perimeter of a region of
5630 MagickExport PixelPacket *SetImagePixels(Image *image,const long x,const long y,
5631 const unsigned long columns,const unsigned long rows)
5633 return(QueueAuthenticPixels(image,x,y,columns,rows,&image->exception));
5637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5641 % S e t M a g i c k R e g i s t r y %
5645 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5647 % SetMagickRegistry() sets a blob into the registry and returns a unique ID.
5648 % If an error occurs, -1 is returned.
5650 % The format of the SetMagickRegistry method is:
5652 % long SetMagickRegistry(const RegistryType type,const void *blob,
5653 % const size_t length,ExceptionInfo *exception)
5655 % A description of each parameter follows:
5657 % o type: the registry type.
5659 % o blob: the address of a Binary Large OBject.
5661 % o length: For a registry type of ImageRegistryType use sizeof(Image)
5662 % otherise the blob length in number of bytes.
5664 % o exception: return any errors or warnings in this structure.
5667 MagickExport long SetMagickRegistry(const RegistryType type,const void *blob,
5668 const size_t magick_unused(length),ExceptionInfo *exception)
5679 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
5680 status=SetImageRegistry(type,key,blob,exception);
5681 if (status == MagickFalse)
5687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5691 % S e t M o n i t o r H a n d l e r %
5695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5697 % SetMonitorHandler() sets the monitor handler to the specified method
5698 % and returns the previous monitor handler.
5700 % The format of the SetMonitorHandler method is:
5702 % MonitorHandler SetMonitorHandler(MonitorHandler handler)
5704 % A description of each parameter follows:
5706 % o handler: Specifies a pointer to a method to handle monitors.
5710 MagickExport MonitorHandler GetMonitorHandler(void)
5712 return(monitor_handler);
5715 MagickExport MonitorHandler SetMonitorHandler(MonitorHandler handler)
5720 previous_handler=monitor_handler;
5721 monitor_handler=handler;
5722 return(previous_handler);
5726 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5730 % S h i f t I m a g e L i s t %
5734 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5736 % ShiftImageList() removes an image from the beginning of the list.
5738 % The format of the ShiftImageList method is:
5740 % Image *ShiftImageList(Image **images)
5742 % A description of each parameter follows:
5744 % o images: the image list.
5747 MagickExport Image *ShiftImageList(Image **images)
5749 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5750 return(RemoveFirstImageFromList(images));
5754 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5762 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5764 % SizeBlob() returns the current length of the image file or blob.
5766 % The format of the SizeBlob method is:
5768 % off_t SizeBlob(Image *image)
5770 % A description of each parameter follows:
5772 % o size: Method SizeBlob returns the current length of the image file
5775 % o image: the image.
5778 MagickExport MagickOffsetType SizeBlob(Image *image)
5780 if (image->debug != MagickFalse)
5781 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.3");
5782 return((MagickOffsetType) GetBlobSize(image));
5786 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5790 % S p l i c e I m a g e L i s t %
5794 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5796 % SpliceImageList() removes the images designated by offset and length from
5797 % the list and replaces them with the specified list.
5799 % The format of the SpliceImageList method is:
5801 % Image *SpliceImageList(Image *images,const long offset,
5802 % const unsigned long length,const Image *splices,
5803 % ExceptionInfo *exception)
5805 % A description of each parameter follows:
5807 % o images: the image list.
5809 % o offset: the position within the list.
5811 % o length: the length of the image list to remove.
5813 % o splice: Replace the removed image list with this list.
5815 % o exception: return any errors or warnings in this structure.
5818 MagickExport Image *SpliceImageList(Image *images,const long offset,
5819 const unsigned long length,const Image *splices,ExceptionInfo *exception)
5827 if (images->debug != MagickFalse)
5828 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5829 clone=CloneImageList(splices,exception);
5830 while (GetPreviousImageInList(images) != (Image *) NULL)
5831 images=GetPreviousImageInList(images);
5832 for (i=0; i < offset; i++)
5834 if (GetNextImageInList(images) == (Image *) NULL)
5835 return((Image *) NULL);
5836 images=GetNextImageInList(images);
5838 (void) SpliceImageIntoList(&images,length,clone);
5843 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5851 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5853 % Strip() strips any whitespace or quotes from the beginning and end of a
5854 % string of characters.
5856 % The format of the Strip method is:
5858 % void Strip(char *message)
5860 % A description of each parameter follows:
5862 % o message: Specifies an array of characters.
5865 MagickExport void Strip(char *message)
5871 assert(message != (char *) NULL);
5872 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5873 if (*message == '\0')
5875 if (strlen(message) == 1)
5878 while (isspace((int) ((unsigned char) *p)) != 0)
5880 if ((*p == '\'') || (*p == '"'))
5882 q=message+strlen(message)-1;
5883 while ((isspace((int) ((unsigned char) *q)) != 0) && (q > p))
5886 if ((*q == '\'') || (*q == '"'))
5888 (void) CopyMagickMemory(message,p,(size_t) (q-p+1));
5889 message[q-p+1]='\0';
5893 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5897 % S y n c C a c h e V i e w %
5901 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5903 % SyncCacheView() saves the cache view pixels to the in-memory or disk
5904 % cache. It returns MagickTrue if the pixel region is synced, otherwise
5907 % The format of the SyncCacheView method is:
5909 % MagickBooleanType SyncCacheView(CacheView *cache_view)
5911 % A description of each parameter follows:
5913 % o cache_view: the cache view.
5916 MagickExport MagickBooleanType SyncCacheView(CacheView *cache_view)
5921 status=SyncCacheViewAuthenticPixels(cache_view,
5922 GetCacheViewException(cache_view));
5927 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5931 % S y n c C a c h e V i e w P i x e l s %
5935 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5937 % SyncCacheViewPixels() saves the cache view pixels to the in-memory
5938 % or disk cache. It returns MagickTrue if the pixel region is flushed,
5939 % otherwise MagickFalse.
5941 % The format of the SyncCacheViewPixels method is:
5943 % MagickBooleanType SyncCacheViewPixels(CacheView *cache_view)
5945 % A description of each parameter follows:
5947 % o cache_view: the cache view.
5949 % o exception: return any errors or warnings in this structure.
5952 MagickExport MagickBooleanType SyncCacheViewPixels(CacheView *cache_view)
5957 status=SyncCacheViewAuthenticPixels(cache_view,
5958 GetCacheViewException(cache_view));
5963 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5967 % S y n c I m a g e P i x e l s %
5971 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5973 % SyncImagePixels() saves the image pixels to the in-memory or disk cache.
5974 % The method returns MagickTrue if the pixel region is synced, otherwise
5977 % The format of the SyncImagePixels() method is:
5979 % MagickBooleanType SyncImagePixels(Image *image)
5981 % A description of each parameter follows:
5983 % o image: the image.
5986 MagickExport MagickBooleanType SyncImagePixels(Image *image)
5988 return(SyncAuthenticPixels(image,&image->exception));
5992 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5996 % T e m p o r a r y F i l e n a m e %
6000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6002 % TemporaryFilename() replaces the contents of path by a unique path name.
6004 % The format of the TemporaryFilename method is:
6006 % void TemporaryFilename(char *path)
6008 % A description of each parameter follows.
6010 % o path: Specifies a pointer to an array of characters. The unique path
6011 % name is returned in this array.
6014 MagickExport void TemporaryFilename(char *path)
6016 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
6017 (void) AcquireUniqueFilename(path);
6018 (void) RelinquishUniqueFileResource(path);
6022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6026 % T h r e s h o l d I m a g e %
6030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6032 % ThresholdImage() changes the value of individual pixels based on
6033 % the intensity of each pixel compared to threshold. The result is a
6034 % high-contrast, two color image.
6036 % The format of the ThresholdImage method is:
6038 % unsigned int ThresholdImage(Image *image,const double threshold)
6040 % A description of each parameter follows:
6042 % o image: the image.
6044 % o threshold: Define the threshold value
6047 MagickExport unsigned int ThresholdImage(Image *image,const double threshold)
6049 #define ThresholdImageTag "Threshold/Image"
6060 assert(image != (Image *) NULL);
6061 assert(image->signature == MagickSignature);
6062 if (image->debug != MagickFalse)
6063 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6064 if (image->debug != MagickFalse)
6065 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
6066 if (!AcquireImageColormap(image,2))
6067 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
6068 "UnableToThresholdImage");
6069 for (y=0; y < (long) image->rows; y++)
6071 register IndexPacket
6077 register PixelPacket
6080 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6081 if (q == (PixelPacket *) NULL)
6083 indexes=GetAuthenticIndexQueue(image);
6084 for (x=0; x < (long) image->columns; x++)
6086 index=(IndexPacket) ((MagickRealType)
6087 PixelIntensityToQuantum(q) <= threshold ? 0 : 1);
6089 q->red=image->colormap[(long) index].red;
6090 q->green=image->colormap[(long) index].green;
6091 q->blue=image->colormap[(long) index].blue;
6094 if (!SyncAuthenticPixels(image,&image->exception))
6101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6105 % T h r e s h o l d I m a g e C h a n n e l %
6109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6111 % ThresholdImageChannel() changes the value of individual pixels based on
6112 % the intensity of each pixel channel. The result is a high-contrast image.
6114 % The format of the ThresholdImageChannel method is:
6116 % unsigned int ThresholdImageChannel(Image *image,const char *threshold)
6118 % A description of each parameter follows:
6120 % o image: the image.
6122 % o threshold: define the threshold values.
6125 MagickExport unsigned int ThresholdImageChannel(Image *image,
6126 const char *threshold)
6128 #define ThresholdImageTag "Threshold/Image"
6148 assert(image != (Image *) NULL);
6149 assert(image->signature == MagickSignature);
6150 if (image->debug != MagickFalse)
6151 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6152 if (threshold == (const char *) NULL)
6154 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
6155 return(MagickFalse);
6156 flags=ParseGeometry(threshold,&geometry_info);
6157 pixel.red=geometry_info.rho;
6158 if (flags & SigmaValue)
6159 pixel.green=geometry_info.sigma;
6161 pixel.green=pixel.red;
6162 if (flags & XiValue)
6163 pixel.blue=geometry_info.xi;
6165 pixel.blue=pixel.red;
6166 if (flags & PsiValue)
6167 pixel.opacity=geometry_info.psi;
6169 pixel.opacity=(MagickRealType) OpaqueOpacity;
6170 if (flags & PercentValue)
6172 pixel.red*=QuantumRange/100.0f;
6173 pixel.green*=QuantumRange/100.0f;
6174 pixel.blue*=QuantumRange/100.0f;
6175 pixel.opacity*=QuantumRange/100.0f;
6177 if (!(flags & SigmaValue))
6179 if (!AcquireImageColormap(image,2))
6180 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
6181 "UnableToThresholdImage");
6183 (void) GetImageDynamicThreshold(image,2.0,2.0,&pixel,&image->exception);
6185 for (y=0; y < (long) image->rows; y++)
6187 register IndexPacket
6193 register PixelPacket
6196 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6197 if (q == (PixelPacket *) NULL)
6199 indexes=GetAuthenticIndexQueue(image);
6200 if (IsMagickGray(&pixel) != MagickFalse)
6201 for (x=0; x < (long) image->columns; x++)
6203 index=(IndexPacket) ((MagickRealType)
6204 PixelIntensityToQuantum(q) <= pixel.red ? 0 : 1);
6206 q->red=image->colormap[(long) index].red;
6207 q->green=image->colormap[(long) index].green;
6208 q->blue=image->colormap[(long) index].blue;
6212 for (x=0; x < (long) image->columns; x++)
6214 q->red=(Quantum) ((MagickRealType)
6215 q->red <= pixel.red ? 0 : QuantumRange);
6216 q->green=(Quantum) ((MagickRealType)
6217 q->green <= pixel.green ? 0 : QuantumRange);
6218 q->blue=(Quantum) ((MagickRealType)
6219 q->blue <= pixel.blue ? 0 : QuantumRange);
6220 q->opacity=(Quantum) ((MagickRealType)
6221 q->opacity <= pixel.opacity ? 0 : QuantumRange);
6224 if (!SyncAuthenticPixels(image,&image->exception))
6231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6235 + T r a n s f o r m C o l o r s p a c e %
6239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6241 % TransformColorspace() converts the image to a specified colorspace.
6242 % If the image is already in the requested colorspace, no work is performed.
6243 % Note that the current colorspace is stored in the image colorspace member.
6244 % The transformation matrices are not necessarily the standard ones: the
6245 % weights are rescaled to normalize the range of the transformed values to
6246 % be [0..QuantumRange].
6248 % The format of the TransformColorspace method is:
6250 % unsigned int (void) TransformColorspace(Image *image,
6251 % const ColorspaceType colorspace)
6253 % A description of each parameter follows:
6255 % o image: the image to transform
6257 % o colorspace: the desired colorspace.
6260 MagickExport unsigned int TransformColorspace(Image *image,
6261 const ColorspaceType colorspace)
6263 assert(image != (Image *) NULL);
6264 assert(image->signature == MagickSignature);
6265 if (image->debug != MagickFalse)
6266 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
6267 return(TransformImageColorspace(image,colorspace));
6271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6275 % T r a n s f o r m H S L %
6279 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6281 % TransformHSL() converts a (red, green, blue) to a (hue, saturation,
6282 % lightness) triple.
6284 % The format of the TransformHSL method is:
6286 % void TransformHSL(const Quantum red,const Quantum green,
6287 % const Quantum blue,double *hue,double *saturation,double *lightness)
6289 % A description of each parameter follows:
6291 % o red, green, blue: A Quantum value representing the red, green, and
6292 % blue component of a pixel..
6294 % o hue, saturation, lightness: A pointer to a double value representing a
6295 % component of the HSL color space.
6299 static inline double MagickMin(const double x,const double y)
6306 MagickExport void TransformHSL(const Quantum red,const Quantum green,
6307 const Quantum blue,double *hue,double *saturation,double *lightness)
6318 Convert RGB to HSL colorspace.
6320 assert(hue != (double *) NULL);
6321 assert(saturation != (double *) NULL);
6322 assert(lightness != (double *) NULL);
6324 g=QuantumScale*green;
6325 b=QuantumScale*blue;
6326 max=MagickMax(r,MagickMax(g,b));
6327 min=MagickMin(r,MagickMin(g,b));
6330 *lightness=(double) ((min+max)/2.0);
6334 *saturation=(double) (delta/((*lightness < 0.5) ? (min+max) :
6337 *hue=(double) (g == min ? 5.0+(max-b)/delta : 1.0-(max-g)/delta);
6340 *hue=(double) (b == min ? 1.0+(max-r)/delta : 3.0-(max-b)/delta);
6342 *hue=(double) (r == min ? 3.0+(max-g)/delta : 5.0-(max-r)/delta);
6347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6351 % T r a n s l a t e T e x t %
6355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6357 % TranslateText() replaces any embedded formatting characters with the
6358 % appropriate image attribute and returns the translated text.
6360 % The format of the TranslateText method is:
6362 % char *TranslateText(const ImageInfo *image_info,Image *image,
6363 % const char *embed_text)
6365 % A description of each parameter follows:
6367 % o image_info: the image info.
6369 % o image: the image.
6371 % o embed_text: the address of a character string containing the embedded
6372 % formatting characters.
6375 MagickExport char *TranslateText(const ImageInfo *image_info,Image *image,
6376 const char *embed_text)
6378 assert(image != (Image *) NULL);
6379 assert(image->signature == MagickSignature);
6380 if (image->debug != MagickFalse)
6381 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.6");
6382 return(InterpretImageProperties(image_info,image,embed_text));
6386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6390 % T r a n s p a r e n t I m a g e %
6394 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6396 % TransparentImage() changes the opacity value associated with any pixel
6397 % that matches color to the value defined by opacity.
6399 % By default color must match a particular pixel color exactly. However,
6400 % in many cases two colors may differ by a small amount. Fuzz defines
6401 % how much tolerance is acceptable to consider two colors as the same.
6402 % For example, set fuzz to 10 and the color red at intensities of 100 and
6403 % 102 respectively are now interpreted as the same color.
6405 % The format of the TransparentImage method is:
6407 % MagickBooleanType TransparentImage(Image *image,
6408 % const PixelPacket target,const Quantum opacity)
6410 % A description of each parameter follows:
6412 % o image: the image.
6414 % o target: the RGB value of the target color.
6416 % o opacity: the replacement opacity value.
6419 MagickExport MagickBooleanType TransparentImage(Image *image,
6420 const PixelPacket target,const Quantum opacity)
6422 #define TransparentImageTag "Transparent/Image"
6431 Make image color transparent.
6433 assert(image != (Image *) NULL);
6434 assert(image->signature == MagickSignature);
6435 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.1.0");
6436 if (image->debug != MagickFalse)
6437 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6438 if (image->matte == MagickFalse)
6439 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
6440 for (y=0; y < (long) image->rows; y++)
6445 register PixelPacket
6448 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6449 if (q == (PixelPacket *) NULL)
6451 for (x=0; x < (long) image->columns; x++)
6453 if (IsColorSimilar(image,q,&target) != MagickFalse)
6457 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
6459 proceed=SetImageProgress(image,TransparentImageTag,y,image->rows);
6460 if (proceed == MagickFalse)
6467 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6471 % U n s h i f t I m a g e L i s t %
6475 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6477 % UnshiftImageList() adds the image to the beginning of the list.
6479 % The format of the UnshiftImageList method is:
6481 % unsigned int UnshiftImageList(Image *images,const Image *image,
6482 % ExceptionInfo *exception)
6484 % A description of each parameter follows:
6486 % o images: the image list.
6488 % o image: the image.
6490 % o exception: return any errors or warnings in this structure.
6493 MagickExport unsigned int UnshiftImageList(Image **images,const Image *image,
6494 ExceptionInfo *exception)
6496 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
6497 PrependImageToList(images,CloneImageList(image,exception));
6502 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6506 + V a l i d a t e C o l o r m a p I n d e x %
6510 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6512 % ValidateColormapIndex() validates the colormap index. If the index does
6513 % not range from 0 to the number of colors in the colormap an exception
6514 % issued and 0 is returned.
6516 % The format of the ValidateColormapIndex method is:
6518 % IndexPacket ValidateColormapIndex(Image *image,const unsigned int index)
6520 % A description of each parameter follows:
6522 % o index: Method ValidateColormapIndex returns colormap index if it is
6523 % valid other an exception issued and 0 is returned.
6525 % o image: the image.
6527 % o index: This integer is the colormap index.
6531 MagickExport IndexPacket ValidateColormapIndex(Image *image,
6532 const unsigned long index)
6534 if (image->debug != MagickFalse)
6535 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.4");
6536 return(ConstrainColormapIndex(image,index));