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-2009 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/geometry.h"
66 #include "magick/identify.h"
67 #include "magick/image.h"
68 #include "magick/image-private.h"
69 #include "magick/list.h"
70 #include "magick/log.h"
71 #include "magick/memory_.h"
72 #include "magick/magick.h"
73 #include "magick/monitor.h"
74 #include "magick/monitor-private.h"
75 #include "magick/paint.h"
76 #include "magick/pixel.h"
77 #include "magick/pixel-private.h"
78 #include "magick/quantize.h"
79 #include "magick/random_.h"
80 #include "magick/resource_.h"
81 #include "magick/semaphore.h"
82 #include "magick/segment.h"
83 #include "magick/splay-tree.h"
84 #include "magick/string_.h"
85 #include "magick/threshold.h"
86 #include "magick/transform.h"
87 #include "magick/utility.h"
89 #if !defined(MAGICKCORE_EXCLUDE_DEPRECATED)
94 monitor_handler = (MonitorHandler) NULL;
97 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 % A c q u i r e C a c h e V i e w I n d e x e s %
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 % AcquireCacheViewIndexes() returns the indexes associated with the specified
110 % The format of the AcquireCacheViewIndexes method is:
112 % const IndexPacket *AcquireCacheViewIndexes(const CacheView *cache_view)
114 % A description of each parameter follows:
116 % o cache_view: the cache view.
119 MagickExport const IndexPacket *AcquireCacheViewIndexes(
120 const CacheView *cache_view)
122 return(GetCacheViewVirtualIndexQueue(cache_view));
126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 % A c q u i r e C a c h e V i e w P i x e l s %
134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136 % AcquireCacheViewPixels() gets pixels from the in-memory or disk pixel cache
137 % as defined by the geometry parameters. A pointer to the pixels is returned
138 % if the pixels are transferred, otherwise a NULL is returned.
140 % The format of the AcquireCacheViewPixels method is:
142 % const PixelPacket *AcquireCacheViewPixels(const CacheView *cache_view,
143 % const long x,const long y,const unsigned long columns,
144 % const unsigned long rows,ExceptionInfo *exception)
146 % A description of each parameter follows:
148 % o cache_view: the cache view.
150 % o x,y,columns,rows: These values define the perimeter of a region of
153 % o exception: return any errors or warnings in this structure.
156 MagickExport const PixelPacket *AcquireCacheViewPixels(
157 const CacheView *cache_view,const long x,const long y,
158 const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
160 return(GetCacheViewVirtualPixels(cache_view,x,y,columns,rows,exception));
164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 % A c q u i r e I m a g e P i x e l s %
172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174 % AcquireImagePixels() returns an immutable pixel region. If the
175 % region is successfully accessed, a pointer to it is returned, otherwise
176 % NULL is returned. The returned pointer may point to a temporary working
177 % copy of the pixels or it may point to the original pixels in memory.
178 % Performance is maximized if the selected region is part of one row, or one
179 % or more full rows, since there is opportunity to access the pixels in-place
180 % (without a copy) if the image is in RAM, or in a memory-mapped file. The
181 % returned pointer should *never* be deallocated by the user.
183 % Pixels accessed via the returned pointer represent a simple array of type
184 % PixelPacket. If the image type is CMYK or the storage class is PseudoClass,
185 % call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to access the
186 % black color component or to obtain the colormap indexes (of type IndexPacket)
187 % corresponding to the region.
189 % If you plan to modify the pixels, use GetAuthenticPixels() instead.
191 % Note, the AcquireImagePixels() and GetAuthenticPixels() methods are not
192 % thread-safe. In a threaded environment, use GetCacheViewVirtualPixels() or
193 % GetCacheViewAuthenticPixels() instead.
195 % The format of the AcquireImagePixels() method is:
197 % const PixelPacket *AcquireImagePixels(const Image *image,const long x,
198 % const long y,const unsigned long columns,const unsigned long rows,
199 % ExceptionInfo *exception)
201 % A description of each parameter follows:
203 % o image: the image.
205 % o x,y,columns,rows: These values define the perimeter of a region of
208 % o exception: return any errors or warnings in this structure.
211 MagickExport const PixelPacket *AcquireImagePixels(const Image *image,
212 const long x,const long y,const unsigned long columns,
213 const unsigned long rows,ExceptionInfo *exception)
215 return(GetVirtualPixels(image,x,y,columns,rows,exception));
219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 % A c q u i r e I n d e x e s %
227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229 % AcquireIndexes() returns the black channel or the colormap indexes
230 % associated with the last call to QueueAuthenticPixels() or GetVirtualPixels().
231 % NULL is returned if the black channel or colormap indexes are not available.
233 % The format of the AcquireIndexes() method is:
235 % const IndexPacket *AcquireIndexes(const Image *image)
237 % A description of each parameter follows:
239 % o indexes: AcquireIndexes() returns the indexes associated with the last
240 % call to QueueAuthenticPixels() or GetVirtualPixels().
242 % o image: the image.
245 MagickExport const IndexPacket *AcquireIndexes(const Image *image)
247 return(GetVirtualIndexQueue(image));
251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
255 % A c q u i r e M e m o r y %
259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
261 % AcquireMemory() returns a pointer to a block of memory at least size bytes
262 % suitably aligned for any use.
264 % The format of the AcquireMemory method is:
266 % void *AcquireMemory(const size_t size)
268 % A description of each parameter follows:
270 % o size: the size of the memory in bytes to allocate.
273 MagickExport void *AcquireMemory(const size_t size)
279 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
280 allocation=malloc(size);
285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
289 % A c q u i r e O n e C a c h e V i e w P i x e l %
293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
295 % AcquireOneCacheViewPixel() returns a single pixel at the specified (x,y)
296 % location. The image background color is returned if an error occurs. If
297 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
299 % The format of the AcquireOneCacheViewPixel method is:
301 % MagickBooleanType AcquireOneCacheViewPixel(const CacheView *cache_view,
302 % const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
304 % A description of each parameter follows:
306 % o cache_view: the cache view.
308 % o x,y: These values define the offset of the pixel.
310 % o pixel: return a pixel at the specified (x,y) location.
312 % o exception: return any errors or warnings in this structure.
315 MagickExport MagickBooleanType AcquireOneCacheViewPixel(
316 const CacheView *cache_view,const long x,const long y,PixelPacket *pixel,
317 ExceptionInfo *exception)
319 return(GetOneCacheViewVirtualPixel(cache_view,x,y,pixel,exception));
323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
327 % 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 %
331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
333 % AcquireOneCacheViewVirtualPixel() returns a single pixel at the specified
334 % (x,y) location. The image background color is returned if an error occurs.
335 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
337 % The format of the AcquireOneCacheViewPixel method is:
339 % MagickBooleanType AcquireOneCacheViewVirtualPixel(
340 % const CacheView *cache_view,
341 % const VirtualPixelMethod virtual_pixel_method,const long x,
342 % const long y,PixelPacket *pixel,ExceptionInfo *exception)
344 % A description of each parameter follows:
346 % o cache_view: the cache view.
348 % o virtual_pixel_method: the virtual pixel method.
350 % o x,y: These values define the offset of the pixel.
352 % o pixel: return a pixel at the specified (x,y) location.
354 % o exception: return any errors or warnings in this structure.
357 MagickExport MagickBooleanType AcquireOneCacheViewVirtualPixel(
358 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
359 const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
364 status=GetOneCacheViewVirtualMethodPixel(cache_view,virtual_pixel_method,
365 x,y,pixel,exception);
370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
374 % A c q u i r e O n e M a g i c k P i x e l %
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380 % AcquireOneMagickPixel() returns a single pixel at the specified (x,y)
381 % location. The image background color is returned if an error occurs. If
382 % you plan to modify the pixel, use GetOnePixel() instead.
384 % The format of the AcquireOneMagickPixel() method is:
386 % MagickPixelPacket AcquireOneMagickPixel(const Image image,const long x,
387 % const long y,ExceptionInfo exception)
389 % A description of each parameter follows:
391 % o image: the image.
393 % o x,y: These values define the location of the pixel to return.
395 % o exception: return any errors or warnings in this structure.
398 MagickExport MagickPixelPacket AcquireOneMagickPixel(const Image *image,
399 const long x,const long y,ExceptionInfo *exception)
404 (void) GetOneVirtualMagickPixel(image,x,y,&pixel,exception);
409 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
413 % A c q u i r e O n e P i x e l %
417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419 % AcquireOnePixel() returns a single pixel at the specified (x,y) location.
420 % The image background color is returned if an error occurs. If you plan to
421 % modify the pixel, use GetOnePixel() instead.
423 % The format of the AcquireOnePixel() method is:
425 % PixelPacket AcquireOnePixel(const Image image,const long x,
426 % const long y,ExceptionInfo exception)
428 % A description of each parameter follows:
430 % o image: the image.
432 % o x,y: These values define the location of the pixel to return.
434 % o exception: return any errors or warnings in this structure.
437 MagickExport PixelPacket AcquireOnePixel(const Image *image,const long x,
438 const long y,ExceptionInfo *exception)
443 (void) GetOneVirtualPixel(image,x,y,&pixel,exception);
448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
452 % A c q u i r e O n e V i r t u a l P i x e l %
456 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
458 % AcquireOneVirtualPixel() returns a single pixel at the specified (x,y)
459 % location as defined by specified pixel method. The image background color
460 % is returned if an error occurs. If you plan to modify the pixel, use
461 % GetOnePixel() instead.
463 % The format of the AcquireOneVirtualPixel() method is:
465 % PixelPacket AcquireOneVirtualPixel(const Image image,
466 % const VirtualPixelMethod virtual_pixel_method,const long x,
467 % const long y,ExceptionInfo exception)
469 % A description of each parameter follows:
471 % o virtual_pixel_method: the virtual pixel method.
473 % o image: the image.
475 % o x,y: These values define the location of the pixel to return.
477 % o exception: return any errors or warnings in this structure.
480 MagickExport PixelPacket AcquireOneVirtualPixel(const Image *image,
481 const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
482 ExceptionInfo *exception)
487 (void) GetOneVirtualMethodPixel(image,virtual_pixel_method,x,y,&pixel,
493 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
497 % A c q u i r e P i x e l s %
501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503 % AcquirePixels() returns the pixels associated with the last call to
504 % QueueAuthenticPixels() or GetVirtualPixels().
506 % The format of the AcquirePixels() method is:
508 % const PixelPacket *AcquirePixels(const Image image)
510 % A description of each parameter follows:
512 % o image: the image.
515 MagickExport const PixelPacket *AcquirePixels(const Image *image)
517 return(GetVirtualPixelQueue(image));
521 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
525 % A f f i n i t y I m a g e %
529 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
531 % AffinityImage() replaces the colors of an image with the closest color from
534 % The format of the AffinityImage method is:
536 % MagickBooleanType AffinityImage(const QuantizeInfo *quantize_info,
537 % Image *image,const Image *affinity_image)
539 % A description of each parameter follows:
541 % o quantize_info: Specifies a pointer to an QuantizeInfo structure.
543 % o image: the image.
545 % o affinity_image: the reference image.
548 MagickExport MagickBooleanType AffinityImage(const QuantizeInfo *quantize_info,
549 Image *image,const Image *affinity_image)
551 return(RemapImage(quantize_info,image,affinity_image));
555 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
559 % A f f i n i t y I m a g e s %
563 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
565 % AffinityImages() replaces the colors of a sequence of images with the
566 % closest color from a reference image.
568 % The format of the AffinityImage method is:
570 % MagickBooleanType AffinityImages(const QuantizeInfo *quantize_info,
571 % Image *images,Image *affinity_image)
573 % A description of each parameter follows:
575 % o quantize_info: Specifies a pointer to an QuantizeInfo structure.
577 % o images: the image sequence.
579 % o affinity_image: the reference image.
582 MagickExport MagickBooleanType AffinityImages(const QuantizeInfo *quantize_info,
583 Image *images,const Image *affinity_image)
585 return(RemapImages(quantize_info,images,affinity_image));
589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
593 % A l l o c a t e I m a g e %
597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599 % AllocateImage() returns a pointer to an image structure initialized to
602 % The format of the AllocateImage method is:
604 % Image *AllocateImage(const ImageInfo *image_info)
606 % A description of each parameter follows:
608 % o image_info: Many of the image default values are set from this
609 % structure. For example, filename, compression, depth, background color,
613 MagickExport Image *AllocateImage(const ImageInfo *image_info)
615 return(AcquireImage(image_info));
619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
623 % A l l o c a t e I m a g e C o l o r m a p %
627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
629 % AllocateImageColormap() allocates an image colormap and initializes
630 % it to a linear gray colorspace. If the image already has a colormap,
631 % it is replaced. AllocateImageColormap() returns MagickTrue if successful,
632 % otherwise MagickFalse if there is not enough memory.
634 % The format of the AllocateImageColormap method is:
636 % MagickBooleanType AllocateImageColormap(Image *image,
637 % const unsigned long colors)
639 % A description of each parameter follows:
641 % o image: the image.
643 % o colors: the number of colors in the image colormap.
646 MagickExport MagickBooleanType AllocateImageColormap(Image *image,
647 const unsigned long colors)
649 return(AcquireImageColormap(image,colors));
653 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
657 % A l l o c a t e N e x t I m a g e %
661 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
663 % AllocateNextImage() initializes the next image in a sequence to
664 % default values. The next member of image points to the newly allocated
665 % image. If there is a memory shortage, next is assigned NULL.
667 % The format of the AllocateNextImage method is:
669 % void AllocateNextImage(const ImageInfo *image_info,Image *image)
671 % A description of each parameter follows:
673 % o image_info: Many of the image default values are set from this
674 % structure. For example, filename, compression, depth, background color,
677 % o image: the image.
680 MagickExport void AllocateNextImage(const ImageInfo *image_info,Image *image)
682 AcquireNextImage(image_info,image);
686 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
690 % A c q u i r e S t r i n g %
694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
696 % AllocateString() allocates memory for a string and copies the source string
697 % to that memory location (and returns it).
699 % The format of the AllocateString method is:
701 % char *AllocateString(const char *source)
703 % A description of each parameter follows:
705 % o source: A character string.
708 MagickExport char *AllocateString(const char *source)
716 assert(source != (const char *) NULL);
717 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
718 length=strlen(source)+MaxTextExtent+1;
719 destination=(char *) AcquireQuantumMemory(length,sizeof(*destination));
720 if (destination == (char *) NULL)
721 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
723 if (source != (char *) NULL)
724 (void) CopyMagickString(destination,source,length);
729 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
733 % C h a n n e l I m a g e %
737 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
739 % Extract a channel from the image. A channel is a particular color component
740 % of each pixel in the image.
742 % The format of the ChannelImage method is:
744 % unsigned int ChannelImage(Image *image,const ChannelType channel)
746 % A description of each parameter follows:
748 % o image: the image.
750 % o channel: Identify which channel to extract: RedChannel, GreenChannel,
751 % BlueChannel, OpacityChannel, CyanChannel, MagentaChannel, YellowChannel,
755 MagickExport unsigned int ChannelImage(Image *image,const ChannelType channel)
757 return(SeparateImageChannel(image,channel));
761 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
765 % C h a n n e l T h r e s h o l d I m a g e %
769 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771 % ChannelThresholdImage() changes the value of individual pixels based on
772 % the intensity of each pixel channel. The result is a high-contrast image.
774 % The format of the ChannelThresholdImage method is:
776 % unsigned int ChannelThresholdImage(Image *image,const char *level)
778 % A description of each parameter follows:
780 % o image: the image.
782 % o level: define the threshold values.
785 MagickExport unsigned int ChannelThresholdImage(Image *image,const char *level)
797 assert(image != (Image *) NULL);
798 assert(image->signature == MagickSignature);
799 if (image->debug != MagickFalse)
800 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
801 if (image->debug != MagickFalse)
802 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
803 if (level == (char *) NULL)
805 flags=ParseGeometry(level,&geometry_info);
806 threshold.red=geometry_info.rho;
807 threshold.green=geometry_info.sigma;
808 if ((flags & SigmaValue) == 0)
809 threshold.green=threshold.red;
810 threshold.blue=geometry_info.xi;
811 if ((flags & XiValue) == 0)
812 threshold.blue=threshold.red;
813 status=BilevelImageChannel(image,RedChannel,threshold.red);
814 status|=BilevelImageChannel(image,GreenChannel,threshold.green);
815 status|=BilevelImageChannel(image,BlueChannel,threshold.blue);
820 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
824 % C l i p I m a g e P a t h %
828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 % ClipPathImage() sets the image clip mask based any clipping path information
833 % The format of the ClipImage method is:
835 % MagickBooleanType ClipPathImage(Image *image,const char *pathname,
836 % const MagickBooleanType inside)
838 % A description of each parameter follows:
840 % o image: the image.
842 % o pathname: name of clipping path resource. If name is preceded by #, use
843 % clipping path numbered by name.
845 % o inside: if non-zero, later operations take effect inside clipping path.
846 % Otherwise later operations take effect outside clipping path.
849 MagickExport MagickBooleanType ClipPathImage(Image *image,const char *pathname,
850 const MagickBooleanType inside)
852 return(ClipImagePath(image,pathname,inside));
856 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
860 % C l o n e I m a g e A t t r i b u t e s %
864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
866 % CloneImageAttributes() clones one or more image attributes.
868 % The format of the CloneImageAttributes method is:
870 % MagickBooleanType CloneImageAttributes(Image *image,
871 % const Image *clone_image)
873 % A description of each parameter follows:
875 % o image: the image.
877 % o clone_image: the clone image.
880 MagickExport MagickBooleanType CloneImageAttributes(Image *image,
881 const Image *clone_image)
883 return(CloneImageProperties(image,clone_image));
887 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
891 % C l o n e M e m o r y %
895 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
897 % CloneMemory() copies size bytes from memory area source to the destination.
898 % Copying between objects that overlap will take place correctly. It returns
901 % The format of the CloneMemory method is:
903 % void *CloneMemory(void *destination,const void *source,
906 % A description of each parameter follows:
908 % o destination: the destination.
910 % o source: the source.
912 % o size: the size of the memory in bytes to allocate.
915 MagickExport void *CloneMemory(void *destination,const void *source,
918 register const unsigned char
921 register unsigned char
927 assert(destination != (void *) NULL);
928 assert(source != (const void *) NULL);
929 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
930 p=(const unsigned char *) source;
931 q=(unsigned char *) destination;
932 if ((p <= q) || ((p+size) >= q))
933 return(CopyMagickMemory(destination,source,size));
935 Overlap, copy backwards.
939 for (i=(long) (size-1); i >= 0; i--)
945 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
949 % C l o s e C a c h e V i e w %
953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
955 % CloseCacheView() closes the specified view returned by a previous call to
958 % The format of the CloseCacheView method is:
960 % CacheView *CloseCacheView(CacheView *view_info)
962 % A description of each parameter follows:
964 % o view_info: the address of a structure of type CacheView.
967 MagickExport CacheView *CloseCacheView(CacheView *view_info)
969 return(DestroyCacheView(view_info));
973 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
977 % C o l o r F l o o d f i l l I m a g e %
981 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
983 % ColorFloodfill() changes the color value of any pixel that matches
984 % target and is an immediate neighbor. If the method FillToBorderMethod is
985 % specified, the color value is changed for any neighbor pixel that does not
986 % match the bordercolor member of image.
988 % By default target must match a particular pixel color exactly.
989 % However, in many cases two colors may differ by a small amount. The
990 % fuzz member of image defines how much tolerance is acceptable to
991 % consider two colors as the same. For example, set fuzz to 10 and the
992 % color red at intensities of 100 and 102 respectively are now
993 % interpreted as the same color for the purposes of the floodfill.
995 % The format of the ColorFloodfillImage method is:
997 % MagickBooleanType ColorFloodfillImage(Image *image,
998 % const DrawInfo *draw_info,const PixelPacket target,
999 % const long x_offset,const long y_offset,const PaintMethod method)
1001 % A description of each parameter follows:
1003 % o image: the image.
1005 % o draw_info: the draw info.
1007 % o target: the RGB value of the target color.
1009 % o x,y: the starting location of the operation.
1011 % o method: Choose either FloodfillMethod or FillToBorderMethod.
1015 #define MaxStacksize (1UL << 15)
1016 #define PushSegmentStack(up,left,right,delta) \
1018 if (s >= (segment_stack+MaxStacksize)) \
1019 ThrowBinaryException(DrawError,"SegmentStackOverflow",image->filename) \
1022 if ((((up)+(delta)) >= 0) && (((up)+(delta)) < (long) image->rows)) \
1024 s->x1=(double) (left); \
1025 s->y1=(double) (up); \
1026 s->x2=(double) (right); \
1027 s->y2=(double) (delta); \
1033 MagickExport MagickBooleanType ColorFloodfillImage(Image *image,
1034 const DrawInfo *draw_info,const PixelPacket target,const long x_offset,
1035 const long y_offset,const PaintMethod method)
1054 register SegmentInfo
1061 Check boundary conditions.
1063 assert(image != (Image *) NULL);
1064 assert(image->signature == MagickSignature);
1065 if (image->debug != MagickFalse)
1066 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1067 assert(draw_info != (DrawInfo *) NULL);
1068 assert(draw_info->signature == MagickSignature);
1069 if ((x_offset < 0) || (x_offset >= (long) image->columns))
1070 return(MagickFalse);
1071 if ((y_offset < 0) || (y_offset >= (long) image->rows))
1072 return(MagickFalse);
1073 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1074 return(MagickFalse);
1075 if (image->matte == MagickFalse)
1076 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
1077 floodplane_image=CloneImage(image,image->columns,image->rows,MagickTrue,
1079 if (floodplane_image == (Image *) NULL)
1080 return(MagickFalse);
1081 (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel);
1083 Set floodfill color.
1085 segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
1086 sizeof(*segment_stack));
1087 if (segment_stack == (SegmentInfo *) NULL)
1089 floodplane_image=DestroyImage(floodplane_image);
1090 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
1094 Push initial segment on stack.
1100 PushSegmentStack(y,x,x,1);
1101 PushSegmentStack(y+1,x,x,-1);
1102 while (s > segment_stack)
1104 register const PixelPacket
1110 register PixelPacket
1114 Pop segment off stack.
1119 offset=(long) s->y2;
1120 y=(long) s->y1+offset;
1122 Recolor neighboring pixels.
1124 p=GetVirtualPixels(image,0,y,(unsigned long) (x1+1),1,&image->exception);
1125 q=GetAuthenticPixels(floodplane_image,0,y,(unsigned long) (x1+1),1,
1127 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
1131 for (x=x1; x >= 0; x--)
1133 if (q->opacity == (Quantum) TransparentOpacity)
1135 if (method == FloodfillMethod)
1137 if (IsColorSimilar(image,p,&target) == MagickFalse)
1141 if (IsColorSimilar(image,p,&target) != MagickFalse)
1143 q->opacity=(Quantum) TransparentOpacity;
1147 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
1149 skip=x >= x1 ? MagickTrue : MagickFalse;
1150 if (skip == MagickFalse)
1154 PushSegmentStack(y,start,x1-1,-offset);
1159 if (skip == MagickFalse)
1161 if (x < (long) image->columns)
1163 p=GetVirtualPixels(image,x,y,image->columns-x,1,
1165 q=GetAuthenticPixels(floodplane_image,x,y,image->columns-x,1,
1167 if ((p == (const PixelPacket *) NULL) ||
1168 (q == (PixelPacket *) NULL))
1170 for ( ; x < (long) image->columns; x++)
1172 if (q->opacity == (Quantum) TransparentOpacity)
1174 if (method == FloodfillMethod)
1176 if (IsColorSimilar(image,p,&target) == MagickFalse)
1180 if (IsColorSimilar(image,p,&target) != MagickFalse)
1182 q->opacity=(Quantum) TransparentOpacity;
1186 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
1189 PushSegmentStack(y,start,x-1,offset);
1191 PushSegmentStack(y,x2+1,x-1,-offset);
1197 p=GetVirtualPixels(image,x,y,(unsigned long) (x2-x+1),1,
1199 q=GetAuthenticPixels(floodplane_image,x,y,(unsigned long) (x2-x+1),1,
1201 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
1203 for ( ; x <= x2; x++)
1205 if (q->opacity == (Quantum) TransparentOpacity)
1207 if (method == FloodfillMethod)
1209 if (IsColorSimilar(image,p,&target) != MagickFalse)
1213 if (IsColorSimilar(image,p,&target) == MagickFalse)
1222 for (y=0; y < (long) image->rows; y++)
1224 register const PixelPacket
1230 register PixelPacket
1234 Tile fill color onto floodplane.
1236 p=GetVirtualPixels(floodplane_image,0,y,image->columns,1,
1238 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
1239 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
1241 for (x=0; x < (long) image->columns; x++)
1243 if (p->opacity != OpaqueOpacity)
1245 (void) GetFillColor(draw_info,x,y,&fill_color);
1246 MagickCompositeOver(&fill_color,(MagickRealType) fill_color.opacity,q,
1247 (MagickRealType) q->opacity,q);
1252 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
1255 segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
1256 floodplane_image=DestroyImage(floodplane_image);
1257 return(y == (long) image->rows ? MagickTrue : MagickFalse);
1261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1265 % D e l e t e I m a g e A t t r i b u t e %
1269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1271 % DeleteImageAttribute() deletes an attribute from the image.
1273 % The format of the DeleteImageAttribute method is:
1275 % MagickBooleanType DeleteImageAttribute(Image *image,const char *key)
1277 % A description of each parameter follows:
1279 % o image: the image info.
1281 % o key: the image key.
1284 MagickExport MagickBooleanType DeleteImageAttribute(Image *image,
1287 return(DeleteImageProperty(image,key));
1291 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1295 % D e l e t e I m a g e L i s t %
1299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1301 % DeleteImageList() deletes an image at the specified position in the list.
1303 % The format of the DeleteImageList method is:
1305 % unsigned int DeleteImageList(Image *images,const long offset)
1307 % A description of each parameter follows:
1309 % o images: the image list.
1311 % o offset: the position within the list.
1314 MagickExport unsigned int DeleteImageList(Image *images,const long offset)
1319 if (images->debug != MagickFalse)
1320 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
1321 while (GetPreviousImageInList(images) != (Image *) NULL)
1322 images=GetPreviousImageInList(images);
1323 for (i=0; i < offset; i++)
1325 if (GetNextImageInList(images) == (Image *) NULL)
1326 return(MagickFalse);
1327 images=GetNextImageInList(images);
1329 DeleteImageFromList(&images);
1334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1338 % D e l e t e M a g i c k R e g i s t r y %
1342 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1344 % DeleteMagickRegistry() deletes an entry in the registry as defined by the id.
1345 % It returns MagickTrue if the entry is deleted otherwise MagickFalse if no
1346 % entry is found in the registry that matches the id.
1348 % The format of the DeleteMagickRegistry method is:
1350 % MagickBooleanType DeleteMagickRegistry(const long id)
1352 % A description of each parameter follows:
1354 % o id: the registry id.
1357 MagickExport MagickBooleanType DeleteMagickRegistry(const long id)
1362 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
1363 return(DeleteImageRegistry(key));
1367 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1371 + D e s t r o y M a g i c k R e g i s t r y %
1375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1377 % DestroyMagickRegistry() deallocates memory associated the magick registry.
1379 % The format of the DestroyMagickRegistry method is:
1381 % void DestroyMagickRegistry(void)
1384 MagickExport void DestroyMagickRegistry(void)
1386 DestroyRegistryComponent();
1390 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1394 % D e s c r i b e I m a g e %
1398 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1400 % DescribeImage() describes an image by printing its attributes to the file.
1401 % Attributes include the image width, height, size, and others.
1403 % The format of the DescribeImage method is:
1405 % MagickBooleanType DescribeImage(Image *image,FILE *file,
1406 % const MagickBooleanType verbose)
1408 % A description of each parameter follows:
1410 % o image: the image.
1412 % o file: the file, typically stdout.
1414 % o verbose: A value other than zero prints more detailed information
1418 MagickExport MagickBooleanType DescribeImage(Image *image,FILE *file,
1419 const MagickBooleanType verbose)
1421 return(IdentifyImage(image,file,verbose));
1425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1429 % D e s t r o y I m a g e A t t r i b u t e s %
1433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1435 % DestroyImageAttributes() deallocates memory associated with the image
1438 % The format of the DestroyImageAttributes method is:
1440 % DestroyImageAttributes(Image *image)
1442 % A description of each parameter follows:
1444 % o image: the image.
1447 MagickExport void DestroyImageAttributes(Image *image)
1449 assert(image != (Image *) NULL);
1450 assert(image->signature == MagickSignature);
1451 if (image->debug != MagickFalse)
1452 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1453 if (image->attributes != (void *) NULL)
1454 image->attributes=(void *) DestroySplayTree((SplayTreeInfo *)
1459 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1463 % D e s t r o y I m a g e s %
1467 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1469 % DestroyImages() destroys an image list.
1471 % The format of the DestroyImages method is:
1473 % void DestroyImages(Image *image)
1475 % A description of each parameter follows:
1477 % o image: the image sequence.
1480 MagickExport void DestroyImages(Image *image)
1482 if (image == (Image *) NULL)
1484 if (image->debug != MagickFalse)
1485 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.3");
1486 image=DestroyImageList(image);
1490 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1494 % D e s t r o y M a g i c k %
1498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1500 % DestroyMagick() destroys the ImageMagick environment.
1502 % The format of the DestroyMagick function is:
1504 % DestroyMagick(void)
1507 MagickExport void DestroyMagick(void)
1509 MagickCoreTerminus();
1513 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1517 % D i s p a t c h I m a g e %
1521 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1523 % DispatchImage() extracts pixel data from an image and returns it to you.
1524 % The method returns MagickFalse on success otherwise MagickTrue if an error is
1525 % encountered. The data is returned as char, short int, int, long, float,
1526 % or double in the order specified by map.
1528 % Suppose you want to extract the first scanline of a 640x480 image as
1529 % character data in red-green-blue order:
1531 % DispatchImage(image,0,0,640,1,"RGB",CharPixel,pixels,exception);
1533 % The format of the DispatchImage method is:
1535 % unsigned int DispatchImage(const Image *image,const long x_offset,
1536 % const long y_offset,const unsigned long columns,
1537 % const unsigned long rows,const char *map,const StorageType type,
1538 % void *pixels,ExceptionInfo *exception)
1540 % A description of each parameter follows:
1542 % o image: the image.
1544 % o x_offset, y_offset, columns, rows: These values define the perimeter
1545 % of a region of pixels you want to extract.
1547 % o map: This string reflects the expected ordering of the pixel array.
1548 % It can be any combination or order of R = red, G = green, B = blue,
1549 % A = alpha, C = cyan, Y = yellow, M = magenta, K = black, or
1550 % I = intensity (for grayscale).
1552 % o type: Define the data type of the pixels. Float and double types are
1553 % normalized to [0..1] otherwise [0..QuantumRange]. Choose from these
1554 % types: CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel, or
1557 % o pixels: This array of values contain the pixel components as defined by
1558 % map and type. You must preallocate this array where the expected
1559 % length varies depending on the values of width, height, map, and type.
1561 % o exception: return any errors or warnings in this structure.
1564 MagickExport unsigned int DispatchImage(const Image *image,const long x_offset,
1565 const long y_offset,const unsigned long columns,const unsigned long rows,
1566 const char *map,const StorageType type,void *pixels,ExceptionInfo *exception)
1571 if (image->debug != MagickFalse)
1572 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
1573 status=ExportImagePixels(image,x_offset,y_offset,columns,rows,map,type,pixels,
1579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1583 % E x t r a c t S u b i m a g e F r o m I m a g e %
1587 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1589 % ExtractSubimageFromImageImage() extracts a region of the image that most
1590 % closely resembles the reference.
1592 % The format of the ExtractSubimageFromImageImage method is:
1594 % Image *ExtractSubimageFromImage(const Image *image,const Image *reference,
1595 % ExceptionInfo *exception)
1597 % A description of each parameter follows:
1599 % o image: the image.
1601 % o reference: find an area of the image that closely resembles this image.
1603 % o exception: return any errors or warnings in this structure.
1607 static double GetSimilarityMetric(const Image *image,const Image *reference,
1608 const long x_offset,const long y_offset,const double similarity_threshold,
1609 ExceptionInfo *exception)
1616 normalized_similarity,
1624 Compute the similarity in pixels between two images.
1626 normalized_similarity=1.0;
1629 if ((image->matte != MagickFalse) && (reference->matte != MagickFalse))
1631 if ((image->colorspace == CMYKColorspace) &&
1632 (reference->colorspace == CMYKColorspace))
1634 image_view=AcquireCacheView(image);
1635 reference_view=AcquireCacheView(reference);
1636 for (y=0; y < (long) reference->rows; y++)
1638 register const IndexPacket
1642 register const PixelPacket
1649 p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset+y,
1650 reference->columns,1,exception);
1651 q=GetCacheViewVirtualPixels(reference_view,0,y,reference->columns,1,
1653 if ((p == (const PixelPacket *) NULL) || (q == (const PixelPacket *) NULL))
1655 indexes=GetCacheViewVirtualIndexQueue(image_view);
1656 reference_indexes=GetCacheViewVirtualIndexQueue(reference_view);
1657 for (x=0; x < (long) reference->columns; x++)
1662 pixel=QuantumScale*(p->red-(double) q->red);
1663 similarity+=pixel*pixel;
1664 pixel=QuantumScale*(p->green-(double) q->green);
1665 similarity+=pixel*pixel;
1666 pixel=QuantumScale*(p->blue-(double) q->blue);
1667 similarity+=pixel*pixel;
1668 if ((image->matte != MagickFalse) && (reference->matte != MagickFalse))
1670 pixel=QuantumScale*(p->opacity-(double) q->opacity);
1671 similarity+=pixel*pixel;
1673 if ((image->colorspace == CMYKColorspace) &&
1674 (reference->colorspace == CMYKColorspace))
1676 pixel=QuantumScale*(indexes[x]-(double) reference_indexes[x]);
1677 similarity+=pixel*pixel;
1682 normalized_similarity=sqrt(similarity)/reference->columns/reference->rows/
1684 if (normalized_similarity > similarity_threshold)
1687 reference_view=DestroyCacheView(reference_view);
1688 image_view=DestroyCacheView(image_view);
1689 return(normalized_similarity);
1692 MagickExport Image *ExtractSubimageFromImage(Image *image,
1693 const Image *reference,ExceptionInfo *exception)
1699 similarity_threshold;
1705 Extract reference from image.
1707 if ((reference->columns > image->columns) || (reference->rows > image->rows))
1708 return((Image *) NULL);
1709 similarity_threshold=image->columns*image->rows;
1710 SetGeometry(reference,&offset);
1711 #if defined(MAGICKCORE_OPENMP_SUPPORT) && (_OPENMP >= 200203)
1712 #pragma omp parallel for
1714 for (y=0; y < (long) (image->rows-reference->rows); y++)
1722 for (x=0; x < (long) (image->columns-reference->columns); x++)
1724 similarity=GetSimilarityMetric(image,reference,x,y,similarity_threshold,
1726 #if defined(MAGICKCORE_OPENMP_SUPPORT) && (_OPENMP >= 200203)
1727 #pragma omp critical (MagickCore_ExtractSubimageFromImage)
1729 if (similarity < similarity_threshold)
1731 similarity_threshold=similarity;
1737 if (similarity_threshold > (QuantumScale*reference->fuzz/100.0))
1738 return((Image *) NULL);
1739 return(CropImage(image,&offset,exception));
1743 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1747 % F l a t t e n I m a g e %
1751 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1753 % FlattenImages() Obsolete Function: Use MergeImageLayers() instead.
1755 % The format of the FlattenImage method is:
1757 % Image *FlattenImage(Image *image,ExceptionInfo *exception)
1759 % A description of each parameter follows:
1761 % o image: the image sequence.
1763 % o exception: return any errors or warnings in this structure.
1766 MagickExport Image *FlattenImages(Image *image,ExceptionInfo *exception)
1768 return(MergeImageLayers(image,FlattenLayer,exception));
1772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1776 % F o r m a t I m a g e A t t r i b u t e %
1780 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1782 % FormatImageAttribute() permits formatted key/value pairs to be saved as an
1785 % The format of the FormatImageAttribute method is:
1787 % MagickBooleanType FormatImageAttribute(Image *image,const char *key,
1788 % const char *format,...)
1790 % A description of each parameter follows.
1792 % o image: The image.
1794 % o key: The attribute key.
1796 % o format: A string describing the format to use to write the remaining
1801 MagickExport MagickBooleanType FormatImageAttributeList(Image *image,
1802 const char *key,const char *format,va_list operands)
1805 value[MaxTextExtent];
1810 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
1811 n=vsnprintf(value,MaxTextExtent,format,operands);
1813 n=vsprintf(value,format,operands);
1816 value[MaxTextExtent-1]='\0';
1817 return(SetImageProperty(image,key,value));
1820 MagickExport MagickBooleanType FormatImageAttribute(Image *image,
1821 const char *key,const char *format,...)
1829 va_start(operands,format);
1830 status=FormatImagePropertyList(image,key,format,operands);
1836 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1840 % F o r m a t S t r i n g %
1844 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1846 % FormatString() prints formatted output of a variable argument list.
1848 % The format of the FormatString method is:
1850 % void FormatString(char *string,const char *format,...)
1852 % A description of each parameter follows.
1854 % o string: Method FormatString returns the formatted string in this
1857 % o format: A string describing the format to use to write the remaining
1862 MagickExport void FormatStringList(char *string,const char *format,
1868 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
1869 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
1870 n=vsnprintf(string,MaxTextExtent,format,operands);
1872 n=vsprintf(string,format,operands);
1875 string[MaxTextExtent-1]='\0';
1878 MagickExport void FormatString(char *string,const char *format,...)
1883 va_start(operands,format);
1884 FormatMagickStringList(string,MaxTextExtent,format,operands);
1890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1894 + F u z z y C o l o r M a t c h %
1898 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1900 % FuzzyColorMatch() returns true if two pixels are identical in color.
1902 % The format of the ColorMatch method is:
1904 % void FuzzyColorMatch(const PixelPacket *p,const PixelPacket *q,
1905 % const double fuzz)
1907 % A description of each parameter follows:
1913 % o distance: Define how much tolerance is acceptable to consider
1914 % two colors as the same.
1917 MagickExport unsigned int FuzzyColorMatch(const PixelPacket *p,
1918 const PixelPacket *q,const double fuzz)
1923 register MagickRealType
1926 if ((fuzz == 0.0) && (p->red == q->red) && (p->green == q->green) &&
1927 (p->blue == q->blue))
1929 pixel.red=p->red-(MagickRealType) q->red;
1930 distance=pixel.red*pixel.red;
1931 if (distance > (fuzz*fuzz))
1932 return(MagickFalse);
1933 pixel.green=p->green-(MagickRealType) q->green;
1934 distance+=pixel.green*pixel.green;
1935 if (distance > (fuzz*fuzz))
1936 return(MagickFalse);
1937 pixel.blue=p->blue-(MagickRealType) q->blue;
1938 distance+=pixel.blue*pixel.blue;
1939 if (distance > (fuzz*fuzz))
1940 return(MagickFalse);
1945 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1949 + F u z z y C o l o r C o m p a r e %
1953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1955 % FuzzyColorCompare() returns MagickTrue if the distance between two colors is
1956 % less than the specified distance in a linear three dimensional color space.
1957 % This method is used by ColorFloodFill() and other algorithms which
1958 % compare two colors.
1960 % The format of the FuzzyColorCompare method is:
1962 % void FuzzyColorCompare(const Image *image,const PixelPacket *p,
1963 % const PixelPacket *q)
1965 % A description of each parameter follows:
1967 % o image: the image.
1974 MagickExport MagickBooleanType FuzzyColorCompare(const Image *image,
1975 const PixelPacket *p,const PixelPacket *q)
1977 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.5");
1978 return(IsColorSimilar(image,p,q));
1982 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1986 + F u z z y O p a c i t y C o m p a r e %
1990 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1992 % FuzzyOpacityCompare() returns true if the distance between two opacity
1993 % values is less than the specified distance in a linear color space. This
1994 % method is used by MatteFloodFill() and other algorithms which compare
1995 % two opacity values.
1997 % The format of the FuzzyOpacityCompare method is:
1999 % void FuzzyOpacityCompare(const Image *image,const PixelPacket *p,
2000 % const PixelPacket *q)
2002 % A description of each parameter follows:
2004 % o image: the image.
2011 MagickExport MagickBooleanType FuzzyOpacityCompare(const Image *image,
2012 const PixelPacket *p,const PixelPacket *q)
2014 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.5");
2015 return(IsOpacitySimilar(image,p,q));
2019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2023 % G e t C o n f i g u r e B l o b %
2027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2029 % GetConfigureBlob() returns the specified configure file as a blob.
2031 % The format of the GetConfigureBlob method is:
2033 % void *GetConfigureBlob(const char *filename,ExceptionInfo *exception)
2035 % A description of each parameter follows:
2037 % o filename: the configure file name.
2039 % o path: return the full path information of the configure file.
2041 % o length: This pointer to a size_t integer sets the initial length of the
2042 % blob. On return, it reflects the actual length of the blob.
2044 % o exception: return any errors or warnings in this structure.
2047 MagickExport void *GetConfigureBlob(const char *filename,char *path,
2048 size_t *length,ExceptionInfo *exception)
2053 assert(filename != (const char *) NULL);
2054 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
2055 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
2056 assert(path != (char *) NULL);
2057 assert(length != (size_t *) NULL);
2058 assert(exception != (ExceptionInfo *) NULL);
2060 (void) CopyMagickString(path,filename,MaxTextExtent);
2061 #if defined(MAGICKCORE_INSTALLED_SUPPORT)
2062 #if defined(MAGICKCORE_LIBRARY_PATH)
2063 if (blob == (void *) NULL)
2066 Search hard coded paths.
2068 (void) FormatMagickString(path,MaxTextExtent,"%s%s",
2069 MAGICKCORE_LIBRARY_PATH,filename);
2070 if (IsPathAccessible(path) != MagickFalse)
2071 blob=FileToBlob(path,~0,length,exception);
2074 #if defined(__WINDOWS__) && !(defined(MAGICKCORE_CONFIGURE_PATH) || defined(MAGICKCORE_SHARE_CONFIGURE_PATH))
2075 if (blob == (void *) NULL)
2081 Locate file via registry key.
2083 key_value=NTRegistryKeyLookup("ConfigurePath");
2084 if (key_value != (char *) NULL)
2086 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",key_value,
2087 DirectorySeparator,filename);
2088 if (IsPathAccessible(path) != MagickFalse)
2089 blob=FileToBlob(path,~0,length,exception);
2094 if (blob == (void *) NULL)
2099 home=GetEnvironmentValue("MAGICK_HOME");
2100 if (home != (char *) NULL)
2105 #if !defined(MAGICKCORE_POSIX_SUPPORT)
2106 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",home,
2107 DirectorySeparator,filename);
2109 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/%s",home,
2110 MAGICKCORE_LIBRARY_RELATIVE_PATH,filename);
2112 if (IsPathAccessible(path) != MagickFalse)
2113 blob=FileToBlob(path,~0,length,exception);
2114 home=DestroyString(home);
2116 home=GetEnvironmentValue("HOME");
2117 if (home == (char *) NULL)
2118 home=GetEnvironmentValue("USERPROFILE");
2119 if (home != (char *) NULL)
2122 Search $HOME/.magick.
2124 (void) FormatMagickString(path,MaxTextExtent,"%s%s.magick%s%s",home,
2125 DirectorySeparator,DirectorySeparator,filename);
2126 if ((IsPathAccessible(path) != MagickFalse) && (blob == (void *) NULL))
2127 blob=FileToBlob(path,~0,length,exception);
2128 home=DestroyString(home);
2131 if ((blob == (void *) NULL) && (*GetClientPath() != '\0'))
2133 #if !defined(MAGICKCORE_POSIX_SUPPORT)
2134 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",GetClientPath(),
2135 DirectorySeparator,filename);
2138 prefix[MaxTextExtent];
2141 Search based on executable directory if directory is known.
2143 (void) CopyMagickString(prefix,GetClientPath(),
2145 ChopPathComponents(prefix,1);
2146 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/%s",prefix,
2147 MAGICKCORE_LIBRARY_RELATIVE_PATH,filename);
2149 if (IsPathAccessible(path) != MagickFalse)
2150 blob=FileToBlob(path,~0,length,exception);
2153 Search current directory.
2155 if ((blob == (void *) NULL) && (IsPathAccessible(path) != MagickFalse))
2156 blob=FileToBlob(path,~0,length,exception);
2157 #if defined(__WINDOWS__)
2159 Search Windows registry.
2161 if (blob == (void *) NULL)
2162 blob=NTResourceToBlob(filename);
2165 if (blob == (void *) NULL)
2166 (void) ThrowMagickException(exception,GetMagickModule(),ConfigureWarning,
2167 "UnableToOpenConfigureFile","`%s'",path);
2172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2176 % G e t C a c h e V i e w %
2180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2182 % GetCacheView() gets pixels from the in-memory or disk pixel cache as
2183 % defined by the geometry parameters. A pointer to the pixels is returned if
2184 % the pixels are transferred, otherwise a NULL is returned.
2186 % The format of the GetCacheView method is:
2188 % PixelPacket *GetCacheView(CacheView *cache_view,const long x,
2189 % const long y,const unsigned long columns,const unsigned long rows)
2191 % A description of each parameter follows:
2193 % o cache_view: the address of a structure of type CacheView.
2195 % o x,y,columns,rows: These values define the perimeter of a region of
2199 MagickExport PixelPacket *GetCacheView(CacheView *cache_view,const long x,
2200 const long y,const unsigned long columns,const unsigned long rows)
2205 pixels=GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2206 GetCacheViewException(cache_view));
2211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2215 % G e t C a c h e V i e w I n d e x e s %
2219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2221 % GetCacheViewIndexes() returns the indexes associated with the specified
2224 % The format of the GetCacheViewIndexes method is:
2226 % IndexPacket *GetCacheViewIndexes(CacheView *cache_view)
2228 % A description of each parameter follows:
2230 % o cache_view: the cache view.
2233 MagickExport IndexPacket *GetCacheViewIndexes(CacheView *cache_view)
2235 return(GetCacheViewAuthenticIndexQueue(cache_view));
2239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2243 % G e t C a c h e V i e w P i x e l s %
2247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2249 % GetCacheViewPixels() gets pixels from the in-memory or disk pixel cache as
2250 % defined by the geometry parameters. A pointer to the pixels is returned if
2251 % the pixels are transferred, otherwise a NULL is returned.
2253 % The format of the GetCacheViewPixels method is:
2255 % PixelPacket *GetCacheViewPixels(CacheView *cache_view,const long x,
2256 % const long y,const unsigned long columns,const unsigned long rows)
2258 % A description of each parameter follows:
2260 % o cache_view: the cache view.
2262 % o x,y,columns,rows: These values define the perimeter of a region of
2266 MagickExport PixelPacket *GetCacheViewPixels(CacheView *cache_view,const long x,
2267 const long y,const unsigned long columns,const unsigned long rows)
2272 pixels=GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2273 GetCacheViewException(cache_view));
2278 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2282 % G e t I m a g e A t t r i b u t e %
2286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2288 % GetImageAttribute() searches the list of image attributes and returns
2289 % a pointer to the attribute if it exists otherwise NULL.
2291 % The format of the GetImageAttribute method is:
2293 % const ImageAttribute *GetImageAttribute(const Image *image,
2296 % A description of each parameter follows:
2298 % o image: the image.
2300 % o key: These character strings are the name of an image attribute to
2305 static void *DestroyAttribute(void *attribute)
2307 register ImageAttribute
2310 p=(ImageAttribute *) attribute;
2311 if (p->value != (char *) NULL)
2312 p->value=DestroyString(p->value);
2313 return(RelinquishMagickMemory(p));
2316 MagickExport const ImageAttribute *GetImageAttribute(const Image *image,
2325 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
2326 value=GetImageProperty(image,key);
2327 if (value == (const char *) NULL)
2328 return((const ImageAttribute *) NULL);
2329 if (image->attributes == (void *) NULL)
2330 ((Image *) image)->attributes=NewSplayTree(CompareSplayTreeString,
2331 RelinquishMagickMemory,DestroyAttribute);
2334 const ImageAttribute
2337 attribute=(const ImageAttribute *) GetValueFromSplayTree((SplayTreeInfo *)
2338 image->attributes,key);
2339 if (attribute != (const ImageAttribute *) NULL)
2342 attribute=(ImageAttribute *) AcquireMagickMemory(sizeof(*attribute));
2343 if (attribute == (ImageAttribute *) NULL)
2344 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
2345 (void) ResetMagickMemory(attribute,0,sizeof(*attribute));
2346 attribute->key=ConstantString(key);
2347 attribute->value=ConstantString(value);
2348 (void) AddValueToSplayTree((SplayTreeInfo *) ((Image *) image)->attributes,
2349 attribute->key,attribute);
2350 return((const ImageAttribute *) attribute);
2354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2358 % 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 %
2362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2364 % GetImageClippingPathAttribute() searches the list of image attributes and
2365 % returns a pointer to a clipping path if it exists otherwise NULL.
2367 % The format of the GetImageClippingPathAttribute method is:
2369 % const ImageAttribute *GetImageClippingPathAttribute(Image *image)
2371 % A description of each parameter follows:
2373 % o attribute: Method GetImageClippingPathAttribute returns the clipping
2374 % path if it exists otherwise NULL.
2376 % o image: the image.
2379 MagickExport const ImageAttribute *GetImageClippingPathAttribute(Image *image)
2381 return(GetImageAttribute(image,"8BIM:1999,2998"));
2385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2389 % 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 %
2393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2395 % GetImageFromMagickRegistry() gets an image from the registry as defined by
2396 % its name. If the image is not found, a NULL image is returned.
2398 % The format of the GetImageFromMagickRegistry method is:
2400 % Image *GetImageFromMagickRegistry(const char *name,long *id,
2401 % ExceptionInfo *exception)
2403 % A description of each parameter follows:
2405 % o name: the name of the image to retrieve from the registry.
2407 % o id: the registry id.
2409 % o exception: return any errors or warnings in this structure.
2412 MagickExport Image *GetImageFromMagickRegistry(const char *name,long *id,
2413 ExceptionInfo *exception)
2416 return((Image *) GetImageRegistry(ImageRegistryType,name,exception));
2420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2424 % G e t M a g i c k R e g i s t r y %
2428 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2430 % GetMagickRegistry() gets a blob from the registry as defined by the id. If
2431 % the blob that matches the id is not found, NULL is returned.
2433 % The format of the GetMagickRegistry method is:
2435 % const void *GetMagickRegistry(const long id,RegistryType *type,
2436 % size_t *length,ExceptionInfo *exception)
2438 % A description of each parameter follows:
2440 % o id: the registry id.
2442 % o type: the registry type.
2444 % o length: the blob length in number of bytes.
2446 % o exception: return any errors or warnings in this structure.
2449 MagickExport void *GetMagickRegistry(const long id,RegistryType *type,
2450 size_t *length,ExceptionInfo *exception)
2458 *type=UndefinedRegistryType;
2460 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
2461 blob=(void *) GetImageRegistry(ImageRegistryType,key,exception);
2462 if (blob != (void *) NULL)
2464 blob=(void *) GetImageRegistry(ImageInfoRegistryType,key,exception);
2465 if (blob != (void *) NULL)
2467 return((void *) GetImageRegistry(UndefinedRegistryType,key,exception));
2471 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2475 % G e t I m a g e G e o m e t r y %
2479 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2481 % GetImageGeometry() returns a region as defined by the geometry string with
2482 % respect to the image and its gravity.
2484 % The format of the GetImageGeometry method is:
2486 % int GetImageGeometry(Image *image,const char *geometry,
2487 % const unsigned int size_to_fit,RectangeInfo *region_info)
2489 % A description of each parameter follows:
2491 % o flags: Method GetImageGeometry returns a bitmask that indicates
2492 % which of the four values were located in the geometry string.
2494 % o geometry: The geometry (e.g. 100x100+10+10).
2496 % o size_to_fit: A value other than 0 means to scale the region so it
2497 % fits within the specified width and height.
2499 % o region_info: the region as defined by the geometry string with
2500 % respect to the image and its gravity.
2503 MagickExport int GetImageGeometry(Image *image,const char *geometry,
2504 const unsigned int size_to_fit,RectangleInfo *region_info)
2506 if (image->debug != MagickFalse)
2507 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.4");
2508 if (size_to_fit != MagickFalse)
2509 return((int) ParseRegionGeometry(image,geometry,region_info,&image->exception));
2510 return((int) ParsePageGeometry(image,geometry,region_info,&image->exception));
2514 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2518 % G e t I m a g e L i s t %
2522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2524 % GetImageList() returns an image at the specified position in the list.
2526 % The format of the GetImageList method is:
2528 % Image *GetImageList(const Image *images,const long offset,
2529 % ExceptionInfo *exception)
2531 % A description of each parameter follows:
2533 % o images: the image list.
2535 % o offset: the position within the list.
2537 % o exception: return any errors or warnings in this structure.
2540 MagickExport Image *GetImageList(const Image *images,const long offset,
2541 ExceptionInfo *exception)
2546 if (images->debug != MagickFalse)
2547 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2548 image=CloneImage(GetImageFromList(images,(long) offset),0,0,MagickTrue,
2554 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2558 % G e t I m a g e L i s t I n d e x %
2562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2564 % GetImageListIndex() returns the position in the list of the specified
2567 % The format of the GetImageListIndex method is:
2569 % long GetImageListIndex(const Image *images)
2571 % A description of each parameter follows:
2573 % o images: the image list.
2576 MagickExport long GetImageListIndex(const Image *images)
2578 if (images->debug != MagickFalse)
2579 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2580 return(GetImageIndexInList(images));
2584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2588 % G e t I m a g e L i s t S i z e %
2592 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2594 % GetImageListSize() returns the number of images in the list.
2596 % The format of the GetImageListSize method is:
2598 % unsigned long GetImageListSize(const Image *images)
2600 % A description of each parameter follows:
2602 % o images: the image list.
2605 MagickExport unsigned long GetImageListSize(const Image *images)
2607 if (images->debug != MagickFalse)
2608 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2609 return(GetImageListLength(images));
2613 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2617 % G e t I m a g e P i x e l s %
2621 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2623 % GetImagePixels() obtains a pixel region for read/write access. If the
2624 % region is successfully accessed, a pointer to a PixelPacket array
2625 % representing the region is returned, otherwise NULL is returned.
2627 % The returned pointer may point to a temporary working copy of the pixels
2628 % or it may point to the original pixels in memory. Performance is maximized
2629 % if the selected region is part of one row, or one or more full rows, since
2630 % then there is opportunity to access the pixels in-place (without a copy)
2631 % if the image is in RAM, or in a memory-mapped file. The returned pointer
2632 % should *never* be deallocated by the user.
2634 % Pixels accessed via the returned pointer represent a simple array of type
2635 % PixelPacket. If the image type is CMYK or if the storage class is
2636 % PseduoClass, call GetAuthenticIndexQueue() after invoking GetImagePixels()
2637 % to obtain the black color component or colormap indexes (of type IndexPacket)
2638 % corresponding to the region. Once the PixelPacket (and/or IndexPacket)
2639 % array has been updated, the changes must be saved back to the underlying
2640 % image using SyncAuthenticPixels() or they may be lost.
2642 % The format of the GetImagePixels() method is:
2644 % PixelPacket *GetImagePixels(Image *image,const long x,const long y,
2645 % const unsigned long columns,const unsigned long rows)
2647 % A description of each parameter follows:
2649 % o image: the image.
2651 % o x,y,columns,rows: These values define the perimeter of a region of
2655 MagickExport PixelPacket *GetImagePixels(Image *image,const long x,const long y,
2656 const unsigned long columns,const unsigned long rows)
2658 return(GetAuthenticPixels(image,x,y,columns,rows,&image->exception));
2662 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2666 % G e t I n d e x e s %
2670 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2672 % GetIndexes() returns the black channel or the colormap indexes associated
2673 % with the last call to QueueAuthenticPixels() or GetVirtualPixels(). NULL is
2674 % returned if the black channel or colormap indexes are not available.
2676 % The format of the GetIndexes() method is:
2678 % IndexPacket *GetIndexes(const Image *image)
2680 % A description of each parameter follows:
2682 % o indexes: GetIndexes() returns the indexes associated with the last
2683 % call to QueueAuthenticPixels() or GetAuthenticPixels().
2685 % o image: the image.
2688 MagickExport IndexPacket *GetIndexes(const Image *image)
2690 return(GetAuthenticIndexQueue(image));
2694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2698 + G e t M a g i c k G e o m e t r y %
2702 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2704 % GetMagickGeometry() is similar to GetGeometry() except the returned
2705 % geometry is modified as determined by the meta characters: %, !, <, >,
2708 % The format of the GetMagickGeometry method is:
2710 % unsigned int GetMagickGeometry(const char *geometry,long *x,long *y,
2711 % unsigned long *width,unsigned long *height)
2713 % A description of each parameter follows:
2715 % o geometry: Specifies a character string representing the geometry
2718 % o x,y: A pointer to an integer. The x and y offset as determined by
2719 % the geometry specification is returned here.
2721 % o width,height: A pointer to an unsigned integer. The width and height
2722 % as determined by the geometry specification is returned here.
2725 MagickExport unsigned int GetMagickGeometry(const char *geometry,long *x,
2726 long *y,unsigned long *width,unsigned long *height)
2728 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.3");
2729 return(ParseMetaGeometry(geometry,x,y,width,height));
2733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2737 % G e t N e x t I m a g e %
2741 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2743 % GetNextImage() returns the next image in a list.
2745 % The format of the GetNextImage method is:
2747 % Image *GetNextImage(const Image *images)
2749 % A description of each parameter follows:
2751 % o images: the image list.
2754 MagickExport Image *GetNextImage(const Image *images)
2756 if (images->debug != MagickFalse)
2757 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2758 return(GetNextImageInList(images));
2762 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2766 % G e t N e x t I m a g e A t t r i b u t e %
2770 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2772 % GetNextImageAttribute() gets the next image attribute.
2774 % The format of the GetNextImageAttribute method is:
2776 % const ImageAttribute *GetNextImageAttribute(const Image *image)
2778 % A description of each parameter follows:
2780 % o image: the image.
2783 MagickExport const ImageAttribute *GetNextImageAttribute(const Image *image)
2788 property=GetNextImageProperty(image);
2789 if (property == (const char *) NULL)
2790 return((const ImageAttribute *) NULL);
2791 return(GetImageAttribute(image,property));
2795 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2799 % G e t N u m b e r S c e n e s %
2803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2805 % GetNumberScenes() returns the number of images in the list.
2807 % The format of the GetNumberScenes method is:
2809 % unsigned int GetNumberScenes(const Image *images)
2811 % A description of each parameter follows:
2813 % o images: the image list.
2816 MagickExport unsigned int GetNumberScenes(const Image *image)
2818 if (image->debug != MagickFalse)
2819 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2820 return((unsigned int) GetImageListLength(image));
2824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2828 % G e t O n e P i x e l %
2832 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2834 % GetOnePixel() returns a single pixel at the specified (x,y) location.
2835 % The image background color is returned if an error occurs.
2837 % The format of the GetOnePixel() method is:
2839 % PixelPacket GetOnePixel(const Image image,const long x,const long y)
2841 % A description of each parameter follows:
2843 % o image: the image.
2845 % o x,y: These values define the location of the pixel to return.
2848 MagickExport PixelPacket GetOnePixel(Image *image,const long x,const long y)
2853 (void) GetOneAuthenticPixel(image,x,y,&pixel,&image->exception);
2858 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2862 % G e t P i x e l s %
2866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2868 % GetPixels() returns the pixels associated with the last call to
2869 % QueueAuthenticPixels() or GetAuthenticPixels().
2871 % The format of the GetPixels() method is:
2873 % PixelPacket *GetPixels(const Image image)
2875 % A description of each parameter follows:
2877 % o pixels: GetPixels() returns the pixels associated with the last call
2878 % to QueueAuthenticPixels() or GetAuthenticPixels().
2880 % o image: the image.
2883 MagickExport PixelPacket *GetPixels(const Image *image)
2885 return(GetAuthenticPixelQueue(image));
2889 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2893 % G e t P r e v i o u s I m a g e %
2897 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2899 % GetPreviousImage() returns the previous image in a list.
2901 % The format of the GetPreviousImage method is:
2903 % Image *GetPreviousImage(const Image *images)
2905 % A description of each parameter follows:
2907 % o images: the image list.
2910 MagickExport Image *GetPreviousImage(const Image *images)
2912 if (images->debug != MagickFalse)
2913 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2914 return(GetPreviousImageInList(images));
2918 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2922 % H S L T r a n s f o r m %
2926 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2928 % HSLTransform() converts a (hue, saturation, lightness) to a (red, green,
2931 % The format of the HSLTransformImage method is:
2933 % void HSLTransform(const double hue,const double saturation,
2934 % const double lightness,Quantum *red,Quantum *green,Quantum *blue)
2936 % A description of each parameter follows:
2938 % o hue, saturation, lightness: A double value representing a
2939 % component of the HSL color space.
2941 % o red, green, blue: A pointer to a pixel component of type Quantum.
2945 static inline MagickRealType HueToRGB(MagickRealType m1,MagickRealType m2,
2952 if ((6.0*hue) < 1.0)
2953 return(m1+6.0*(m2-m1)*hue);
2954 if ((2.0*hue) < 1.0)
2956 if ((3.0*hue) < 2.0)
2957 return(m1+6.0*(m2-m1)*(2.0/3.0-hue));
2961 MagickExport void HSLTransform(const double hue,const double saturation,
2962 const double lightness,Quantum *red,Quantum *green,Quantum *blue)
2972 Convert HSL to RGB colorspace.
2974 assert(red != (Quantum *) NULL);
2975 assert(green != (Quantum *) NULL);
2976 assert(blue != (Quantum *) NULL);
2977 if (lightness <= 0.5)
2978 m2=lightness*(saturation+1.0);
2980 m2=lightness+saturation-lightness*saturation;
2981 m1=2.0*lightness-m2;
2982 r=HueToRGB(m1,m2,hue+1.0/3.0);
2983 g=HueToRGB(m1,m2,hue);
2984 b=HueToRGB(m1,m2,hue-1.0/3.0);
2985 *red=RoundToQuantum((MagickRealType) QuantumRange*r);
2986 *green=RoundToQuantum((MagickRealType) QuantumRange*g);
2987 *blue=RoundToQuantum((MagickRealType) QuantumRange*b);
2991 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2995 % I d e n t i t y A f f i n e %
2999 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3001 % IdentityAffine() initializes the affine transform to the identity matrix.
3003 % The format of the IdentityAffine method is:
3005 % IdentityAffine(AffineMatrix *affine)
3007 % A description of each parameter follows:
3009 % o affine: A pointer the affine transform of type AffineMatrix.
3012 MagickExport void IdentityAffine(AffineMatrix *affine)
3014 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3015 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3016 assert(affine != (AffineMatrix *) NULL);
3017 (void) ResetMagickMemory(affine,0,sizeof(AffineMatrix));
3023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3027 % I n i t i a l i z e M a g i c k %
3031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3033 % InitializeMagick() initializes the ImageMagick environment.
3035 % The format of the InitializeMagick function is:
3037 % InitializeMagick(const char *path)
3039 % A description of each parameter follows:
3041 % o path: the execution path of the current ImageMagick client.
3044 MagickExport void InitializeMagick(const char *path)
3046 MagickCoreGenesis(path,MagickFalse);
3050 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3054 % I n t e r p o l a t e P i x e l C o l o r %
3058 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3060 % InterpolatePixelColor() applies bi-linear or tri-linear interpolation
3061 % between a pixel and it's neighbors.
3063 % The format of the InterpolatePixelColor method is:
3065 % MagickPixelPacket InterpolatePixelColor(const Image *image,
3066 % CacheView *view_info,InterpolatePixelMethod method,const double x,
3067 % const double y,ExceptionInfo *exception)
3069 % A description of each parameter follows:
3071 % o image: the image.
3073 % o image_view: the image cache view.
3075 % o type: the type of pixel color interpolation.
3077 % o x,y: A double representing the current (x,y) position of the pixel.
3079 % o exception: return any errors or warnings in this structure.
3083 static inline double MagickMax(const double x,const double y)
3090 static void BicubicInterpolate(const MagickPixelPacket *pixels,const double dx,
3091 MagickPixelPacket *pixel)
3101 p=(pixels[3].red-pixels[2].red)-(pixels[0].red-pixels[1].red);
3102 q=(pixels[0].red-pixels[1].red)-p;
3103 r=pixels[2].red-pixels[0].red;
3105 pixel->red=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3106 p=(pixels[3].green-pixels[2].green)-(pixels[0].green-pixels[1].green);
3107 q=(pixels[0].green-pixels[1].green)-p;
3108 r=pixels[2].green-pixels[0].green;
3110 pixel->green=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3111 p=(pixels[3].blue-pixels[2].blue)-(pixels[0].blue-pixels[1].blue);
3112 q=(pixels[0].blue-pixels[1].blue)-p;
3113 r=pixels[2].blue-pixels[0].blue;
3115 pixel->blue=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3116 p=(pixels[3].opacity-pixels[2].opacity)-(pixels[0].opacity-pixels[1].opacity);
3117 q=(pixels[0].opacity-pixels[1].opacity)-p;
3118 r=pixels[2].opacity-pixels[0].opacity;
3119 s=pixels[1].opacity;
3120 pixel->opacity=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3121 if (pixel->colorspace == CMYKColorspace)
3123 p=(pixels[3].index-pixels[2].index)-(pixels[0].index-pixels[1].index);
3124 q=(pixels[0].index-pixels[1].index)-p;
3125 r=pixels[2].index-pixels[0].index;
3127 pixel->index=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3131 static inline MagickRealType CubicWeightingFunction(const MagickRealType x)
3137 alpha=MagickMax(x+2.0,0.0);
3138 gamma=1.0*alpha*alpha*alpha;
3139 alpha=MagickMax(x+1.0,0.0);
3140 gamma-=4.0*alpha*alpha*alpha;
3141 alpha=MagickMax(x+0.0,0.0);
3142 gamma+=6.0*alpha*alpha*alpha;
3143 alpha=MagickMax(x-1.0,0.0);
3144 gamma-=4.0*alpha*alpha*alpha;
3148 static inline double MeshInterpolate(const PointInfo *delta,const double p,
3149 const double x,const double y)
3151 return(delta->x*x+delta->y*y+(1.0-delta->x-delta->y)*p);
3154 static inline long NearestNeighbor(MagickRealType x)
3157 return((long) (x+0.5));
3158 return((long) (x-0.5));
3161 MagickExport MagickPixelPacket InterpolatePixelColor(const Image *image,
3162 CacheView *image_view,const InterpolatePixelMethod method,const double x,
3163 const double y,ExceptionInfo *exception)
3168 register const IndexPacket
3171 register const PixelPacket
3177 assert(image != (Image *) NULL);
3178 assert(image->signature == MagickSignature);
3179 assert(image_view != (CacheView *) NULL);
3180 GetMagickPixelPacket(image,&pixel);
3183 case AverageInterpolatePixel:
3192 p=GetCacheViewVirtualPixels(image_view,(long) floor(x)-1,(long) floor(y)-
3194 if (p == (const PixelPacket *) NULL)
3196 indexes=GetCacheViewVirtualIndexQueue(image_view);
3197 for (i=0; i < 16L; i++)
3199 GetMagickPixelPacket(image,pixels+i);
3200 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3202 if (image->matte != MagickFalse)
3204 alpha[i]=QuantumScale*((MagickRealType) QuantumRange-p->opacity);
3205 pixels[i].red*=alpha[i];
3206 pixels[i].green*=alpha[i];
3207 pixels[i].blue*=alpha[i];
3208 if (image->colorspace == CMYKColorspace)
3209 pixels[i].index*=alpha[i];
3212 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3213 pixel.red+=gamma*0.0625*pixels[i].red;
3214 pixel.green+=gamma*0.0625*pixels[i].green;
3215 pixel.blue+=gamma*0.0625*pixels[i].blue;
3216 pixel.opacity+=0.0625*pixels[i].opacity;
3217 if (image->colorspace == CMYKColorspace)
3218 pixel.index+=gamma*0.0625*pixels[i].index;
3223 case BicubicInterpolatePixel:
3235 p=GetCacheViewVirtualPixels(image_view,(long) floor(x)-1,(long) floor(y)-
3237 if (p == (const PixelPacket *) NULL)
3239 indexes=GetCacheViewVirtualIndexQueue(image_view);
3240 for (i=0; i < 16L; i++)
3242 GetMagickPixelPacket(image,pixels+i);
3243 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3245 if (image->matte != MagickFalse)
3247 alpha[i]=QuantumScale*((MagickRealType) QuantumRange-p->opacity);
3248 pixels[i].red*=alpha[i];
3249 pixels[i].green*=alpha[i];
3250 pixels[i].blue*=alpha[i];
3251 if (image->colorspace == CMYKColorspace)
3252 pixels[i].index*=alpha[i];
3257 for (i=0; i < 4L; i++)
3258 BicubicInterpolate(pixels+4*i,delta.x,u+i);
3260 BicubicInterpolate(u,delta.y,&pixel);
3263 case BilinearInterpolatePixel:
3276 p=GetCacheViewVirtualPixels(image_view,(long) floor(x),(long) floor(y),2,
3278 if (p == (const PixelPacket *) NULL)
3280 indexes=GetCacheViewVirtualIndexQueue(image_view);
3281 for (i=0; i < 4L; i++)
3283 GetMagickPixelPacket(image,pixels+i);
3284 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3286 if (image->matte != MagickFalse)
3288 alpha[i]=QuantumScale*((MagickRealType) QuantumRange-p->opacity);
3289 pixels[i].red*=alpha[i];
3290 pixels[i].green*=alpha[i];
3291 pixels[i].blue*=alpha[i];
3292 if (image->colorspace == CMYKColorspace)
3293 pixels[i].index*=alpha[i];
3299 gamma=(((1.0-delta.y)*((1.0-delta.x)*alpha[0]+delta.x*alpha[1])+delta.y*
3300 ((1.0-delta.x)*alpha[2]+delta.x*alpha[3])));
3301 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3302 pixel.red=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].red+delta.x*
3303 pixels[1].red)+delta.y*((1.0-delta.x)*pixels[2].red+delta.x*
3305 pixel.green=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].green+delta.x*
3306 pixels[1].green)+delta.y*((1.0-delta.x)*pixels[2].green+
3307 delta.x*pixels[3].green));
3308 pixel.blue=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].blue+delta.x*
3309 pixels[1].blue)+delta.y*((1.0-delta.x)*pixels[2].blue+delta.x*
3311 pixel.opacity=((1.0-delta.y)*((1.0-delta.x)*pixels[0].opacity+delta.x*
3312 pixels[1].opacity)+delta.y*((1.0-delta.x)*pixels[2].opacity+delta.x*
3313 pixels[3].opacity));
3314 if (image->colorspace == CMYKColorspace)
3315 pixel.index=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].index+delta.x*
3316 pixels[1].index)+delta.y*((1.0-delta.x)*pixels[2].index+delta.x*
3320 case FilterInterpolatePixel:
3334 geometry.x=(long) floor(x)-1L;
3335 geometry.y=(long) floor(y)-1L;
3336 excerpt_image=ExcerptImage(image,&geometry,exception);
3337 if (excerpt_image == (Image *) NULL)
3339 filter_image=ResizeImage(excerpt_image,1,1,image->filter,image->blur,
3341 excerpt_image=DestroyImage(excerpt_image);
3342 if (filter_image == (Image *) NULL)
3344 p=GetVirtualPixels(filter_image,0,0,1,1,exception);
3345 if (p == (const PixelPacket *) NULL)
3347 filter_image=DestroyImage(filter_image);
3350 indexes=GetVirtualIndexQueue(filter_image);
3351 GetMagickPixelPacket(image,pixels);
3352 SetMagickPixelPacket(image,p,indexes,&pixel);
3353 filter_image=DestroyImage(filter_image);
3356 case IntegerInterpolatePixel:
3361 p=GetCacheViewVirtualPixels(image_view,(long) floor(x),(long) floor(y),1,
3363 if (p == (const PixelPacket *) NULL)
3365 indexes=GetCacheViewVirtualIndexQueue(image_view);
3366 GetMagickPixelPacket(image,pixels);
3367 SetMagickPixelPacket(image,p,indexes,&pixel);
3370 case MeshInterpolatePixel:
3383 p=GetCacheViewVirtualPixels(image_view,(long) floor(x),(long) floor(y),
3385 if (p == (const PixelPacket *) NULL)
3387 indexes=GetCacheViewVirtualIndexQueue(image_view);
3388 for (i=0; i < 4L; i++)
3390 GetMagickPixelPacket(image,pixels+i);
3391 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3393 if (image->matte != MagickFalse)
3395 alpha[i]=QuantumScale*((MagickRealType) QuantumRange-p->opacity);
3396 pixels[i].red*=alpha[i];
3397 pixels[i].green*=alpha[i];
3398 pixels[i].blue*=alpha[i];
3399 if (image->colorspace == CMYKColorspace)
3400 pixels[i].index*=alpha[i];
3406 luminance.x=MagickPixelLuminance(pixels+0)-MagickPixelLuminance(pixels+3);
3407 luminance.y=MagickPixelLuminance(pixels+1)-MagickPixelLuminance(pixels+2);
3408 if (fabs(luminance.x) < fabs(luminance.y))
3413 if (delta.x <= delta.y)
3416 Bottom-left triangle (pixel:2, diagonal: 0-3).
3418 delta.y=1.0-delta.y;
3419 gamma=MeshInterpolate(&delta,alpha[2],alpha[3],alpha[0]);
3420 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3421 pixel.red=gamma*MeshInterpolate(&delta,pixels[2].red,
3422 pixels[3].red,pixels[0].red);
3423 pixel.green=gamma*MeshInterpolate(&delta,pixels[2].green,
3424 pixels[3].green,pixels[0].green);
3425 pixel.blue=gamma*MeshInterpolate(&delta,pixels[2].blue,
3426 pixels[3].blue,pixels[0].blue);
3427 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[2].opacity,
3428 pixels[3].opacity,pixels[0].opacity);
3429 if (image->colorspace == CMYKColorspace)
3430 pixel.index=gamma*MeshInterpolate(&delta,pixels[2].index,
3431 pixels[3].index,pixels[0].index);
3436 Top-right triangle (pixel:1, diagonal: 0-3).
3438 delta.x=1.0-delta.x;
3439 gamma=MeshInterpolate(&delta,alpha[1],alpha[0],alpha[3]);
3440 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3441 pixel.red=gamma*MeshInterpolate(&delta,pixels[1].red,
3442 pixels[0].red,pixels[3].red);
3443 pixel.green=gamma*MeshInterpolate(&delta,pixels[1].green,
3444 pixels[0].green,pixels[3].green);
3445 pixel.blue=gamma*MeshInterpolate(&delta,pixels[1].blue,
3446 pixels[0].blue,pixels[3].blue);
3447 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[1].opacity,
3448 pixels[0].opacity,pixels[3].opacity);
3449 if (image->colorspace == CMYKColorspace)
3450 pixel.index=gamma*MeshInterpolate(&delta,pixels[1].index,
3451 pixels[0].index,pixels[3].index);
3459 if (delta.x <= (1.0-delta.y))
3462 Top-left triangle (pixel 0, diagonal: 1-2).
3464 gamma=MeshInterpolate(&delta,alpha[0],alpha[1],alpha[2]);
3465 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3466 pixel.red=gamma*MeshInterpolate(&delta,pixels[0].red,
3467 pixels[1].red,pixels[2].red);
3468 pixel.green=gamma*MeshInterpolate(&delta,pixels[0].green,
3469 pixels[1].green,pixels[2].green);
3470 pixel.blue=gamma*MeshInterpolate(&delta,pixels[0].blue,
3471 pixels[1].blue,pixels[2].blue);
3472 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[0].opacity,
3473 pixels[1].opacity,pixels[2].opacity);
3474 if (image->colorspace == CMYKColorspace)
3475 pixel.index=gamma*MeshInterpolate(&delta,pixels[0].index,
3476 pixels[1].index,pixels[2].index);
3481 Bottom-right triangle (pixel: 3, diagonal: 1-2).
3483 delta.x=1.0-delta.x;
3484 delta.y=1.0-delta.y;
3485 gamma=MeshInterpolate(&delta,alpha[3],alpha[2],alpha[1]);
3486 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3487 pixel.red=gamma*MeshInterpolate(&delta,pixels[3].red,
3488 pixels[2].red,pixels[1].red);
3489 pixel.green=gamma*MeshInterpolate(&delta,pixels[3].green,
3490 pixels[2].green,pixels[1].green);
3491 pixel.blue=gamma*MeshInterpolate(&delta,pixels[3].blue,
3492 pixels[2].blue,pixels[1].blue);
3493 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[3].opacity,
3494 pixels[2].opacity,pixels[1].opacity);
3495 if (image->colorspace == CMYKColorspace)
3496 pixel.index=gamma*MeshInterpolate(&delta,pixels[3].index,
3497 pixels[2].index,pixels[1].index);
3502 case NearestNeighborInterpolatePixel:
3507 p=GetCacheViewVirtualPixels(image_view,NearestNeighbor(x),
3508 NearestNeighbor(y),1,1,exception);
3509 if (p == (const PixelPacket *) NULL)
3511 indexes=GetCacheViewVirtualIndexQueue(image_view);
3512 GetMagickPixelPacket(image,pixels);
3513 SetMagickPixelPacket(image,p,indexes,&pixel);
3516 case SplineInterpolatePixel:
3534 p=GetCacheViewVirtualPixels(image_view,(long) floor(x)-1,(long) floor(y)-
3536 if (p == (const PixelPacket *) NULL)
3538 indexes=GetCacheViewVirtualIndexQueue(image_view);
3542 for (i=(-1); i < 3L; i++)
3544 dy=CubicWeightingFunction((MagickRealType) i-delta.y);
3545 for (j=(-1); j < 3L; j++)
3547 GetMagickPixelPacket(image,pixels+n);
3548 SetMagickPixelPacket(image,p,indexes+n,pixels+n);
3550 if (image->matte != MagickFalse)
3552 alpha[n]=QuantumScale*((MagickRealType) QuantumRange-p->opacity);
3553 pixels[n].red*=alpha[n];
3554 pixels[n].green*=alpha[n];
3555 pixels[n].blue*=alpha[n];
3556 if (image->colorspace == CMYKColorspace)
3557 pixels[n].index*=alpha[n];
3559 dx=CubicWeightingFunction(delta.x-(MagickRealType) j);
3561 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3562 pixel.red+=gamma*dx*dy*pixels[n].red;
3563 pixel.green+=gamma*dx*dy*pixels[n].green;
3564 pixel.blue+=gamma*dx*dy*pixels[n].blue;
3565 if (image->matte != MagickFalse)
3566 pixel.opacity+=dx*dy*pixels[n].opacity;
3567 if (image->colorspace == CMYKColorspace)
3568 pixel.index+=gamma*dx*dy*pixels[n].index;
3580 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3584 % I n t e r p r e t I m a g e A t t r i b u t e s %
3588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3590 % InterpretImageAttributes() replaces any embedded formatting characters with
3591 % the appropriate image attribute and returns the translated text.
3593 % The format of the InterpretImageAttributes method is:
3595 % char *InterpretImageAttributes(const ImageInfo *image_info,Image *image,
3596 % const char *embed_text)
3598 % A description of each parameter follows:
3600 % o image_info: the image info.
3602 % o image: the image.
3604 % o embed_text: the address of a character string containing the embedded
3605 % formatting characters.
3608 MagickExport char *InterpretImageAttributes(const ImageInfo *image_info,
3609 Image *image,const char *embed_text)
3611 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
3612 return(InterpretImageProperties(image_info,image,embed_text));
3616 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3620 + I s S u b i m a g e %
3624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3626 % IsSubimage() returns MagickTrue if the geometry is a valid subimage
3627 % specification (e.g. [1], [1-9], [1,7,4]).
3629 % The format of the IsSubimage method is:
3631 % unsigned int IsSubimage(const char *geometry,const unsigned int pedantic)
3633 % A description of each parameter follows:
3635 % o geometry: This string is the geometry specification.
3637 % o pedantic: A value other than 0 invokes a more restrictive set of
3638 % conditions for a valid specification (e.g. [1], [1-4], [4-1]).
3641 MagickExport unsigned int IsSubimage(const char *geometry,
3642 const unsigned int pedantic)
3644 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3645 if (geometry == (const char *) NULL)
3646 return(MagickFalse);
3647 if ((strchr(geometry,'x') != (char *) NULL) ||
3648 (strchr(geometry,'X') != (char *) NULL))
3649 return(MagickFalse);
3650 if ((pedantic != MagickFalse) && (strchr(geometry,',') != (char *) NULL))
3651 return(MagickFalse);
3656 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3660 % L e v e l I m a g e C o l o r s %
3664 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3666 % LevelImageColor() will map the given color to "black" and "white"
3667 % values, limearly spreading out the colors, and level values on a channel by
3668 % channel bases, as per LevelImage(). The given colors allows you to specify
3669 % different level ranges for each of the color channels seperatally.
3671 % If the boolean 'invert' is set true the image values will modifyed in the
3672 % reverse direction. That is any existing "black" and "white" colors in the
3673 % image will become the color values given, with all other values compressed
3674 % appropriatally. This effectivally maps a greyscale gradient into the given
3677 % The format of the LevelImageColors method is:
3679 % MagickBooleanType LevelImageColors(Image *image,const ChannelType channel,
3680 % const MagickPixelPacket *black_color,const MagickPixelPacket *white_color,
3681 % const MagickBooleanType invert)
3683 % A description of each parameter follows:
3685 % o image: the image.
3687 % o channel: the channel.
3689 % o black_color: The color to map black to/from
3691 % o white_point: The color to map white to/from
3693 % o invert: if true map the colors (levelize), rather than from (level)
3696 MagickBooleanType LevelImageColors(Image *image,const ChannelType channel,
3697 const MagickPixelPacket *black_color,const MagickPixelPacket *white_color,
3698 const MagickBooleanType invert)
3700 return(LevelColorsImageChannel(image,channel,black_color,white_color,invert));
3704 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3708 % L i b e r a t e M e m o r y %
3712 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3714 % LiberateMemory() frees memory that has already been allocated, and NULL's
3715 % the pointer to it.
3717 % The format of the LiberateMemory method is:
3719 % void LiberateMemory(void **memory)
3721 % A description of each parameter follows:
3723 % o memory: A pointer to a block of memory to free for reuse.
3726 MagickExport void LiberateMemory(void **memory)
3728 assert(memory != (void **) NULL);
3729 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3730 if (*memory == (void *) NULL)
3733 *memory=(void *) NULL;
3737 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3741 % L i b e r a t e S e m a p h o r e I n f o %
3745 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3747 % LiberateSemaphoreInfo() relinquishes a semaphore.
3749 % The format of the LiberateSemaphoreInfo method is:
3751 % LiberateSemaphoreInfo(void **semaphore_info)
3753 % A description of each parameter follows:
3755 % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
3758 MagickExport void LiberateSemaphoreInfo(SemaphoreInfo **semaphore_info)
3760 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3761 RelinquishSemaphoreInfo(*semaphore_info);
3765 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3769 % M a g i c k I n c a r n a t e %
3773 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3775 % MagickIncarnate() initializes the ImageMagick environment.
3777 % The format of the MagickIncarnate function is:
3779 % MagickIncarnate(const char *path)
3781 % A description of each parameter follows:
3783 % o path: the execution path of the current ImageMagick client.
3787 MagickExport void MagickIncarnate(const char *path)
3789 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
3790 MagickCoreGenesis(path,MagickFalse);
3794 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3798 % M a g i c k M o n i t o r %
3802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3804 % MagickMonitor() calls the monitor handler method with a text string that
3805 % describes the task and a measure of completion. The method returns
3806 % MagickTrue on success otherwise MagickFalse if an error is encountered, e.g.
3807 % if there was a user interrupt.
3809 % The format of the MagickMonitor method is:
3811 % MagickBooleanType MagickMonitor(const char *text,
3812 % const MagickOffsetType offset,const MagickSizeType span,
3813 % void *client_data)
3815 % A description of each parameter follows:
3817 % o offset: the position relative to the span parameter which represents
3818 % how much progress has been made toward completing a task.
3820 % o span: the span relative to completing a task.
3822 % o client_data: the client data.
3825 MagickExport MagickBooleanType MagickMonitor(const char *text,
3826 const MagickOffsetType offset,const MagickSizeType span,
3827 void *magick_unused(client_data))
3835 assert(text != (const char *) NULL);
3836 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",text);
3837 ProcessPendingEvents(text);
3839 exception=AcquireExceptionInfo();
3840 if (monitor_handler != (MonitorHandler) NULL)
3841 status=(*monitor_handler)(text,offset,span,exception);
3842 exception=DestroyExceptionInfo(exception);
3847 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3855 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3857 % MapImage() replaces the colors of an image with the closest color from a
3860 % The format of the MapImage method is:
3862 % MagickBooleanType MapImage(Image *image,const Image *map_image,
3863 % const MagickBooleanType dither)
3865 % A description of each parameter follows:
3867 % o image: Specifies a pointer to an Image structure.
3869 % o map_image: the image. Reduce image to a set of colors represented by
3872 % o dither: Set this integer value to something other than zero to
3873 % dither the mapped image.
3876 MagickExport MagickBooleanType MapImage(Image *image,const Image *map_image,
3877 const MagickBooleanType dither)
3883 Initialize color cube.
3885 assert(image != (Image *) NULL);
3886 assert(image->signature == MagickSignature);
3887 if (image->debug != MagickFalse)
3888 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3889 assert(map_image != (Image *) NULL);
3890 assert(map_image->signature == MagickSignature);
3891 GetQuantizeInfo(&quantize_info);
3892 quantize_info.dither=dither;
3893 return(RemapImage(&quantize_info,image,map_image));
3897 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3901 % M a p I m a g e s %
3905 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3907 % MapImages() replaces the colors of a sequence of images with the closest
3908 % color from a reference image.
3910 % The format of the MapImage method is:
3912 % MagickBooleanType MapImages(Image *images,Image *map_image,
3913 % const MagickBooleanType dither)
3915 % A description of each parameter follows:
3917 % o image: Specifies a pointer to a set of Image structures.
3919 % o map_image: the image. Reduce image to a set of colors represented by
3922 % o dither: Set this integer value to something other than zero to
3923 % dither the quantized image.
3926 MagickExport MagickBooleanType MapImages(Image *images,const Image *map_image,
3927 const MagickBooleanType dither)
3932 assert(images != (Image *) NULL);
3933 assert(images->signature == MagickSignature);
3934 if (images->debug != MagickFalse)
3935 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3936 GetQuantizeInfo(&quantize_info);
3937 quantize_info.dither=dither;
3938 return(RemapImages(&quantize_info,images,map_image));
3942 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3946 % M a t t e F l o o d f i l l I m a g e %
3950 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3952 % MatteFloodfill() changes the transparency value of any pixel that matches
3953 % target and is an immediate neighbor. If the method FillToBorderMethod
3954 % is specified, the transparency value is changed for any neighbor pixel
3955 % that does not match the bordercolor member of image.
3957 % By default target must match a particular pixel transparency exactly.
3958 % However, in many cases two transparency values may differ by a
3959 % small amount. The fuzz member of image defines how much tolerance is
3960 % acceptable to consider two transparency values as the same. For example,
3961 % set fuzz to 10 and the opacity values of 100 and 102 respectively are
3962 % now interpreted as the same value for the purposes of the floodfill.
3964 % The format of the MatteFloodfillImage method is:
3966 % MagickBooleanType MatteFloodfillImage(Image *image,
3967 % const PixelPacket target,const Quantum opacity,const long x_offset,
3968 % const long y_offset,const PaintMethod method)
3970 % A description of each parameter follows:
3972 % o image: the image.
3974 % o target: the RGB value of the target color.
3976 % o opacity: the level of transparency: 0 is fully opaque and QuantumRange is
3977 % fully transparent.
3979 % o x,y: the starting location of the operation.
3981 % o method: Choose either FloodfillMethod or FillToBorderMethod.
3984 MagickExport MagickBooleanType MatteFloodfillImage(Image *image,
3985 const PixelPacket target,const Quantum opacity,const long x_offset,
3986 const long y_offset,const PaintMethod method)
4002 register SegmentInfo
4009 Check boundary conditions.
4011 assert(image != (Image *) NULL);
4012 assert(image->signature == MagickSignature);
4013 if (image->debug != MagickFalse)
4014 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4015 if ((x_offset < 0) || (x_offset >= (long) image->columns))
4016 return(MagickFalse);
4017 if ((y_offset < 0) || (y_offset >= (long) image->rows))
4018 return(MagickFalse);
4019 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
4020 return(MagickFalse);
4021 if (image->matte == MagickFalse)
4022 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
4023 floodplane_image=CloneImage(image,image->columns,image->rows,MagickTrue,
4025 if (floodplane_image == (Image *) NULL)
4026 return(MagickFalse);
4027 (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel);
4029 Set floodfill color.
4031 segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
4032 sizeof(*segment_stack));
4033 if (segment_stack == (SegmentInfo *) NULL)
4035 floodplane_image=DestroyImage(floodplane_image);
4036 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
4040 Push initial segment on stack.
4046 PushSegmentStack(y,x,x,1);
4047 PushSegmentStack(y+1,x,x,-1);
4048 while (s > segment_stack)
4050 register const PixelPacket
4056 register PixelPacket
4060 Pop segment off stack.
4065 offset=(long) s->y2;
4066 y=(long) s->y1+offset;
4068 Recolor neighboring pixels.
4070 p=GetVirtualPixels(image,0,y,(unsigned long) (x1+1),1,&image->exception);
4071 q=GetAuthenticPixels(floodplane_image,0,y,(unsigned long) (x1+1),1,
4073 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4077 for (x=x1; x >= 0; x--)
4079 if (q->opacity == (Quantum) TransparentOpacity)
4081 if (method == FloodfillMethod)
4083 if (IsColorSimilar(image,p,&target) == MagickFalse)
4087 if (IsColorSimilar(image,p,&target) != MagickFalse)
4089 q->opacity=(Quantum) TransparentOpacity;
4093 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
4095 skip=x >= x1 ? MagickTrue : MagickFalse;
4096 if (skip == MagickFalse)
4100 PushSegmentStack(y,start,x1-1,-offset);
4105 if (skip == MagickFalse)
4107 if (x < (long) image->columns)
4109 p=GetVirtualPixels(image,x,y,image->columns-x,1,
4111 q=GetAuthenticPixels(floodplane_image,x,y,image->columns-x,1,
4113 if ((p == (const PixelPacket *) NULL) ||
4114 (q == (PixelPacket *) NULL))
4116 for ( ; x < (long) image->columns; x++)
4118 if (q->opacity == (Quantum) TransparentOpacity)
4120 if (method == FloodfillMethod)
4122 if (IsColorSimilar(image,p,&target) == MagickFalse)
4126 if (IsColorSimilar(image,p,&target) != MagickFalse)
4128 q->opacity=(Quantum) TransparentOpacity;
4132 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
4135 PushSegmentStack(y,start,x-1,offset);
4137 PushSegmentStack(y,x2+1,x-1,-offset);
4143 p=GetVirtualPixels(image,x,y,(unsigned long) (x2-x+1),1,
4145 q=GetAuthenticPixels(floodplane_image,x,y,(unsigned long) (x2-x+1),1,
4147 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4149 for ( ; x <= x2; x++)
4151 if (q->opacity == (Quantum) TransparentOpacity)
4153 if (method == FloodfillMethod)
4155 if (IsColorSimilar(image,p,&target) != MagickFalse)
4159 if (IsColorSimilar(image,p,&target) == MagickFalse)
4168 for (y=0; y < (long) image->rows; y++)
4170 register const PixelPacket
4176 register PixelPacket
4180 Tile fill color onto floodplane.
4182 p=GetVirtualPixels(floodplane_image,0,y,image->columns,1,
4184 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4185 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4187 for (x=0; x < (long) image->columns; x++)
4189 if (p->opacity != OpaqueOpacity)
4194 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4197 segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
4198 floodplane_image=DestroyImage(floodplane_image);
4199 return(y == (long) image->rows ? MagickTrue : MagickFalse);
4203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4207 % M o s a i c I m a g e s %
4211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4213 % MosaicImages() Obsolete Function: Use MergeImageLayers() instead.
4215 % The format of the MosaicImage method is:
4217 % Image *MosaicImages(const Image *image,ExceptionInfo *exception)
4219 % A description of each parameter follows:
4221 % o image: the image list to be composited together
4223 % o exception: return any errors or warnings in this structure.
4226 MagickExport Image *MosaicImages(Image *image,ExceptionInfo *exception)
4228 return(MergeImageLayers(image,MosaicLayer,exception));
4232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4236 % O p a q u e I m a g e %
4240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4242 % OpaqueImage() changes any pixel that matches color with the color
4245 % By default color must match a particular pixel color exactly. However,
4246 % in many cases two colors may differ by a small amount. Fuzz defines
4247 % how much tolerance is acceptable to consider two colors as the same.
4248 % For example, set fuzz to 10 and the color red at intensities of 100 and
4249 % 102 respectively are now interpreted as the same color.
4251 % The format of the OpaqueImage method is:
4253 % MagickBooleanType OpaqueImage(Image *image,
4254 % const PixelPacket *target,const PixelPacket fill)
4256 % A description of each parameter follows:
4258 % o image: the image.
4260 % o target: the RGB value of the target color.
4262 % o fill: the replacement color.
4265 MagickExport MagickBooleanType OpaqueImage(Image *image,
4266 const PixelPacket target,const PixelPacket fill)
4268 #define OpaqueImageTag "Opaque/Image"
4280 Make image color opaque.
4282 assert(image != (Image *) NULL);
4283 assert(image->signature == MagickSignature);
4284 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.1.0");
4285 if (image->debug != MagickFalse)
4286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4287 switch (image->storage_class)
4293 Make DirectClass image opaque.
4295 for (y=0; y < (long) image->rows; y++)
4300 register PixelPacket
4303 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4304 if (q == (PixelPacket *) NULL)
4306 for (x=0; x < (long) image->columns; x++)
4308 if (IsColorSimilar(image,q,&target) != MagickFalse)
4312 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4314 proceed=SetImageProgress(image,OpaqueImageTag,y,image->rows);
4315 if (proceed == MagickFalse)
4323 Make PseudoClass image opaque.
4325 for (i=0; i < (long) image->colors; i++)
4327 if (IsColorSimilar(image,&image->colormap[i],&target) != MagickFalse)
4328 image->colormap[i]=fill;
4330 if (fill.opacity != OpaqueOpacity)
4332 for (y=0; y < (long) image->rows; y++)
4337 register PixelPacket
4340 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4341 if (q == (PixelPacket *) NULL)
4343 for (x=0; x < (long) image->columns; x++)
4345 if (IsColorSimilar(image,q,&target) != MagickFalse)
4346 q->opacity=fill.opacity;
4349 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4353 (void) SyncImage(image);
4357 if (fill.opacity != OpaqueOpacity)
4358 image->matte=MagickTrue;
4363 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4367 % O p e n C a c h e V i e w %
4371 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4373 % OpenCacheView() opens a view into the pixel cache, using the
4374 % VirtualPixelMethod that is defined within the given image itself.
4376 % The format of the OpenCacheView method is:
4378 % CacheView *OpenCacheView(const Image *image)
4380 % A description of each parameter follows:
4382 % o image: the image.
4385 MagickExport CacheView *OpenCacheView(const Image *image)
4387 return(AcquireCacheView(image));
4391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4395 % P a i n t F l o o d f i l l I m a g e %
4399 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4401 % PaintFloodfill() changes the color value of any pixel that matches
4402 % target and is an immediate neighbor. If the method FillToBorderMethod is
4403 % specified, the color value is changed for any neighbor pixel that does not
4404 % match the bordercolor member of image.
4406 % By default target must match a particular pixel color exactly.
4407 % However, in many cases two colors may differ by a small amount. The
4408 % fuzz member of image defines how much tolerance is acceptable to
4409 % consider two colors as the same. For example, set fuzz to 10 and the
4410 % color red at intensities of 100 and 102 respectively are now
4411 % interpreted as the same color for the purposes of the floodfill.
4413 % The format of the PaintFloodfillImage method is:
4415 % MagickBooleanType PaintFloodfillImage(Image *image,
4416 % const ChannelType channel,const MagickPixelPacket target,const long x,
4417 % const long y,const DrawInfo *draw_info,const PaintMethod method)
4419 % A description of each parameter follows:
4421 % o image: the image.
4423 % o channel: the channel(s).
4425 % o target: the RGB value of the target color.
4427 % o x,y: the starting location of the operation.
4429 % o draw_info: the draw info.
4431 % o method: Choose either FloodfillMethod or FillToBorderMethod.
4434 MagickExport MagickBooleanType PaintFloodfillImage(Image *image,
4435 const ChannelType channel,const MagickPixelPacket *target,const long x,
4436 const long y,const DrawInfo *draw_info,const PaintMethod method)
4441 status=FloodfillPaintImage(image,channel,draw_info,target,x,y,
4442 method == FloodfillMethod ? MagickFalse : MagickTrue);
4447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4450 % P a i n t O p a q u e I m a g e %
4453 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4455 % PaintOpaqueImage() changes any pixel that matches color with the color
4458 % By default color must match a particular pixel color exactly. However,
4459 % in many cases two colors may differ by a small amount. Fuzz defines
4460 % how much tolerance is acceptable to consider two colors as the same.
4461 % For example, set fuzz to 10 and the color red at intensities of 100 and
4462 % 102 respectively are now interpreted as the same color.
4464 % The format of the PaintOpaqueImage method is:
4466 % MagickBooleanType PaintOpaqueImage(Image *image,
4467 % const PixelPacket *target,const PixelPacket *fill)
4468 % MagickBooleanType PaintOpaqueImageChannel(Image *image,
4469 % const ChannelType channel,const PixelPacket *target,
4470 % const PixelPacket *fill)
4472 % A description of each parameter follows:
4474 % o image: the image.
4476 % o channel: the channel(s).
4478 % o target: the RGB value of the target color.
4480 % o fill: the replacement color.
4484 MagickExport MagickBooleanType PaintOpaqueImage(Image *image,
4485 const MagickPixelPacket *target,const MagickPixelPacket *fill)
4490 status=OpaquePaintImageChannel(image,DefaultChannels,target,fill,MagickFalse);
4494 MagickExport MagickBooleanType PaintOpaqueImageChannel(Image *image,
4495 const ChannelType channel,const MagickPixelPacket *target,
4496 const MagickPixelPacket *fill)
4498 return(OpaquePaintImageChannel(image,channel,target,fill,MagickFalse));
4502 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4506 % P a i n t T r a n s p a r e n t I m a g e %
4510 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4512 % PaintTransparentImage() changes the opacity value associated with any pixel
4513 % that matches color to the value defined by opacity.
4515 % By default color must match a particular pixel color exactly. However,
4516 % in many cases two colors may differ by a small amount. Fuzz defines
4517 % how much tolerance is acceptable to consider two colors as the same.
4518 % For example, set fuzz to 10 and the color red at intensities of 100 and
4519 % 102 respectively are now interpreted as the same color.
4521 % The format of the PaintTransparentImage method is:
4523 % MagickBooleanType PaintTransparentImage(Image *image,
4524 % const MagickPixelPacket *target,const Quantum opacity)
4526 % A description of each parameter follows:
4528 % o image: the image.
4530 % o target: the RGB value of the target color.
4532 % o opacity: the replacement opacity value.
4535 MagickExport MagickBooleanType PaintTransparentImage(Image *image,
4536 const MagickPixelPacket *target,const Quantum opacity)
4538 return(TransparentPaintImage(image,target,opacity,MagickFalse));
4542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4546 + P a r s e I m a g e G e o m e t r y %
4550 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4552 % ParseImageGeometry() is similar to GetGeometry() except the returned
4553 % geometry is modified as determined by the meta characters: %, !, <,
4556 % The format of the ParseImageGeometry method is:
4558 % int ParseImageGeometry(char *geometry,long *x,long *y,
4559 % unsigned long *width,unsigned long *height)
4561 % A description of each parameter follows:
4563 % o flags: Method ParseImageGeometry returns a bitmask that indicates
4564 % which of the four values were located in the geometry string.
4566 % o image_geometry: Specifies a character string representing the geometry
4569 % o x,y: A pointer to an integer. The x and y offset as determined by
4570 % the geometry specification is returned here.
4572 % o width,height: A pointer to an unsigned integer. The width and height
4573 % as determined by the geometry specification is returned here.
4576 MagickExport int ParseImageGeometry(const char *geometry,long *x,long *y,
4577 unsigned long *width,unsigned long *height)
4579 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
4580 return((int) ParseMetaGeometry(geometry,x,y,width,height));
4584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4588 % P a r s e S i z e G e o m e t r y %
4592 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4594 % ParseSizeGeometry() returns a region as defined by the geometry string with
4595 % respect to the image dimensions and aspect ratio.
4597 % The format of the ParseSizeGeometry method is:
4599 % MagickStatusType ParseSizeGeometry(const Image *image,
4600 % const char *geometry,RectangeInfo *region_info)
4602 % A description of each parameter follows:
4604 % o geometry: The geometry (e.g. 100x100+10+10).
4606 % o region_info: the region as defined by the geometry string.
4609 MagickExport MagickStatusType ParseSizeGeometry(const Image *image,
4610 const char *geometry,RectangleInfo *region_info)
4615 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.4.7");
4616 SetGeometry(image,region_info);
4617 flags=ParseMetaGeometry(geometry,®ion_info->x,®ion_info->y,
4618 ®ion_info->width,®ion_info->height);
4623 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4627 % P o p I m a g e L i s t %
4631 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4633 % PopImageList() removes the last image in the list.
4635 % The format of the PopImageList method is:
4637 % Image *PopImageList(Image **images)
4639 % A description of each parameter follows:
4641 % o images: the image list.
4644 MagickExport Image *PopImageList(Image **images)
4646 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
4647 return(RemoveLastImageFromList(images));
4651 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4655 % P o p I m a g e P i x e l s %
4659 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4661 % PopImagePixels() transfers one or more pixel components from the image pixel
4662 % cache to a user supplied buffer. The pixels are returned in network byte
4663 % order. MagickTrue is returned if the pixels are successfully transferred,
4664 % otherwise MagickFalse.
4666 % The format of the PopImagePixels method is:
4668 % size_t PopImagePixels(Image *,const QuantumType quantum,
4669 % unsigned char *destination)
4671 % A description of each parameter follows:
4673 % o image: the image.
4675 % o quantum: Declare which pixel components to transfer (RGB, RGBA, etc).
4677 % o destination: The components are transferred to this buffer.
4680 MagickExport size_t PopImagePixels(Image *image,const QuantumType quantum,
4681 unsigned char *destination)
4689 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
4690 if (quantum_info == (QuantumInfo *) NULL)
4692 length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
4693 quantum,destination,&image->exception);
4694 quantum_info=DestroyQuantumInfo(quantum_info);
4699 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4703 % P o s t s c r i p t G e o m e t r y %
4707 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4709 % PostscriptGeometry() replaces any page mneumonic with the equivalent size in
4712 % The format of the PostscriptGeometry method is:
4714 % char *PostscriptGeometry(const char *page)
4716 % A description of each parameter follows.
4718 % o page: Specifies a pointer to an array of characters.
4719 % The string is either a Postscript page name (e.g. A4) or a postscript
4720 % page geometry (e.g. 612x792+36+36).
4723 MagickExport char *PostscriptGeometry(const char *page)
4725 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
4726 return(GetPageGeometry(page));
4730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4734 % P u s h I m a g e L i s t %
4738 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4740 % PushImageList() adds an image to the end of the list.
4742 % The format of the PushImageList method is:
4744 % unsigned int PushImageList(Image *images,const Image *image,
4745 % ExceptionInfo *exception)
4747 % A description of each parameter follows:
4749 % o images: the image list.
4751 % o image: the image.
4753 % o exception: return any errors or warnings in this structure.
4756 MagickExport unsigned int PushImageList(Image **images,const Image *image,
4757 ExceptionInfo *exception)
4759 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
4760 AppendImageToList(images,CloneImageList(image,exception));
4765 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4769 % P u s h I m a g e P i x e l s %
4773 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4775 % PushImagePixels() transfers one or more pixel components from a user
4776 % supplied buffer into the image pixel cache of an image. The pixels are
4777 % expected in network byte order. It returns MagickTrue if the pixels are
4778 % successfully transferred, otherwise MagickFalse.
4780 % The format of the PushImagePixels method is:
4782 % size_t PushImagePixels(Image *image,const QuantumType quantum,
4783 % const unsigned char *source)
4785 % A description of each parameter follows:
4787 % o image: the image.
4789 % o quantum: Declare which pixel components to transfer (red, green, blue,
4790 % opacity, RGB, or RGBA).
4792 % o source: The pixel components are transferred from this buffer.
4795 MagickExport size_t PushImagePixels(Image *image,const QuantumType quantum,
4796 const unsigned char *source)
4804 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
4805 if (quantum_info == (QuantumInfo *) NULL)
4807 length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,quantum,
4808 source,&image->exception);
4809 quantum_info=DestroyQuantumInfo(quantum_info);
4814 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4818 % Q u a n t i z a t i o n E r r o r %
4822 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4824 % QuantizationError() measures the difference between the original and
4825 % quantized images. This difference is the total quantization error. The
4826 % error is computed by summing over all pixels in an image the distance
4827 % squared in RGB space between each reference pixel value and its quantized
4828 % value. These values are computed:
4830 % o mean_error_per_pixel: This value is the mean error for any single
4831 % pixel in the image.
4833 % o normalized_mean_square_error: This value is the normalized mean
4834 % quantization error for any single pixel in the image. This distance
4835 % measure is normalized to a range between 0 and 1. It is independent
4836 % of the range of red, green, and blue values in the image.
4838 % o normalized_maximum_square_error: Thsi value is the normalized
4839 % maximum quantization error for any single pixel in the image. This
4840 % distance measure is normalized to a range between 0 and 1. It is
4841 % independent of the range of red, green, and blue values in your image.
4844 % The format of the QuantizationError method is:
4846 % unsigned int QuantizationError(Image *image)
4848 % A description of each parameter follows.
4850 % o image: Specifies a pointer to an Image structure; returned from
4854 MagickExport unsigned int QuantizationError(Image *image)
4856 if (image->debug != MagickFalse)
4857 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.3");
4858 return(GetImageQuantizeError(image));
4862 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4865 % 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 %
4869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4871 % RandomChannelThresholdImage() changes the value of individual pixels based
4872 % on the intensity of each pixel compared to a random threshold. The result
4873 % is a low-contrast, two color image.
4875 % The format of the RandomChannelThresholdImage method is:
4877 % unsigned int RandomChannelThresholdImage(Image *image,
4878 % const char *channel, const char *thresholds,
4879 % ExceptionInfo *exception)
4881 % A description of each parameter follows:
4883 % o image: the image.
4885 % o channel: the channel or channels to be thresholded.
4887 % o thresholds: a geometry string containing LOWxHIGH thresholds.
4888 % If the string contains 2x2, 3x3, or 4x4, then an ordered
4889 % dither of order 2, 3, or 4 will be performed instead.
4891 % o exception: return any errors or warnings in this structure.
4894 MagickExport unsigned int RandomChannelThresholdImage(Image *image,const char
4895 *channel,const char *thresholds,ExceptionInfo *exception)
4897 #define RandomChannelThresholdImageText " RandomChannelThreshold image... "
4910 static MagickRealType
4911 o2[4]={0.2f, 0.6f, 0.8f, 0.4f},
4912 o3[9]={0.1f, 0.6f, 0.3f, 0.7f, 0.5f, 0.8f, 0.4f, 0.9f, 0.2f},
4913 o4[16]={0.1f, 0.7f, 1.1f, 0.3f, 1.0f, 0.5f, 1.5f, 0.8f, 1.4f, 1.6f, 0.6f,
4914 1.2f, 0.4f, 0.9f, 1.3f, 0.2f},
4923 assert(image != (Image *) NULL);
4924 assert(image->signature == MagickSignature);
4925 if (image->debug != MagickFalse)
4926 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4927 assert(exception != (ExceptionInfo *) NULL);
4928 assert(exception->signature == MagickSignature);
4929 if (image->debug != MagickFalse)
4930 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
4931 if (thresholds == (const char *) NULL)
4933 if (LocaleCompare(thresholds,"2x2") == 0)
4936 if (LocaleCompare(thresholds,"3x3") == 0)
4939 if (LocaleCompare(thresholds,"4x4") == 0)
4946 count=sscanf(thresholds,"%lf[/x%%]%lf",&lower_threshold,
4948 if (strchr(thresholds,'%') != (char *) NULL)
4950 upper_threshold*=(.01*QuantumRange);
4951 lower_threshold*=(.01*QuantumRange);
4954 upper_threshold=(MagickRealType) QuantumRange-lower_threshold;
4956 if (image->debug != MagickFalse)
4957 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
4958 " RandomChannelThresholdImage: channel type=%s",channel);
4959 if (image->debug != MagickFalse)
4960 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
4961 " Thresholds: %s (%fx%f)",thresholds,lower_threshold,upper_threshold);
4962 if (LocaleCompare(channel,"all") == 0 ||
4963 LocaleCompare(channel,"intensity") == 0)
4964 if (AcquireImageColormap(image,2) == MagickFalse)
4965 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
4967 random_info=AcquireRandomInfo();
4968 for (y=0; y < (long) image->rows; y++)
4973 register IndexPacket
4975 *__restrict indexes;
4977 register PixelPacket
4980 q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
4981 if (q == (PixelPacket *) NULL)
4983 if (LocaleCompare(channel,"all") == 0 ||
4984 LocaleCompare(channel,"intensity") == 0)
4986 indexes=GetAuthenticIndexQueue(image);
4987 for (x=0; x < (long) image->columns; x++)
4992 intensity=(MagickRealType) PixelIntensityToQuantum(q);
4995 if (intensity < lower_threshold)
4996 threshold=lower_threshold;
4997 else if (intensity > upper_threshold)
4998 threshold=upper_threshold;
5000 threshold=(MagickRealType) (QuantumRange*
5001 GetPseudoRandomValue(random_info));
5003 else if (order == 2)
5004 threshold=(MagickRealType) QuantumRange*o2[(x%2)+2*(y%2)];
5005 else if (order == 3)
5006 threshold=(MagickRealType) QuantumRange*o3[(x%3)+3*(y%3)];
5007 else if (order == 4)
5008 threshold=(MagickRealType) QuantumRange*o4[(x%4)+4*(y%4)];
5009 q->red=q->green=q->blue=(Quantum) (intensity <=
5010 threshold ? 0 : QuantumRange);
5011 index=(IndexPacket) (intensity <= threshold ? 0 : 1);
5013 q->red=q->green=q->blue=image->colormap[(long) index].red;
5017 if (LocaleCompare(channel,"opacity") == 0 ||
5018 LocaleCompare(channel,"all") == 0 ||
5019 LocaleCompare(channel,"matte") == 0)
5021 if (image->matte != MagickFalse)
5022 for (x=0; x < (long) image->columns; x++)
5026 if ((MagickRealType) q->opacity < lower_threshold)
5027 threshold=lower_threshold;
5028 else if ((MagickRealType) q->opacity > upper_threshold)
5029 threshold=upper_threshold;
5031 threshold=(MagickRealType) (QuantumRange*
5032 GetPseudoRandomValue(random_info));
5034 else if (order == 2)
5035 threshold=(MagickRealType) QuantumRange*o2[(x%2)+2*(y%2)];
5036 else if (order == 3)
5037 threshold=(MagickRealType) QuantumRange*o3[(x%3)+3*(y%3)];
5038 else if (order == 4)
5039 threshold=(MagickRealType) QuantumRange*o4[(x%4)+4*(y%4)]/1.7;
5040 q->opacity=(Quantum) ((MagickRealType) q->opacity <= threshold ?
5047 /* To Do: red, green, blue, cyan, magenta, yellow, black */
5048 if (LocaleCompare(channel,"intensity") != 0)
5049 ThrowBinaryException(OptionError,"UnrecognizedChannelType",
5052 if (SyncAuthenticPixels(image,exception) == MagickFalse)
5055 random_info=DestroyRandomInfo(random_info);
5060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5064 % R e a c q u i r e M e m o r y %
5068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5070 % ReacquireMemory() changes the size of the memory and returns a pointer to
5071 % the (possibly moved) block. The contents will be unchanged up to the
5072 % lesser of the new and old sizes.
5074 % The format of the ReacquireMemory method is:
5076 % void ReacquireMemory(void **memory,const size_t size)
5078 % A description of each parameter follows:
5080 % o memory: A pointer to a memory allocation. On return the pointer
5081 % may change but the contents of the original allocation will not.
5083 % o size: the new size of the allocated memory.
5086 MagickExport void ReacquireMemory(void **memory,const size_t size)
5091 assert(memory != (void **) NULL);
5092 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5093 if (*memory == (void *) NULL)
5095 *memory=AcquireMagickMemory(size);
5098 allocation=realloc(*memory,size);
5099 if (allocation == (void *) NULL)
5100 *memory=RelinquishMagickMemory(*memory);
5105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5109 % 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 %
5113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5115 % ResetImageAttributeIterator() resets the image attributes iterator. Use it
5116 % in conjunction with GetNextImageAttribute() to iterate over all the values
5117 % associated with an image.
5119 % The format of the ResetImageAttributeIterator method is:
5121 % ResetImageAttributeIterator(const ImageInfo *image)
5123 % A description of each parameter follows:
5125 % o image: the image.
5128 MagickExport void ResetImageAttributeIterator(const Image *image)
5130 ResetImagePropertyIterator(image);
5134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5138 % S e t C a c h e V i e w P i x e l s %
5142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5144 % SetCacheViewPixels() gets pixels from the in-memory or disk pixel cache as
5145 % defined by the geometry parameters. A pointer to the pixels is returned
5146 % if the pixels are transferred, otherwise a NULL is returned.
5148 % The format of the SetCacheViewPixels method is:
5150 % PixelPacket *SetCacheViewPixels(CacheView *cache_view,const long x,
5151 % const long y,const unsigned long columns,const unsigned long rows)
5153 % A description of each parameter follows:
5155 % o cache_view: the cache view.
5157 % o x,y,columns,rows: These values define the perimeter of a region of
5161 MagickExport PixelPacket *SetCacheViewPixels(CacheView *cache_view,const long x,
5162 const long y,const unsigned long columns,const unsigned long rows)
5167 pixels=QueueCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
5168 GetCacheViewException(cache_view));
5173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5177 + S e t C a c h e T h e s h o l d %
5181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5183 % SetCacheThreshold() sets the amount of free memory allocated for the pixel
5184 % cache. Once this threshold is exceeded, all subsequent pixels cache
5185 % operations are to/from disk.
5187 % The format of the SetCacheThreshold() method is:
5189 % void SetCacheThreshold(const size_t threshold)
5191 % A description of each parameter follows:
5193 % o threshold: the number of megabytes of memory available to the pixel
5197 MagickExport void SetCacheThreshold(const unsigned long size)
5199 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
5200 (void) SetMagickResourceLimit(MemoryResource,size*1024*1024);
5201 (void) SetMagickResourceLimit(MapResource,2*size*1024*1024);
5205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5209 % S e t E x c e p t i o n I n f o %
5213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5215 % SetExceptionInfo() sets the exception severity.
5217 % The format of the SetExceptionInfo method is:
5219 % MagickBooleanType SetExceptionInfo(ExceptionInfo *exception,
5220 % ExceptionType severity)
5222 % A description of each parameter follows:
5224 % o exception: the exception info.
5226 % o severity: the exception severity.
5229 MagickExport MagickBooleanType SetExceptionInfo(ExceptionInfo *exception,
5230 ExceptionType severity)
5232 assert(exception != (ExceptionInfo *) NULL);
5233 ClearMagickException(exception);
5234 exception->severity=severity;
5239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5249 % SetImage() sets the red, green, and blue components of each pixel to
5250 % the image background color and the opacity component to the specified
5251 % level of transparency. The background color is defined by the
5252 % background_color member of the image.
5254 % The format of the SetImage method is:
5256 % void SetImage(Image *image,const Quantum opacity)
5258 % A description of each parameter follows:
5260 % o image: the image.
5262 % o opacity: Set each pixel to this level of transparency.
5265 MagickExport void SetImage(Image *image,const Quantum opacity)
5273 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.0");
5274 assert(image != (Image *) NULL);
5275 if (image->debug != MagickFalse)
5276 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
5277 assert(image->signature == MagickSignature);
5278 background_color=image->background_color;
5279 if (opacity != OpaqueOpacity)
5280 background_color.opacity=opacity;
5281 if (background_color.opacity != OpaqueOpacity)
5283 (void) SetImageStorageClass(image,DirectClass);
5284 image->matte=MagickTrue;
5286 if ((image->storage_class == PseudoClass) ||
5287 (image->colorspace == CMYKColorspace))
5290 Set colormapped or CMYK image.
5292 for (y=0; y < (long) image->rows; y++)
5294 register IndexPacket
5295 *__restrict indexes;
5300 register PixelPacket
5303 q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
5304 if (q == (PixelPacket *) NULL)
5306 for (x=0; x < (long) image->columns; x++)
5307 *q++=background_color;
5308 indexes=GetAuthenticIndexQueue(image);
5309 for (x=0; x < (long) image->columns; x++)
5310 indexes[x]=(IndexPacket) 0;
5311 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
5317 Set DirectClass image.
5319 for (y=0; y < (long) image->rows; y++)
5324 register PixelPacket
5327 q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
5328 if (q == (PixelPacket *) NULL)
5330 for (x=0; x < (long) image->columns; x++)
5331 *q++=background_color;
5332 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
5338 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5342 % S e t I m a g e A t t r i b u t e %
5346 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5348 % SetImageAttribute() searches the list of image attributes and replaces the
5349 % attribute value. If it is not found in the list, the attribute name
5350 % and value is added to the list.
5352 % The format of the SetImageAttribute method is:
5354 % MagickBooleanType SetImageAttribute(Image *image,const char *key,
5355 % const char *value)
5357 % A description of each parameter follows:
5359 % o image: the image.
5363 % o value: the value.
5366 MagickExport MagickBooleanType SetImageAttribute(Image *image,const char *key,
5369 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
5370 return(SetImageProperty(image,key,value));
5374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5378 % S e t I m a g e L i s t %
5382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5384 % SetImageList() inserts an image into the list at the specified position.
5386 % The format of the SetImageList method is:
5388 % unsigned int SetImageList(Image *images,const Image *image,
5389 % const long offset,ExceptionInfo *exception)
5391 % A description of each parameter follows:
5393 % o images: the image list.
5395 % o image: the image.
5397 % o offset: the position within the list.
5399 % o exception: return any errors or warnings in this structure.
5402 MagickExport unsigned int SetImageList(Image **images,const Image *image,
5403 const long offset,ExceptionInfo *exception)
5411 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5412 clone=CloneImageList(image,exception);
5413 while (GetPreviousImageInList(*images) != (Image *) NULL)
5414 (*images)=GetPreviousImageInList(*images);
5415 for (i=0; i < offset; i++)
5417 if (GetNextImageInList(*images) == (Image *) NULL)
5418 return(MagickFalse);
5419 (*images)=GetNextImageInList(*images);
5421 InsertImageInList(images,clone);
5426 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5430 % S e t I m a g e P i x e l s %
5434 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5436 % SetImagePixels() queues a mutable pixel region.
5437 % If the region is successfully intialized a pointer to a PixelPacket
5438 % array representing the region is returned, otherwise NULL is returned.
5439 % The returned pointer may point to a temporary working buffer for the
5440 % pixels or it may point to the final location of the pixels in memory.
5442 % Write-only access means that any existing pixel values corresponding to
5443 % the region are ignored. This useful while the initial image is being
5444 % created from scratch, or if the existing pixel values are to be
5445 % completely replaced without need to refer to their pre-existing values.
5446 % The application is free to read and write the pixel buffer returned by
5447 % SetImagePixels() any way it pleases. SetImagePixels() does not initialize
5448 % the pixel array values. Initializing pixel array values is the
5449 % application's responsibility.
5451 % Performance is maximized if the selected region is part of one row, or
5452 % one or more full rows, since then there is opportunity to access the
5453 % pixels in-place (without a copy) if the image is in RAM, or in a
5454 % memory-mapped file. The returned pointer should *never* be deallocated
5457 % Pixels accessed via the returned pointer represent a simple array of type
5458 % PixelPacket. If the image type is CMYK or the storage class is PseudoClass,
5459 % call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to obtain
5460 % the black color component or the colormap indexes (of type IndexPacket)
5461 % corresponding to the region. Once the PixelPacket (and/or IndexPacket)
5462 % array has been updated, the changes must be saved back to the underlying
5463 % image using SyncAuthenticPixels() or they may be lost.
5465 % The format of the SetImagePixels() method is:
5467 % PixelPacket *SetImagePixels(Image *image,const long x,const long y,
5468 % const unsigned long columns,const unsigned long rows)
5470 % A description of each parameter follows:
5472 % o pixels: SetImagePixels returns a pointer to the pixels if they are
5473 % transferred, otherwise a NULL is returned.
5475 % o image: the image.
5477 % o x,y,columns,rows: These values define the perimeter of a region of
5481 MagickExport PixelPacket *SetImagePixels(Image *image,const long x,const long y,
5482 const unsigned long columns,const unsigned long rows)
5484 return(QueueAuthenticPixels(image,x,y,columns,rows,&image->exception));
5488 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5492 % S e t M a g i c k R e g i s t r y %
5496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5498 % SetMagickRegistry() sets a blob into the registry and returns a unique ID.
5499 % If an error occurs, -1 is returned.
5501 % The format of the SetMagickRegistry method is:
5503 % long SetMagickRegistry(const RegistryType type,const void *blob,
5504 % const size_t length,ExceptionInfo *exception)
5506 % A description of each parameter follows:
5508 % o type: the registry type.
5510 % o blob: the address of a Binary Large OBject.
5512 % o length: For a registry type of ImageRegistryType use sizeof(Image)
5513 % otherise the blob length in number of bytes.
5515 % o exception: return any errors or warnings in this structure.
5518 MagickExport long SetMagickRegistry(const RegistryType type,const void *blob,
5519 const size_t magick_unused(length),ExceptionInfo *exception)
5530 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
5531 status=SetImageRegistry(type,key,blob,exception);
5532 if (status == MagickFalse)
5538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5542 % S e t M o n i t o r H a n d l e r %
5546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5548 % SetMonitorHandler() sets the monitor handler to the specified method
5549 % and returns the previous monitor handler.
5551 % The format of the SetMonitorHandler method is:
5553 % MonitorHandler SetMonitorHandler(MonitorHandler handler)
5555 % A description of each parameter follows:
5557 % o handler: Specifies a pointer to a method to handle monitors.
5561 MagickExport MonitorHandler GetMonitorHandler(void)
5563 return(monitor_handler);
5566 MagickExport MonitorHandler SetMonitorHandler(MonitorHandler handler)
5571 previous_handler=monitor_handler;
5572 monitor_handler=handler;
5573 return(previous_handler);
5577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5581 % S h i f t I m a g e L i s t %
5585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5587 % ShiftImageList() removes an image from the beginning of the list.
5589 % The format of the ShiftImageList method is:
5591 % Image *ShiftImageList(Image **images)
5593 % A description of each parameter follows:
5595 % o images: the image list.
5598 MagickExport Image *ShiftImageList(Image **images)
5600 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5601 return(RemoveFirstImageFromList(images));
5605 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5613 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5615 % SizeBlob() returns the current length of the image file or blob.
5617 % The format of the SizeBlob method is:
5619 % off_t SizeBlob(Image *image)
5621 % A description of each parameter follows:
5623 % o size: Method SizeBlob returns the current length of the image file
5626 % o image: the image.
5629 MagickExport MagickOffsetType SizeBlob(Image *image)
5631 if (image->debug != MagickFalse)
5632 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.3");
5633 return((MagickOffsetType) GetBlobSize(image));
5637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5641 % S p l i c e I m a g e L i s t %
5645 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5647 % SpliceImageList() removes the images designated by offset and length from
5648 % the list and replaces them with the specified list.
5650 % The format of the SpliceImageList method is:
5652 % Image *SpliceImageList(Image *images,const long offset,
5653 % const unsigned long length,const Image *splices,
5654 % ExceptionInfo *exception)
5656 % A description of each parameter follows:
5658 % o images: the image list.
5660 % o offset: the position within the list.
5662 % o length: the length of the image list to remove.
5664 % o splice: Replace the removed image list with this list.
5666 % o exception: return any errors or warnings in this structure.
5669 MagickExport Image *SpliceImageList(Image *images,const long offset,
5670 const unsigned long length,const Image *splices,ExceptionInfo *exception)
5678 if (images->debug != MagickFalse)
5679 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5680 clone=CloneImageList(splices,exception);
5681 while (GetPreviousImageInList(images) != (Image *) NULL)
5682 images=GetPreviousImageInList(images);
5683 for (i=0; i < offset; i++)
5685 if (GetNextImageInList(images) == (Image *) NULL)
5686 return((Image *) NULL);
5687 images=GetNextImageInList(images);
5689 (void) SpliceImageIntoList(&images,length,clone);
5694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5702 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5704 % Strip() strips any whitespace or quotes from the beginning and end of a
5705 % string of characters.
5707 % The format of the Strip method is:
5709 % void Strip(char *message)
5711 % A description of each parameter follows:
5713 % o message: Specifies an array of characters.
5716 MagickExport void Strip(char *message)
5722 assert(message != (char *) NULL);
5723 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5724 if (*message == '\0')
5726 if (strlen(message) == 1)
5729 while (isspace((int) ((unsigned char) *p)) != 0)
5731 if ((*p == '\'') || (*p == '"'))
5733 q=message+strlen(message)-1;
5734 while ((isspace((int) ((unsigned char) *q)) != 0) && (q > p))
5737 if ((*q == '\'') || (*q == '"'))
5739 (void) CopyMagickMemory(message,p,(size_t) (q-p+1));
5740 message[q-p+1]='\0';
5744 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5748 % S y n c C a c h e V i e w %
5752 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5754 % SyncCacheView() saves the cache view pixels to the in-memory or disk
5755 % cache. It returns MagickTrue if the pixel region is synced, otherwise
5758 % The format of the SyncCacheView method is:
5760 % MagickBooleanType SyncCacheView(CacheView *cache_view)
5762 % A description of each parameter follows:
5764 % o cache_view: the cache view.
5767 MagickExport MagickBooleanType SyncCacheView(CacheView *cache_view)
5772 status=SyncCacheViewAuthenticPixels(cache_view,
5773 GetCacheViewException(cache_view));
5778 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5782 % S y n c C a c h e V i e w P i x e l s %
5786 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5788 % SyncCacheViewPixels() saves the cache view pixels to the in-memory
5789 % or disk cache. It returns MagickTrue if the pixel region is flushed,
5790 % otherwise MagickFalse.
5792 % The format of the SyncCacheViewPixels method is:
5794 % MagickBooleanType SyncCacheViewPixels(CacheView *cache_view)
5796 % A description of each parameter follows:
5798 % o cache_view: the cache view.
5800 % o exception: return any errors or warnings in this structure.
5803 MagickExport MagickBooleanType SyncCacheViewPixels(CacheView *cache_view)
5808 status=SyncCacheViewAuthenticPixels(cache_view,
5809 GetCacheViewException(cache_view));
5814 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5818 % S y n c I m a g e P i x e l s %
5822 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5824 % SyncImagePixels() saves the image pixels to the in-memory or disk cache.
5825 % The method returns MagickTrue if the pixel region is synced, otherwise
5828 % The format of the SyncImagePixels() method is:
5830 % MagickBooleanType SyncImagePixels(Image *image)
5832 % A description of each parameter follows:
5834 % o image: the image.
5837 MagickExport MagickBooleanType SyncImagePixels(Image *image)
5839 return(SyncAuthenticPixels(image,&image->exception));
5843 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5847 % T e m p o r a r y F i l e n a m e %
5851 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5853 % TemporaryFilename() replaces the contents of path by a unique path name.
5855 % The format of the TemporaryFilename method is:
5857 % void TemporaryFilename(char *path)
5859 % A description of each parameter follows.
5861 % o path: Specifies a pointer to an array of characters. The unique path
5862 % name is returned in this array.
5865 MagickExport void TemporaryFilename(char *path)
5867 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
5868 (void) AcquireUniqueFilename(path);
5869 (void) RelinquishUniqueFileResource(path);
5873 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5877 % T h r e s h o l d I m a g e %
5881 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5883 % ThresholdImage() changes the value of individual pixels based on
5884 % the intensity of each pixel compared to threshold. The result is a
5885 % high-contrast, two color image.
5887 % The format of the ThresholdImage method is:
5889 % unsigned int ThresholdImage(Image *image,const double threshold)
5891 % A description of each parameter follows:
5893 % o image: the image.
5895 % o threshold: Define the threshold value
5898 MagickExport unsigned int ThresholdImage(Image *image,const double threshold)
5900 #define ThresholdImageTag "Threshold/Image"
5911 assert(image != (Image *) NULL);
5912 assert(image->signature == MagickSignature);
5913 if (image->debug != MagickFalse)
5914 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
5915 if (image->debug != MagickFalse)
5916 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5917 if (!AcquireImageColormap(image,2))
5918 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
5919 "UnableToThresholdImage");
5920 for (y=0; y < (long) image->rows; y++)
5922 register IndexPacket
5923 *__restrict indexes;
5928 register PixelPacket
5931 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
5932 if (q == (PixelPacket *) NULL)
5934 indexes=GetAuthenticIndexQueue(image);
5935 for (x=0; x < (long) image->columns; x++)
5937 index=(IndexPacket) ((MagickRealType)
5938 PixelIntensityToQuantum(q) <= threshold ? 0 : 1);
5940 q->red=image->colormap[(long) index].red;
5941 q->green=image->colormap[(long) index].green;
5942 q->blue=image->colormap[(long) index].blue;
5945 if (!SyncAuthenticPixels(image,&image->exception))
5952 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5956 % T h r e s h o l d I m a g e C h a n n e l %
5960 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5962 % ThresholdImageChannel() changes the value of individual pixels based on
5963 % the intensity of each pixel channel. The result is a high-contrast image.
5965 % The format of the ThresholdImageChannel method is:
5967 % unsigned int ThresholdImageChannel(Image *image,const char *threshold)
5969 % A description of each parameter follows:
5971 % o image: the image.
5973 % o threshold: define the threshold values.
5976 MagickExport unsigned int ThresholdImageChannel(Image *image,
5977 const char *threshold)
5979 #define ThresholdImageTag "Threshold/Image"
5999 assert(image != (Image *) NULL);
6000 assert(image->signature == MagickSignature);
6001 if (image->debug != MagickFalse)
6002 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6003 if (threshold == (const char *) NULL)
6005 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
6006 return(MagickFalse);
6007 flags=ParseGeometry(threshold,&geometry_info);
6008 pixel.red=geometry_info.rho;
6009 if (flags & SigmaValue)
6010 pixel.green=geometry_info.sigma;
6012 pixel.green=pixel.red;
6013 if (flags & XiValue)
6014 pixel.blue=geometry_info.xi;
6016 pixel.blue=pixel.red;
6017 if (flags & PsiValue)
6018 pixel.opacity=geometry_info.psi;
6020 pixel.opacity=(MagickRealType) OpaqueOpacity;
6021 if (flags & PercentValue)
6023 pixel.red*=QuantumRange/100.0f;
6024 pixel.green*=QuantumRange/100.0f;
6025 pixel.blue*=QuantumRange/100.0f;
6026 pixel.opacity*=QuantumRange/100.0f;
6028 if (!(flags & SigmaValue))
6030 if (!AcquireImageColormap(image,2))
6031 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
6032 "UnableToThresholdImage");
6034 (void) GetImageDynamicThreshold(image,2.0,2.0,&pixel,&image->exception);
6036 for (y=0; y < (long) image->rows; y++)
6038 register IndexPacket
6039 *__restrict indexes;
6044 register PixelPacket
6047 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6048 if (q == (PixelPacket *) NULL)
6050 indexes=GetAuthenticIndexQueue(image);
6051 if (IsMagickGray(&pixel) != MagickFalse)
6052 for (x=0; x < (long) image->columns; x++)
6054 index=(IndexPacket) ((MagickRealType)
6055 PixelIntensityToQuantum(q) <= pixel.red ? 0 : 1);
6057 q->red=image->colormap[(long) index].red;
6058 q->green=image->colormap[(long) index].green;
6059 q->blue=image->colormap[(long) index].blue;
6063 for (x=0; x < (long) image->columns; x++)
6065 q->red=(Quantum) ((MagickRealType)
6066 q->red <= pixel.red ? 0 : QuantumRange);
6067 q->green=(Quantum) ((MagickRealType)
6068 q->green <= pixel.green ? 0 : QuantumRange);
6069 q->blue=(Quantum) ((MagickRealType)
6070 q->blue <= pixel.blue ? 0 : QuantumRange);
6071 q->opacity=(Quantum) ((MagickRealType)
6072 q->opacity <= pixel.opacity ? 0 : QuantumRange);
6075 if (!SyncAuthenticPixels(image,&image->exception))
6082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6086 + T r a n s f o r m C o l o r s p a c e %
6090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6092 % TransformColorspace() converts the image to a specified colorspace.
6093 % If the image is already in the requested colorspace, no work is performed.
6094 % Note that the current colorspace is stored in the image colorspace member.
6095 % The transformation matrices are not necessarily the standard ones: the
6096 % weights are rescaled to normalize the range of the transformed values to
6097 % be [0..QuantumRange].
6099 % The format of the TransformColorspace method is:
6101 % unsigned int (void) TransformColorspace(Image *image,
6102 % const ColorspaceType colorspace)
6104 % A description of each parameter follows:
6106 % o image: the image to transform
6108 % o colorspace: the desired colorspace.
6111 MagickExport unsigned int TransformColorspace(Image *image,
6112 const ColorspaceType colorspace)
6114 assert(image != (Image *) NULL);
6115 assert(image->signature == MagickSignature);
6116 if (image->debug != MagickFalse)
6117 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
6118 return(TransformImageColorspace(image,colorspace));
6122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6126 % T r a n s f o r m H S L %
6130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6132 % TransformHSL() converts a (red, green, blue) to a (hue, saturation,
6133 % lightness) triple.
6135 % The format of the TransformHSL method is:
6137 % void TransformHSL(const Quantum red,const Quantum green,
6138 % const Quantum blue,double *hue,double *saturation,double *lightness)
6140 % A description of each parameter follows:
6142 % o red, green, blue: A Quantum value representing the red, green, and
6143 % blue component of a pixel..
6145 % o hue, saturation, lightness: A pointer to a double value representing a
6146 % component of the HSL color space.
6150 static inline double MagickMin(const double x,const double y)
6157 MagickExport void TransformHSL(const Quantum red,const Quantum green,
6158 const Quantum blue,double *hue,double *saturation,double *lightness)
6169 Convert RGB to HSL colorspace.
6171 assert(hue != (double *) NULL);
6172 assert(saturation != (double *) NULL);
6173 assert(lightness != (double *) NULL);
6175 g=QuantumScale*green;
6176 b=QuantumScale*blue;
6177 max=MagickMax(r,MagickMax(g,b));
6178 min=MagickMin(r,MagickMin(g,b));
6181 *lightness=(double) ((min+max)/2.0);
6185 *saturation=(double) (delta/((*lightness < 0.5) ? (min+max) :
6188 *hue=(double) (g == min ? 5.0+(max-b)/delta : 1.0-(max-g)/delta);
6191 *hue=(double) (b == min ? 1.0+(max-r)/delta : 3.0-(max-b)/delta);
6193 *hue=(double) (r == min ? 3.0+(max-g)/delta : 5.0-(max-r)/delta);
6198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6202 % T r a n s l a t e T e x t %
6206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6208 % TranslateText() replaces any embedded formatting characters with the
6209 % appropriate image attribute and returns the translated text.
6211 % The format of the TranslateText method is:
6213 % char *TranslateText(const ImageInfo *image_info,Image *image,
6214 % const char *embed_text)
6216 % A description of each parameter follows:
6218 % o image_info: the image info.
6220 % o image: the image.
6222 % o embed_text: the address of a character string containing the embedded
6223 % formatting characters.
6226 MagickExport char *TranslateText(const ImageInfo *image_info,Image *image,
6227 const char *embed_text)
6229 assert(image != (Image *) NULL);
6230 assert(image->signature == MagickSignature);
6231 if (image->debug != MagickFalse)
6232 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.6");
6233 return(InterpretImageProperties(image_info,image,embed_text));
6237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6241 % T r a n s p a r e n t I m a g e %
6245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6247 % TransparentImage() changes the opacity value associated with any pixel
6248 % that matches color to the value defined by opacity.
6250 % By default color must match a particular pixel color exactly. However,
6251 % in many cases two colors may differ by a small amount. Fuzz defines
6252 % how much tolerance is acceptable to consider two colors as the same.
6253 % For example, set fuzz to 10 and the color red at intensities of 100 and
6254 % 102 respectively are now interpreted as the same color.
6256 % The format of the TransparentImage method is:
6258 % MagickBooleanType TransparentImage(Image *image,
6259 % const PixelPacket target,const Quantum opacity)
6261 % A description of each parameter follows:
6263 % o image: the image.
6265 % o target: the RGB value of the target color.
6267 % o opacity: the replacement opacity value.
6270 MagickExport MagickBooleanType TransparentImage(Image *image,
6271 const PixelPacket target,const Quantum opacity)
6273 #define TransparentImageTag "Transparent/Image"
6282 Make image color transparent.
6284 assert(image != (Image *) NULL);
6285 assert(image->signature == MagickSignature);
6286 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.1.0");
6287 if (image->debug != MagickFalse)
6288 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6289 if (image->matte == MagickFalse)
6290 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
6291 for (y=0; y < (long) image->rows; y++)
6296 register PixelPacket
6299 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6300 if (q == (PixelPacket *) NULL)
6302 for (x=0; x < (long) image->columns; x++)
6304 if (IsColorSimilar(image,q,&target) != MagickFalse)
6308 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
6310 proceed=SetImageProgress(image,TransparentImageTag,y,image->rows);
6311 if (proceed == MagickFalse)
6318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6322 % U n s h i f t I m a g e L i s t %
6326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6328 % UnshiftImageList() adds the image to the beginning of the list.
6330 % The format of the UnshiftImageList method is:
6332 % unsigned int UnshiftImageList(Image *images,const Image *image,
6333 % ExceptionInfo *exception)
6335 % A description of each parameter follows:
6337 % o images: the image list.
6339 % o image: the image.
6341 % o exception: return any errors or warnings in this structure.
6344 MagickExport unsigned int UnshiftImageList(Image **images,const Image *image,
6345 ExceptionInfo *exception)
6347 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
6348 PrependImageToList(images,CloneImageList(image,exception));
6353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6357 + V a l i d a t e C o l o r m a p I n d e x %
6361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6363 % ValidateColormapIndex() validates the colormap index. If the index does
6364 % not range from 0 to the number of colors in the colormap an exception
6365 % issued and 0 is returned.
6367 % The format of the ValidateColormapIndex method is:
6369 % IndexPacket ValidateColormapIndex(Image *image,const unsigned int index)
6371 % A description of each parameter follows:
6373 % o index: Method ValidateColormapIndex returns colormap index if it is
6374 % valid other an exception issued and 0 is returned.
6376 % o image: the image.
6378 % o index: This integer is the colormap index.
6382 MagickExport IndexPacket ValidateColormapIndex(Image *image,
6383 const unsigned long index)
6385 if (image->debug != MagickFalse)
6386 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.4");
6387 return(ConstrainColormapIndex(image,index));