2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % DDDD EEEEE PPPP RRRR EEEEE CCCC AAA TTTTT EEEEE %
7 % D D E P P R R E C A A T E %
8 % D D EEE PPPPP RRRR EEE C AAAAA T EEE %
9 % D D E P R R E C A A T E %
10 % DDDD EEEEE P R R EEEEE CCCC A A T EEEEE %
13 % MagickCore Deprecated Methods %
20 % Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "magick/studio.h"
44 #include "magick/property.h"
45 #include "magick/blob.h"
46 #include "magick/blob-private.h"
47 #include "magick/cache.h"
48 #include "magick/cache-view.h"
49 #include "magick/client.h"
50 #include "magick/color.h"
51 #include "magick/color-private.h"
52 #include "magick/colormap.h"
53 #include "magick/colormap-private.h"
54 #include "magick/colorspace.h"
55 #include "magick/composite.h"
56 #include "magick/composite-private.h"
57 #include "magick/constitute.h"
58 #include "magick/deprecate.h"
59 #include "magick/draw.h"
60 #include "magick/draw-private.h"
61 #include "magick/effect.h"
62 #include "magick/enhance.h"
63 #include "magick/exception.h"
64 #include "magick/exception-private.h"
65 #include "magick/fx.h"
66 #include "magick/geometry.h"
67 #include "magick/identify.h"
68 #include "magick/image.h"
69 #include "magick/image-private.h"
70 #include "magick/list.h"
71 #include "magick/log.h"
72 #include "magick/memory_.h"
73 #include "magick/magick.h"
74 #include "magick/monitor.h"
75 #include "magick/monitor-private.h"
76 #include "magick/morphology.h"
77 #include "magick/paint.h"
78 #include "magick/pixel.h"
79 #include "magick/pixel-private.h"
80 #include "magick/quantize.h"
81 #include "magick/random_.h"
82 #include "magick/resource_.h"
83 #include "magick/semaphore.h"
84 #include "magick/segment.h"
85 #include "magick/splay-tree.h"
86 #include "magick/statistic.h"
87 #include "magick/string_.h"
88 #include "magick/threshold.h"
89 #include "magick/transform.h"
90 #include "magick/utility.h"
92 #if !defined(MAGICKCORE_EXCLUDE_DEPRECATED)
97 monitor_handler = (MonitorHandler) NULL;
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 % A c q u i r e C a c h e V i e w I n d e x e s %
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 % AcquireCacheViewIndexes() returns the indexes associated with the specified
113 % Deprecated, replace with:
115 % GetCacheViewVirtualIndexQueue(cache_view);
117 % The format of the AcquireCacheViewIndexes method is:
119 % const IndexPacket *AcquireCacheViewIndexes(const CacheView *cache_view)
121 % A description of each parameter follows:
123 % o cache_view: the cache view.
126 MagickExport const IndexPacket *AcquireCacheViewIndexes(
127 const CacheView *cache_view)
129 return(GetCacheViewVirtualIndexQueue(cache_view));
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137 % A c q u i r e C a c h e V i e w P i x e l s %
141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
143 % AcquireCacheViewPixels() gets pixels from the in-memory or disk pixel cache
144 % as defined by the geometry parameters. A pointer to the pixels is returned
145 % if the pixels are transferred, otherwise a NULL is returned.
147 % Deprecated, replace with:
149 % GetCacheViewVirtualPixels(cache_view,x,y,columns,rows,exception);
151 % The format of the AcquireCacheViewPixels method is:
153 % const PixelPacket *AcquireCacheViewPixels(const CacheView *cache_view,
154 % const ssize_t x,const ssize_t y,const size_t columns,
155 % const size_t rows,ExceptionInfo *exception)
157 % A description of each parameter follows:
159 % o cache_view: the cache view.
161 % o x,y,columns,rows: These values define the perimeter of a region of
164 % o exception: return any errors or warnings in this structure.
167 MagickExport const PixelPacket *AcquireCacheViewPixels(
168 const CacheView *cache_view,const ssize_t x,const ssize_t y,
169 const size_t columns,const size_t rows,ExceptionInfo *exception)
171 return(GetCacheViewVirtualPixels(cache_view,x,y,columns,rows,exception));
175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 % A c q u i r e I m a g e P i x e l s %
182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184 % AcquireImagePixels() returns an immutable pixel region. If the
185 % region is successfully accessed, a pointer to it is returned, otherwise
186 % NULL is returned. The returned pointer may point to a temporary working
187 % copy of the pixels or it may point to the original pixels in memory.
188 % Performance is maximized if the selected region is part of one row, or one
189 % or more full rows, since there is opportunity to access the pixels in-place
190 % (without a copy) if the image is in RAM, or in a memory-mapped file. The
191 % returned pointer should *never* be deallocated by the user.
193 % Pixels accessed via the returned pointer represent a simple array of type
194 % PixelPacket. If the image type is CMYK or the storage class is PseudoClass,
195 % call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to access
196 % the black color component or to obtain the colormap indexes (of type
197 % IndexPacket) corresponding to the region.
199 % If you plan to modify the pixels, use GetAuthenticPixels() instead.
201 % Note, the AcquireImagePixels() and GetAuthenticPixels() methods are not
202 % thread-safe. In a threaded environment, use GetCacheViewVirtualPixels() or
203 % GetCacheViewAuthenticPixels() instead.
205 % Deprecated, replace with:
207 % GetVirtualPixels(image,x,y,columns,rows,exception);
209 % The format of the AcquireImagePixels() method is:
211 % const PixelPacket *AcquireImagePixels(const Image *image,const ssize_t x,
212 % const ssize_t y,const size_t columns,const size_t rows,
213 % ExceptionInfo *exception)
215 % A description of each parameter follows:
217 % o image: the image.
219 % o x,y,columns,rows: These values define the perimeter of a region of
222 % o exception: return any errors or warnings in this structure.
225 MagickExport const PixelPacket *AcquireImagePixels(const Image *image,
226 const ssize_t x,const ssize_t y,const size_t columns,
227 const size_t rows,ExceptionInfo *exception)
229 return(GetVirtualPixels(image,x,y,columns,rows,exception));
233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 % A c q u i r e I n d e x e s %
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 % AcquireIndexes() returns the black channel or the colormap indexes
244 % associated with the last call to QueueAuthenticPixels() or
245 % GetVirtualPixels(). NULL is returned if the black channel or colormap
246 % indexes are not available.
248 % Deprecated, replace with:
250 % GetVirtualIndexQueue(image);
252 % The format of the AcquireIndexes() method is:
254 % const IndexPacket *AcquireIndexes(const Image *image)
256 % A description of each parameter follows:
258 % o indexes: AcquireIndexes() returns the indexes associated with the last
259 % call to QueueAuthenticPixels() or GetVirtualPixels().
261 % o image: the image.
264 MagickExport const IndexPacket *AcquireIndexes(const Image *image)
266 return(GetVirtualIndexQueue(image));
270 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274 % A c q u i r e M e m o r y %
278 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
280 % AcquireMemory() returns a pointer to a block of memory at least size bytes
281 % suitably aligned for any use.
283 % The format of the AcquireMemory method is:
285 % void *AcquireMemory(const size_t size)
287 % A description of each parameter follows:
289 % o size: the size of the memory in bytes to allocate.
292 MagickExport void *AcquireMemory(const size_t size)
298 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
299 allocation=malloc(size);
304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308 % A c q u i r e O n e C a c h e V i e w P i x e l %
312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
314 % AcquireOneCacheViewPixel() returns a single pixel at the specified (x,y)
315 % location. The image background color is returned if an error occurs. If
316 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
318 % Deprecated, replace with:
320 % GetOneCacheViewVirtualPixel(cache_view,x,y,pixel,exception);
322 % The format of the AcquireOneCacheViewPixel method is:
324 % MagickBooleanType AcquireOneCacheViewPixel(const CacheView *cache_view,
325 % const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
327 % A description of each parameter follows:
329 % o cache_view: the cache view.
331 % o x,y: These values define the offset of the pixel.
333 % o pixel: return a pixel at the specified (x,y) location.
335 % o exception: return any errors or warnings in this structure.
338 MagickExport MagickBooleanType AcquireOneCacheViewPixel(
339 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelPacket *pixel,
340 ExceptionInfo *exception)
342 return(GetOneCacheViewVirtualPixel(cache_view,x,y,pixel,exception));
346 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
350 % 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 %
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
356 % AcquireOneCacheViewVirtualPixel() returns a single pixel at the specified
357 % (x,y) location. The image background color is returned if an error occurs.
358 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
360 % Deprecated, replace with:
362 % GetOneCacheViewVirtualMethodPixel(cache_view,virtual_pixel_method,
363 % x,y,pixel,exception);
365 % The format of the AcquireOneCacheViewPixel method is:
367 % MagickBooleanType AcquireOneCacheViewVirtualPixel(
368 % const CacheView *cache_view,
369 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
370 % const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
372 % A description of each parameter follows:
374 % o cache_view: the cache view.
376 % o virtual_pixel_method: the virtual pixel method.
378 % o x,y: These values define the offset of the pixel.
380 % o pixel: return a pixel at the specified (x,y) location.
382 % o exception: return any errors or warnings in this structure.
385 MagickExport MagickBooleanType AcquireOneCacheViewVirtualPixel(
386 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
387 const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
392 status=GetOneCacheViewVirtualMethodPixel(cache_view,virtual_pixel_method,
393 x,y,pixel,exception);
398 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
402 % A c q u i r e O n e M a g i c k P i x e l %
406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
408 % AcquireOneMagickPixel() returns a single pixel at the specified (x,y)
409 % location. The image background color is returned if an error occurs. If
410 % you plan to modify the pixel, use GetOnePixel() instead.
412 % Deprecated, replace with:
414 % MagickPixelPacket pixel;
415 % GetOneVirtualMagickPixel(image,x,y,&pixel,exception);
417 % The format of the AcquireOneMagickPixel() method is:
419 % MagickPixelPacket AcquireOneMagickPixel(const Image image,const ssize_t x,
420 % const ssize_t y,ExceptionInfo exception)
422 % A description of each parameter follows:
424 % o image: the image.
426 % o x,y: These values define the location of the pixel to return.
428 % o exception: return any errors or warnings in this structure.
431 MagickExport MagickPixelPacket AcquireOneMagickPixel(const Image *image,
432 const ssize_t x,const ssize_t y,ExceptionInfo *exception)
437 (void) GetOneVirtualMagickPixel(image,x,y,&pixel,exception);
442 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
446 % A c q u i r e O n e P i x e l %
450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
452 % AcquireOnePixel() returns a single pixel at the specified (x,y) location.
453 % The image background color is returned if an error occurs. If you plan to
454 % modify the pixel, use GetOnePixel() instead.
456 % Deprecated, replace with:
459 % GetOneVirtualPixel(image,x,y,&pixel,exception);
461 % The format of the AcquireOnePixel() method is:
463 % PixelPacket AcquireOnePixel(const Image image,const ssize_t x,
464 % const ssize_t y,ExceptionInfo exception)
466 % A description of each parameter follows:
468 % o image: the image.
470 % o x,y: These values define the location of the pixel to return.
472 % o exception: return any errors or warnings in this structure.
475 MagickExport PixelPacket AcquireOnePixel(const Image *image,const ssize_t x,
476 const ssize_t y,ExceptionInfo *exception)
481 (void) GetOneVirtualPixel(image,x,y,&pixel,exception);
486 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
490 % A c q u i r e O n e V i r t u a l P i x e l %
494 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
496 % AcquireOneVirtualPixel() returns a single pixel at the specified (x,y)
497 % location as defined by specified pixel method. The image background color
498 % is returned if an error occurs. If you plan to modify the pixel, use
499 % GetOnePixel() instead.
501 % Deprecated, replace with:
504 % GetOneVirtualMethodPixel(image,virtual_pixel_method,x,y,&pixel,exception);
506 % The format of the AcquireOneVirtualPixel() method is:
508 % PixelPacket AcquireOneVirtualPixel(const Image image,
509 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
510 % const ssize_t y,ExceptionInfo exception)
512 % A description of each parameter follows:
514 % o virtual_pixel_method: the virtual pixel method.
516 % o image: the image.
518 % o x,y: These values define the location of the pixel to return.
520 % o exception: return any errors or warnings in this structure.
523 MagickExport PixelPacket AcquireOneVirtualPixel(const Image *image,
524 const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
525 ExceptionInfo *exception)
530 (void) GetOneVirtualMethodPixel(image,virtual_pixel_method,x,y,&pixel,
536 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
540 % A c q u i r e P i x e l s %
544 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
546 % AcquirePixels() returns the pixels associated with the last call to
547 % QueueAuthenticPixels() or GetVirtualPixels().
549 % Deprecated, replace with:
551 % GetVirtualPixelQueue(image);
553 % The format of the AcquirePixels() method is:
555 % const PixelPacket *AcquirePixels(const Image image)
557 % A description of each parameter follows:
559 % o image: the image.
562 MagickExport const PixelPacket *AcquirePixels(const Image *image)
564 return(GetVirtualPixelQueue(image));
568 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572 % A f f i n i t y I m a g e %
576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578 % AffinityImage() replaces the colors of an image with the closest color from
581 % Deprecated, replace with:
583 % RemapImage(quantize_info,image,affinity_image);
585 % The format of the AffinityImage method is:
587 % MagickBooleanType AffinityImage(const QuantizeInfo *quantize_info,
588 % Image *image,const Image *affinity_image)
590 % A description of each parameter follows:
592 % o quantize_info: Specifies a pointer to an QuantizeInfo structure.
594 % o image: the image.
596 % o affinity_image: the reference image.
599 MagickExport MagickBooleanType AffinityImage(const QuantizeInfo *quantize_info,
600 Image *image,const Image *affinity_image)
602 return(RemapImage(quantize_info,image,affinity_image));
606 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
610 % A f f i n i t y I m a g e s %
614 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
616 % AffinityImages() replaces the colors of a sequence of images with the
617 % closest color from a reference image.
619 % Deprecated, replace with:
621 % RemapImages(quantize_info,images,affinity_image);
623 % The format of the AffinityImage method is:
625 % MagickBooleanType AffinityImages(const QuantizeInfo *quantize_info,
626 % Image *images,Image *affinity_image)
628 % A description of each parameter follows:
630 % o quantize_info: Specifies a pointer to an QuantizeInfo structure.
632 % o images: the image sequence.
634 % o affinity_image: the reference image.
637 MagickExport MagickBooleanType AffinityImages(const QuantizeInfo *quantize_info,
638 Image *images,const Image *affinity_image)
640 return(RemapImages(quantize_info,images,affinity_image));
644 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
648 % A l l o c a t e I m a g e %
652 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
654 % AllocateImage() returns a pointer to an image structure initialized to
657 % Deprecated, replace with:
659 % AcquireImage(image_info);
661 % The format of the AllocateImage method is:
663 % Image *AllocateImage(const ImageInfo *image_info)
665 % A description of each parameter follows:
667 % o image_info: Many of the image default values are set from this
668 % structure. For example, filename, compression, depth, background color,
672 MagickExport Image *AllocateImage(const ImageInfo *image_info)
674 return(AcquireImage(image_info));
678 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
682 % A l l o c a t e I m a g e C o l o r m a p %
686 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
688 % AllocateImageColormap() allocates an image colormap and initializes
689 % it to a linear gray colorspace. If the image already has a colormap,
690 % it is replaced. AllocateImageColormap() returns MagickTrue if successful,
691 % otherwise MagickFalse if there is not enough memory.
693 % Deprecated, replace with:
695 % AcquireImageColormap(image,colors);
697 % The format of the AllocateImageColormap method is:
699 % MagickBooleanType AllocateImageColormap(Image *image,
700 % const size_t colors)
702 % A description of each parameter follows:
704 % o image: the image.
706 % o colors: the number of colors in the image colormap.
709 MagickExport MagickBooleanType AllocateImageColormap(Image *image,
712 return(AcquireImageColormap(image,colors));
716 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
720 % A l l o c a t e N e x t I m a g e %
724 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
726 % AllocateNextImage() initializes the next image in a sequence to
727 % default values. The next member of image points to the newly allocated
728 % image. If there is a memory shortage, next is assigned NULL.
730 % Deprecated, replace with:
732 % AcquireNextImage(image_info,image);
734 % The format of the AllocateNextImage method is:
736 % void AllocateNextImage(const ImageInfo *image_info,Image *image)
738 % A description of each parameter follows:
740 % o image_info: Many of the image default values are set from this
741 % structure. For example, filename, compression, depth, background color,
744 % o image: the image.
747 MagickExport void AllocateNextImage(const ImageInfo *image_info,Image *image)
749 AcquireNextImage(image_info,image);
753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
757 % A l l o c a t e S t r i n g %
761 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
763 % AllocateString() allocates memory for a string and copies the source string
764 % to that memory location (and returns it).
766 % The format of the AllocateString method is:
768 % char *AllocateString(const char *source)
770 % A description of each parameter follows:
772 % o source: A character string.
775 MagickExport char *AllocateString(const char *source)
783 assert(source != (const char *) NULL);
784 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
785 length=strlen(source)+MaxTextExtent+1;
786 destination=(char *) AcquireQuantumMemory(length,sizeof(*destination));
787 if (destination == (char *) NULL)
788 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
790 if (source != (char *) NULL)
791 (void) CopyMagickString(destination,source,length);
796 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
800 % A v e r a g e I m a g e s %
804 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
806 % AverageImages() takes a set of images and averages them together. Each
807 % image in the set must have the same width and height. AverageImages()
808 % returns a single image with each corresponding pixel component of each
809 % image averaged. On failure, a NULL image is returned and exception
810 % describes the reason for the failure.
812 % Deprecated, replace with:
814 % EvaluateImages(images,MeanEvaluateOperator,exception);
816 % The format of the AverageImages method is:
818 % Image *AverageImages(Image *images,ExceptionInfo *exception)
820 % A description of each parameter follows:
822 % o image: the image sequence.
824 % o exception: return any errors or warnings in this structure.
827 MagickExport Image *AverageImages(const Image *images,ExceptionInfo *exception)
829 return(EvaluateImages(images,MeanEvaluateOperator,exception));
833 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
837 % C h a n n e l I m a g e %
841 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
843 % Extract a channel from the image. A channel is a particular color component
844 % of each pixel in the image.
846 % Deprecated, replace with:
848 % SeparateImageChannel(image,channel);
850 % The format of the ChannelImage method is:
852 % unsigned int ChannelImage(Image *image,const ChannelType channel)
854 % A description of each parameter follows:
856 % o image: the image.
858 % o channel: Identify which channel to extract: RedChannel, GreenChannel,
859 % BlueChannel, OpacityChannel, CyanChannel, MagentaChannel, YellowChannel,
863 MagickExport unsigned int ChannelImage(Image *image,const ChannelType channel)
865 return(SeparateImageChannel(image,channel));
869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
873 % C h a n n e l T h r e s h o l d I m a g e %
877 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
879 % ChannelThresholdImage() changes the value of individual pixels based on
880 % the intensity of each pixel channel. The result is a high-contrast image.
882 % The format of the ChannelThresholdImage method is:
884 % unsigned int ChannelThresholdImage(Image *image,const char *level)
886 % A description of each parameter follows:
888 % o image: the image.
890 % o level: define the threshold values.
893 MagickExport unsigned int ChannelThresholdImage(Image *image,const char *level)
905 assert(image != (Image *) NULL);
906 assert(image->signature == MagickSignature);
907 if (image->debug != MagickFalse)
908 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
909 if (image->debug != MagickFalse)
910 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
911 if (level == (char *) NULL)
913 flags=ParseGeometry(level,&geometry_info);
914 threshold.red=geometry_info.rho;
915 threshold.green=geometry_info.sigma;
916 if ((flags & SigmaValue) == 0)
917 threshold.green=threshold.red;
918 threshold.blue=geometry_info.xi;
919 if ((flags & XiValue) == 0)
920 threshold.blue=threshold.red;
921 status=BilevelImageChannel(image,RedChannel,threshold.red);
922 status|=BilevelImageChannel(image,GreenChannel,threshold.green);
923 status|=BilevelImageChannel(image,BlueChannel,threshold.blue);
928 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
932 % C l i p I m a g e P a t h %
936 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
938 % ClipPathImage() sets the image clip mask based any clipping path information
941 % Deprecated, replace with:
943 % ClipImagePath(image,pathname,inside);
945 % The format of the ClipImage method is:
947 % MagickBooleanType ClipPathImage(Image *image,const char *pathname,
948 % const MagickBooleanType inside)
950 % A description of each parameter follows:
952 % o image: the image.
954 % o pathname: name of clipping path resource. If name is preceded by #, use
955 % clipping path numbered by name.
957 % o inside: if non-zero, later operations take effect inside clipping path.
958 % Otherwise later operations take effect outside clipping path.
961 MagickExport MagickBooleanType ClipPathImage(Image *image,const char *pathname,
962 const MagickBooleanType inside)
964 return(ClipImagePath(image,pathname,inside));
968 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
972 % C l o n e I m a g e A t t r i b u t e s %
976 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
978 % CloneImageAttributes() clones one or more image attributes.
980 % Deprecated, replace with:
982 % CloneImageProperties(image,clone_image);
984 % The format of the CloneImageAttributes method is:
986 % MagickBooleanType CloneImageAttributes(Image *image,
987 % const Image *clone_image)
989 % A description of each parameter follows:
991 % o image: the image.
993 % o clone_image: the clone image.
996 MagickExport MagickBooleanType CloneImageAttributes(Image *image,
997 const Image *clone_image)
999 return(CloneImageProperties(image,clone_image));
1003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007 % C l o n e M e m o r y %
1011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1013 % CloneMemory() copies size bytes from memory area source to the destination.
1014 % Copying between objects that overlap will take place correctly. It returns
1017 % The format of the CloneMemory method is:
1019 % void *CloneMemory(void *destination,const void *source,
1020 % const size_t size)
1022 % A description of each parameter follows:
1024 % o destination: the destination.
1026 % o source: the source.
1028 % o size: the size of the memory in bytes to allocate.
1031 MagickExport void *CloneMemory(void *destination,const void *source,
1034 register const unsigned char
1037 register unsigned char
1043 assert(destination != (void *) NULL);
1044 assert(source != (const void *) NULL);
1045 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
1046 p=(const unsigned char *) source;
1047 q=(unsigned char *) destination;
1048 if ((p <= q) || ((p+size) >= q))
1049 return(CopyMagickMemory(destination,source,size));
1051 Overlap, copy backwards.
1055 for (i=(ssize_t) (size-1); i >= 0; i--)
1057 return(destination);
1061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1065 % C l o s e C a c h e V i e w %
1069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1071 % CloseCacheView() closes the specified view returned by a previous call to
1074 % Deprecated, replace with:
1076 % DestroyCacheView(view_info);
1078 % The format of the CloseCacheView method is:
1080 % CacheView *CloseCacheView(CacheView *view_info)
1082 % A description of each parameter follows:
1084 % o view_info: the address of a structure of type CacheView.
1087 MagickExport CacheView *CloseCacheView(CacheView *view_info)
1089 return(DestroyCacheView(view_info));
1093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1097 % C o l o r F l o o d f i l l I m a g e %
1101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1103 % ColorFloodfill() changes the color value of any pixel that matches
1104 % target and is an immediate neighbor. If the method FillToBorderMethod is
1105 % specified, the color value is changed for any neighbor pixel that does not
1106 % match the bordercolor member of image.
1108 % By default target must match a particular pixel color exactly.
1109 % However, in many cases two colors may differ by a small amount. The
1110 % fuzz member of image defines how much tolerance is acceptable to
1111 % consider two colors as the same. For example, set fuzz to 10 and the
1112 % color red at intensities of 100 and 102 respectively are now
1113 % interpreted as the same color for the purposes of the floodfill.
1115 % The format of the ColorFloodfillImage method is:
1117 % MagickBooleanType ColorFloodfillImage(Image *image,
1118 % const DrawInfo *draw_info,const PixelPacket target,
1119 % const ssize_t x_offset,const ssize_t y_offset,const PaintMethod method)
1121 % A description of each parameter follows:
1123 % o image: the image.
1125 % o draw_info: the draw info.
1127 % o target: the RGB value of the target color.
1129 % o x,y: the starting location of the operation.
1131 % o method: Choose either FloodfillMethod or FillToBorderMethod.
1135 #define MaxStacksize (1UL << 15)
1136 #define PushSegmentStack(up,left,right,delta) \
1138 if (s >= (segment_stack+MaxStacksize)) \
1139 ThrowBinaryException(DrawError,"SegmentStackOverflow",image->filename) \
1142 if ((((up)+(delta)) >= 0) && (((up)+(delta)) < (ssize_t) image->rows)) \
1144 s->x1=(double) (left); \
1145 s->y1=(double) (up); \
1146 s->x2=(double) (right); \
1147 s->y2=(double) (delta); \
1153 MagickExport MagickBooleanType ColorFloodfillImage(Image *image,
1154 const DrawInfo *draw_info,const PixelPacket target,const ssize_t x_offset,
1155 const ssize_t y_offset,const PaintMethod method)
1174 register SegmentInfo
1181 Check boundary conditions.
1183 assert(image != (Image *) NULL);
1184 assert(image->signature == MagickSignature);
1185 if (image->debug != MagickFalse)
1186 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1187 assert(draw_info != (DrawInfo *) NULL);
1188 assert(draw_info->signature == MagickSignature);
1189 if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
1190 return(MagickFalse);
1191 if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
1192 return(MagickFalse);
1193 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1194 return(MagickFalse);
1195 if (image->matte == MagickFalse)
1196 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
1197 floodplane_image=CloneImage(image,image->columns,image->rows,MagickTrue,
1199 if (floodplane_image == (Image *) NULL)
1200 return(MagickFalse);
1201 (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel);
1203 Set floodfill color.
1205 segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
1206 sizeof(*segment_stack));
1207 if (segment_stack == (SegmentInfo *) NULL)
1209 floodplane_image=DestroyImage(floodplane_image);
1210 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
1214 Push initial segment on stack.
1220 PushSegmentStack(y,x,x,1);
1221 PushSegmentStack(y+1,x,x,-1);
1222 while (s > segment_stack)
1224 register const PixelPacket
1230 register PixelPacket
1234 Pop segment off stack.
1239 offset=(ssize_t) s->y2;
1240 y=(ssize_t) s->y1+offset;
1242 Recolor neighboring pixels.
1244 p=GetVirtualPixels(image,0,y,(size_t) (x1+1),1,&image->exception);
1245 q=GetAuthenticPixels(floodplane_image,0,y,(size_t) (x1+1),1,
1247 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
1251 for (x=x1; x >= 0; x--)
1253 if (q->opacity == (Quantum) TransparentOpacity)
1255 if (method == FloodfillMethod)
1257 if (IsColorSimilar(image,p,&target) == MagickFalse)
1261 if (IsColorSimilar(image,p,&target) != MagickFalse)
1263 q->opacity=(Quantum) TransparentOpacity;
1267 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
1269 skip=x >= x1 ? MagickTrue : MagickFalse;
1270 if (skip == MagickFalse)
1274 PushSegmentStack(y,start,x1-1,-offset);
1279 if (skip == MagickFalse)
1281 if (x < (ssize_t) image->columns)
1283 p=GetVirtualPixels(image,x,y,image->columns-x,1,
1285 q=GetAuthenticPixels(floodplane_image,x,y,image->columns-x,1,
1287 if ((p == (const PixelPacket *) NULL) ||
1288 (q == (PixelPacket *) NULL))
1290 for ( ; x < (ssize_t) image->columns; x++)
1292 if (q->opacity == (Quantum) TransparentOpacity)
1294 if (method == FloodfillMethod)
1296 if (IsColorSimilar(image,p,&target) == MagickFalse)
1300 if (IsColorSimilar(image,p,&target) != MagickFalse)
1302 q->opacity=(Quantum) TransparentOpacity;
1306 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
1309 PushSegmentStack(y,start,x-1,offset);
1311 PushSegmentStack(y,x2+1,x-1,-offset);
1317 p=GetVirtualPixels(image,x,y,(size_t) (x2-x+1),1,
1319 q=GetAuthenticPixels(floodplane_image,x,y,(size_t) (x2-x+1),1,
1321 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
1323 for ( ; x <= x2; x++)
1325 if (q->opacity == (Quantum) TransparentOpacity)
1327 if (method == FloodfillMethod)
1329 if (IsColorSimilar(image,p,&target) != MagickFalse)
1333 if (IsColorSimilar(image,p,&target) == MagickFalse)
1342 for (y=0; y < (ssize_t) image->rows; y++)
1344 register const PixelPacket
1350 register PixelPacket
1354 Tile fill color onto floodplane.
1356 p=GetVirtualPixels(floodplane_image,0,y,image->columns,1,
1358 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
1359 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
1361 for (x=0; x < (ssize_t) image->columns; x++)
1363 if (p->opacity != OpaqueOpacity)
1365 (void) GetFillColor(draw_info,x,y,&fill_color);
1366 MagickCompositeOver(&fill_color,(MagickRealType) fill_color.opacity,q,
1367 (MagickRealType) q->opacity,q);
1372 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
1375 segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
1376 floodplane_image=DestroyImage(floodplane_image);
1377 return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
1381 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1385 % D e l e t e I m a g e A t t r i b u t e %
1389 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1391 % DeleteImageAttribute() deletes an attribute from the image.
1393 % Deprecated, replace with:
1395 % DeleteImageProperty(image,key);
1397 % The format of the DeleteImageAttribute method is:
1399 % MagickBooleanType DeleteImageAttribute(Image *image,const char *key)
1401 % A description of each parameter follows:
1403 % o image: the image info.
1405 % o key: the image key.
1408 MagickExport MagickBooleanType DeleteImageAttribute(Image *image,
1411 return(DeleteImageProperty(image,key));
1415 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1419 % D e l e t e I m a g e L i s t %
1423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1425 % DeleteImageList() deletes an image at the specified position in the list.
1427 % The format of the DeleteImageList method is:
1429 % unsigned int DeleteImageList(Image *images,const ssize_t offset)
1431 % A description of each parameter follows:
1433 % o images: the image list.
1435 % o offset: the position within the list.
1438 MagickExport unsigned int DeleteImageList(Image *images,const ssize_t offset)
1443 if (images->debug != MagickFalse)
1444 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
1445 while (GetPreviousImageInList(images) != (Image *) NULL)
1446 images=GetPreviousImageInList(images);
1447 for (i=0; i < offset; i++)
1449 if (GetNextImageInList(images) == (Image *) NULL)
1450 return(MagickFalse);
1451 images=GetNextImageInList(images);
1453 DeleteImageFromList(&images);
1458 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1462 % D e l e t e M a g i c k R e g i s t r y %
1466 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1468 % DeleteMagickRegistry() deletes an entry in the registry as defined by the id.
1469 % It returns MagickTrue if the entry is deleted otherwise MagickFalse if no
1470 % entry is found in the registry that matches the id.
1472 % Deprecated, replace with:
1474 % char key[MaxTextExtent];
1475 % FormatMagickString(key,MaxTextExtent,"%ld\n",id);
1476 % DeleteImageRegistry(key);
1478 % The format of the DeleteMagickRegistry method is:
1480 % MagickBooleanType DeleteMagickRegistry(const ssize_t id)
1482 % A description of each parameter follows:
1484 % o id: the registry id.
1487 MagickExport MagickBooleanType DeleteMagickRegistry(const ssize_t id)
1492 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",(long) id);
1493 return(DeleteImageRegistry(key));
1497 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1501 + D e s t r o y M a g i c k R e g i s t r y %
1505 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1507 % DestroyMagickRegistry() deallocates memory associated the magick registry.
1509 % Deprecated, replace with:
1511 % RegistryComponentTerminus();
1513 % The format of the DestroyMagickRegistry method is:
1515 % void DestroyMagickRegistry(void)
1518 MagickExport void DestroyMagickRegistry(void)
1520 RegistryComponentTerminus();
1524 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1528 % D e s c r i b e I m a g e %
1532 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1534 % DescribeImage() describes an image by printing its attributes to the file.
1535 % Attributes include the image width, height, size, and others.
1537 % Deprecated, replace with:
1539 % IdentifyImage(image,file,verbose);
1541 % The format of the DescribeImage method is:
1543 % MagickBooleanType DescribeImage(Image *image,FILE *file,
1544 % const MagickBooleanType verbose)
1546 % A description of each parameter follows:
1548 % o image: the image.
1550 % o file: the file, typically stdout.
1552 % o verbose: A value other than zero prints more detailed information
1556 MagickExport MagickBooleanType DescribeImage(Image *image,FILE *file,
1557 const MagickBooleanType verbose)
1559 return(IdentifyImage(image,file,verbose));
1563 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1567 % D e s t r o y I m a g e A t t r i b u t e s %
1571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1573 % DestroyImageAttributes() deallocates memory associated with the image
1576 % The format of the DestroyImageAttributes method is:
1578 % DestroyImageAttributes(Image *image)
1580 % A description of each parameter follows:
1582 % o image: the image.
1585 MagickExport void DestroyImageAttributes(Image *image)
1587 assert(image != (Image *) NULL);
1588 assert(image->signature == MagickSignature);
1589 if (image->debug != MagickFalse)
1590 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1591 if (image->attributes != (void *) NULL)
1592 image->attributes=(void *) DestroySplayTree((SplayTreeInfo *)
1597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1601 % D e s t r o y I m a g e s %
1605 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1607 % DestroyImages() destroys an image list.
1609 % Deprecated, replace with:
1611 % DestroyImageList(image);
1613 % The format of the DestroyImages method is:
1615 % void DestroyImages(Image *image)
1617 % A description of each parameter follows:
1619 % o image: the image sequence.
1622 MagickExport void DestroyImages(Image *image)
1624 if (image == (Image *) NULL)
1626 if (image->debug != MagickFalse)
1627 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.3");
1628 image=DestroyImageList(image);
1632 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1636 % D e s t r o y M a g i c k %
1640 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1642 % DestroyMagick() destroys the ImageMagick environment.
1644 % Deprecated, replace with:
1646 % MagickCoreTerminus();
1648 % The format of the DestroyMagick function is:
1650 % DestroyMagick(void)
1653 MagickExport void DestroyMagick(void)
1655 MagickCoreTerminus();
1659 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1663 % D i s p a t c h I m a g e %
1667 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1669 % DispatchImage() extracts pixel data from an image and returns it to you.
1670 % The method returns MagickFalse on success otherwise MagickTrue if an error is
1671 % encountered. The data is returned as char, short int, int, ssize_t, float,
1672 % or double in the order specified by map.
1674 % Suppose you want to extract the first scanline of a 640x480 image as
1675 % character data in red-green-blue order:
1677 % DispatchImage(image,0,0,640,1,"RGB",CharPixel,pixels,exception);
1679 % Deprecated, replace with:
1681 % ExportImagePixels(image,x_offset,y_offset,columns,rows,map,type,pixels,
1684 % The format of the DispatchImage method is:
1686 % unsigned int DispatchImage(const Image *image,const ssize_t x_offset,
1687 % const ssize_t y_offset,const size_t columns,
1688 % const size_t rows,const char *map,const StorageType type,
1689 % void *pixels,ExceptionInfo *exception)
1691 % A description of each parameter follows:
1693 % o image: the image.
1695 % o x_offset, y_offset, columns, rows: These values define the perimeter
1696 % of a region of pixels you want to extract.
1698 % o map: This string reflects the expected ordering of the pixel array.
1699 % It can be any combination or order of R = red, G = green, B = blue,
1700 % A = alpha, C = cyan, Y = yellow, M = magenta, K = black, or
1701 % I = intensity (for grayscale).
1703 % o type: Define the data type of the pixels. Float and double types are
1704 % normalized to [0..1] otherwise [0..QuantumRange]. Choose from these
1705 % types: CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel, or
1708 % o pixels: This array of values contain the pixel components as defined by
1709 % map and type. You must preallocate this array where the expected
1710 % length varies depending on the values of width, height, map, and type.
1712 % o exception: return any errors or warnings in this structure.
1715 MagickExport unsigned int DispatchImage(const Image *image,const ssize_t x_offset,
1716 const ssize_t y_offset,const size_t columns,const size_t rows,
1717 const char *map,const StorageType type,void *pixels,ExceptionInfo *exception)
1722 if (image->debug != MagickFalse)
1723 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
1724 status=ExportImagePixels(image,x_offset,y_offset,columns,rows,map,type,pixels,
1730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1734 % E x t r a c t S u b i m a g e F r o m I m a g e %
1738 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1740 % ExtractSubimageFromImageImage() extracts a region of the image that most
1741 % closely resembles the reference.
1743 % The format of the ExtractSubimageFromImageImage method is:
1745 % Image *ExtractSubimageFromImage(const Image *image,
1746 % const Image *reference,ExceptionInfo *exception)
1748 % A description of each parameter follows:
1750 % o image: the image.
1752 % o reference: find an area of the image that closely resembles this image.
1754 % o exception: return any errors or warnings in this structure.
1758 static double GetSimilarityMetric(const Image *image,const Image *reference,
1759 const ssize_t x_offset,const ssize_t y_offset,const double similarity_threshold,
1760 ExceptionInfo *exception)
1771 normalized_similarity,
1775 Compute the similarity in pixels between two images.
1777 normalized_similarity=1.0;
1780 if ((image->matte != MagickFalse) && (reference->matte != MagickFalse))
1782 if ((image->colorspace == CMYKColorspace) &&
1783 (reference->colorspace == CMYKColorspace))
1785 image_view=AcquireCacheView(image);
1786 reference_view=AcquireCacheView(reference);
1787 for (y=0; y < (ssize_t) reference->rows; y++)
1789 register const IndexPacket
1793 register const PixelPacket
1800 p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset+y,
1801 reference->columns,1,exception);
1802 q=GetCacheViewVirtualPixels(reference_view,0,y,reference->columns,1,
1804 if ((p == (const PixelPacket *) NULL) || (q == (const PixelPacket *) NULL))
1806 indexes=GetCacheViewVirtualIndexQueue(image_view);
1807 reference_indexes=GetCacheViewVirtualIndexQueue(reference_view);
1808 for (x=0; x < (ssize_t) reference->columns; x++)
1813 pixel=QuantumScale*(p->red-(double) q->red);
1814 similarity+=pixel*pixel;
1815 pixel=QuantumScale*(p->green-(double) q->green);
1816 similarity+=pixel*pixel;
1817 pixel=QuantumScale*(p->blue-(double) q->blue);
1818 similarity+=pixel*pixel;
1819 if ((image->matte != MagickFalse) && (reference->matte != MagickFalse))
1821 pixel=QuantumScale*(p->opacity-(double) q->opacity);
1822 similarity+=pixel*pixel;
1824 if ((image->colorspace == CMYKColorspace) &&
1825 (reference->colorspace == CMYKColorspace))
1827 pixel=QuantumScale*(indexes[x]-(double) reference_indexes[x]);
1828 similarity+=pixel*pixel;
1833 normalized_similarity=sqrt(similarity)/reference->columns/reference->rows/
1835 if (normalized_similarity > similarity_threshold)
1838 reference_view=DestroyCacheView(reference_view);
1839 image_view=DestroyCacheView(image_view);
1840 return(normalized_similarity);
1843 MagickExport Image *ExtractSubimageFromImage(Image *image,
1844 const Image *reference,ExceptionInfo *exception)
1850 similarity_threshold;
1856 Extract reference from image.
1858 if ((reference->columns > image->columns) || (reference->rows > image->rows))
1859 return((Image *) NULL);
1860 similarity_threshold=(double) image->columns*image->rows;
1861 SetGeometry(reference,&offset);
1862 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1863 #pragma omp parallel for schedule(dynamic,4)
1865 for (y=0; y < (ssize_t) (image->rows-reference->rows); y++)
1873 for (x=0; x < (ssize_t) (image->columns-reference->columns); x++)
1875 similarity=GetSimilarityMetric(image,reference,x,y,similarity_threshold,
1877 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1878 #pragma omp critical (MagickCore_ExtractSubimageFromImage)
1880 if (similarity < similarity_threshold)
1882 similarity_threshold=similarity;
1888 if (similarity_threshold > (QuantumScale*reference->fuzz/100.0))
1889 return((Image *) NULL);
1890 return(CropImage(image,&offset,exception));
1894 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1898 % F l a t t e n I m a g e %
1902 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1904 % FlattenImages() Obsolete Function: Use MergeImageLayers() instead.
1906 % Deprecated, replace with:
1908 % MergeImageLayers(image,FlattenLayer,exception);
1910 % The format of the FlattenImage method is:
1912 % Image *FlattenImage(Image *image,ExceptionInfo *exception)
1914 % A description of each parameter follows:
1916 % o image: the image sequence.
1918 % o exception: return any errors or warnings in this structure.
1921 MagickExport Image *FlattenImages(Image *image,ExceptionInfo *exception)
1923 return(MergeImageLayers(image,FlattenLayer,exception));
1927 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1931 % F o r m a t I m a g e A t t r i b u t e %
1935 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1937 % FormatImageAttribute() permits formatted key/value pairs to be saved as an
1940 % The format of the FormatImageAttribute method is:
1942 % MagickBooleanType FormatImageAttribute(Image *image,const char *key,
1943 % const char *format,...)
1945 % A description of each parameter follows.
1947 % o image: The image.
1949 % o key: The attribute key.
1951 % o format: A string describing the format to use to write the remaining
1956 MagickExport MagickBooleanType FormatImageAttributeList(Image *image,
1957 const char *key,const char *format,va_list operands)
1960 value[MaxTextExtent];
1965 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
1966 n=vsnprintf(value,MaxTextExtent,format,operands);
1968 n=vsprintf(value,format,operands);
1971 value[MaxTextExtent-1]='\0';
1972 return(SetImageProperty(image,key,value));
1975 MagickExport MagickBooleanType FormatImageAttribute(Image *image,
1976 const char *key,const char *format,...)
1984 va_start(operands,format);
1985 status=FormatImagePropertyList(image,key,format,operands);
1991 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1995 % F o r m a t S t r i n g %
1999 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2001 % FormatString() prints formatted output of a variable argument list.
2003 % The format of the FormatString method is:
2005 % void FormatString(char *string,const char *format,...)
2007 % A description of each parameter follows.
2009 % o string: Method FormatString returns the formatted string in this
2012 % o format: A string describing the format to use to write the remaining
2017 MagickExport void FormatStringList(char *string,const char *format,
2023 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
2024 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
2025 n=vsnprintf(string,MaxTextExtent,format,operands);
2027 n=vsprintf(string,format,operands);
2030 string[MaxTextExtent-1]='\0';
2033 MagickExport void FormatString(char *string,const char *format,...)
2038 va_start(operands,format);
2039 (void) FormatMagickStringList(string,MaxTextExtent,format,operands);
2045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2049 + F u z z y C o l o r M a t c h %
2053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2055 % FuzzyColorMatch() returns true if two pixels are identical in color.
2057 % The format of the ColorMatch method is:
2059 % void FuzzyColorMatch(const PixelPacket *p,const PixelPacket *q,
2060 % const double fuzz)
2062 % A description of each parameter follows:
2068 % o distance: Define how much tolerance is acceptable to consider
2069 % two colors as the same.
2072 MagickExport unsigned int FuzzyColorMatch(const PixelPacket *p,
2073 const PixelPacket *q,const double fuzz)
2078 register MagickRealType
2081 if ((fuzz == 0.0) && (p->red == q->red) && (p->green == q->green) &&
2082 (p->blue == q->blue))
2084 pixel.red=p->red-(MagickRealType) q->red;
2085 distance=pixel.red*pixel.red;
2086 if (distance > (fuzz*fuzz))
2087 return(MagickFalse);
2088 pixel.green=p->green-(MagickRealType) q->green;
2089 distance+=pixel.green*pixel.green;
2090 if (distance > (fuzz*fuzz))
2091 return(MagickFalse);
2092 pixel.blue=p->blue-(MagickRealType) q->blue;
2093 distance+=pixel.blue*pixel.blue;
2094 if (distance > (fuzz*fuzz))
2095 return(MagickFalse);
2100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2104 + F u z z y C o l o r C o m p a r e %
2108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2110 % FuzzyColorCompare() returns MagickTrue if the distance between two colors is
2111 % less than the specified distance in a linear three dimensional color space.
2112 % This method is used by ColorFloodFill() and other algorithms which
2113 % compare two colors.
2115 % The format of the FuzzyColorCompare method is:
2117 % void FuzzyColorCompare(const Image *image,const PixelPacket *p,
2118 % const PixelPacket *q)
2120 % A description of each parameter follows:
2122 % o image: the image.
2129 MagickExport MagickBooleanType FuzzyColorCompare(const Image *image,
2130 const PixelPacket *p,const PixelPacket *q)
2132 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.5");
2133 return(IsColorSimilar(image,p,q));
2137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2141 + F u z z y O p a c i t y C o m p a r e %
2145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2147 % FuzzyOpacityCompare() returns true if the distance between two opacity
2148 % values is less than the specified distance in a linear color space. This
2149 % method is used by MatteFloodFill() and other algorithms which compare
2150 % two opacity values.
2152 % Deprecated, replace with:
2154 % IsOpacitySimilar(image,p,q);
2156 % The format of the FuzzyOpacityCompare method is:
2158 % void FuzzyOpacityCompare(const Image *image,const PixelPacket *p,
2159 % const PixelPacket *q)
2161 % A description of each parameter follows:
2163 % o image: the image.
2170 MagickExport MagickBooleanType FuzzyOpacityCompare(const Image *image,
2171 const PixelPacket *p,const PixelPacket *q)
2173 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.5");
2174 return(IsOpacitySimilar(image,p,q));
2178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2182 % G e t C o n f i g u r e B l o b %
2186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2188 % GetConfigureBlob() returns the specified configure file as a blob.
2190 % The format of the GetConfigureBlob method is:
2192 % void *GetConfigureBlob(const char *filename,ExceptionInfo *exception)
2194 % A description of each parameter follows:
2196 % o filename: the configure file name.
2198 % o path: return the full path information of the configure file.
2200 % o length: This pointer to a size_t integer sets the initial length of the
2201 % blob. On return, it reflects the actual length of the blob.
2203 % o exception: return any errors or warnings in this structure.
2206 MagickExport void *GetConfigureBlob(const char *filename,char *path,
2207 size_t *length,ExceptionInfo *exception)
2212 assert(filename != (const char *) NULL);
2213 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
2214 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
2215 assert(path != (char *) NULL);
2216 assert(length != (size_t *) NULL);
2217 assert(exception != (ExceptionInfo *) NULL);
2219 (void) CopyMagickString(path,filename,MaxTextExtent);
2220 #if defined(MAGICKCORE_INSTALLED_SUPPORT)
2221 #if defined(MAGICKCORE_LIBRARY_PATH)
2222 if (blob == (void *) NULL)
2225 Search hard coded paths.
2227 (void) FormatMagickString(path,MaxTextExtent,"%s%s",
2228 MAGICKCORE_LIBRARY_PATH,filename);
2229 if (IsPathAccessible(path) != MagickFalse)
2230 blob=FileToBlob(path,~0,length,exception);
2233 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !(defined(MAGICKCORE_CONFIGURE_PATH) || defined(MAGICKCORE_SHARE_CONFIGURE_PATH))
2234 if (blob == (void *) NULL)
2240 Locate file via registry key.
2242 key_value=NTRegistryKeyLookup("ConfigurePath");
2243 if (key_value != (char *) NULL)
2245 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",key_value,
2246 DirectorySeparator,filename);
2247 if (IsPathAccessible(path) != MagickFalse)
2248 blob=FileToBlob(path,~0,length,exception);
2253 if (blob == (void *) NULL)
2258 home=GetEnvironmentValue("MAGICK_HOME");
2259 if (home != (char *) NULL)
2264 #if !defined(MAGICKCORE_POSIX_SUPPORT)
2265 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",home,
2266 DirectorySeparator,filename);
2268 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/%s",home,
2269 MAGICKCORE_LIBRARY_RELATIVE_PATH,filename);
2271 if (IsPathAccessible(path) != MagickFalse)
2272 blob=FileToBlob(path,~0,length,exception);
2273 home=DestroyString(home);
2275 home=GetEnvironmentValue("HOME");
2276 if (home == (char *) NULL)
2277 home=GetEnvironmentValue("USERPROFILE");
2278 if (home != (char *) NULL)
2281 Search $HOME/.magick.
2283 (void) FormatMagickString(path,MaxTextExtent,"%s%s.magick%s%s",home,
2284 DirectorySeparator,DirectorySeparator,filename);
2285 if ((IsPathAccessible(path) != MagickFalse) && (blob == (void *) NULL))
2286 blob=FileToBlob(path,~0,length,exception);
2287 home=DestroyString(home);
2290 if ((blob == (void *) NULL) && (*GetClientPath() != '\0'))
2292 #if !defined(MAGICKCORE_POSIX_SUPPORT)
2293 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",GetClientPath(),
2294 DirectorySeparator,filename);
2297 prefix[MaxTextExtent];
2300 Search based on executable directory if directory is known.
2302 (void) CopyMagickString(prefix,GetClientPath(),
2304 ChopPathComponents(prefix,1);
2305 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/%s",prefix,
2306 MAGICKCORE_LIBRARY_RELATIVE_PATH,filename);
2308 if (IsPathAccessible(path) != MagickFalse)
2309 blob=FileToBlob(path,~0,length,exception);
2312 Search current directory.
2314 if ((blob == (void *) NULL) && (IsPathAccessible(path) != MagickFalse))
2315 blob=FileToBlob(path,~0,length,exception);
2316 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
2318 Search Windows registry.
2320 if (blob == (void *) NULL)
2321 blob=NTResourceToBlob(filename);
2324 if (blob == (void *) NULL)
2325 (void) ThrowMagickException(exception,GetMagickModule(),ConfigureWarning,
2326 "UnableToOpenConfigureFile","`%s'",path);
2331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2335 % G e t C a c h e V i e w %
2339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2341 % GetCacheView() gets pixels from the in-memory or disk pixel cache as
2342 % defined by the geometry parameters. A pointer to the pixels is returned if
2343 % the pixels are transferred, otherwise a NULL is returned.
2345 % Deprecated, replace with:
2347 % GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2348 % GetCacheViewException(cache_view));
2350 % The format of the GetCacheView method is:
2352 % PixelPacket *GetCacheView(CacheView *cache_view,const ssize_t x,
2353 % const ssize_t y,const size_t columns,const size_t rows)
2355 % A description of each parameter follows:
2357 % o cache_view: the address of a structure of type CacheView.
2359 % o x,y,columns,rows: These values define the perimeter of a region of
2363 MagickExport PixelPacket *GetCacheView(CacheView *cache_view,const ssize_t x,
2364 const ssize_t y,const size_t columns,const size_t rows)
2369 pixels=GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2370 GetCacheViewException(cache_view));
2375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2379 % G e t C a c h e V i e w I n d e x e s %
2383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2385 % GetCacheViewIndexes() returns the indexes associated with the specified
2388 % Deprecated, replace with:
2390 % GetCacheViewAuthenticIndexQueue(cache_view);
2392 % The format of the GetCacheViewIndexes method is:
2394 % IndexPacket *GetCacheViewIndexes(CacheView *cache_view)
2396 % A description of each parameter follows:
2398 % o cache_view: the cache view.
2401 MagickExport IndexPacket *GetCacheViewIndexes(CacheView *cache_view)
2403 return(GetCacheViewAuthenticIndexQueue(cache_view));
2407 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2411 % G e t C a c h e V i e w P i x e l s %
2415 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2417 % GetCacheViewPixels() gets pixels from the in-memory or disk pixel cache as
2418 % defined by the geometry parameters. A pointer to the pixels is returned if
2419 % the pixels are transferred, otherwise a NULL is returned.
2421 % Deprecated, replace with:
2423 % GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2424 % GetCacheViewException(cache_view));
2426 % The format of the GetCacheViewPixels method is:
2428 % PixelPacket *GetCacheViewPixels(CacheView *cache_view,const ssize_t x,
2429 % const ssize_t y,const size_t columns,const size_t rows)
2431 % A description of each parameter follows:
2433 % o cache_view: the cache view.
2435 % o x,y,columns,rows: These values define the perimeter of a region of
2439 MagickExport PixelPacket *GetCacheViewPixels(CacheView *cache_view,const ssize_t x,
2440 const ssize_t y,const size_t columns,const size_t rows)
2445 pixels=GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2446 GetCacheViewException(cache_view));
2451 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2455 % G e t I m a g e A t t r i b u t e %
2459 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2461 % GetImageAttribute() searches the list of image attributes and returns
2462 % a pointer to the attribute if it exists otherwise NULL.
2464 % The format of the GetImageAttribute method is:
2466 % const ImageAttribute *GetImageAttribute(const Image *image,
2469 % A description of each parameter follows:
2471 % o image: the image.
2473 % o key: These character strings are the name of an image attribute to
2478 static void *DestroyAttribute(void *attribute)
2480 register ImageAttribute
2483 p=(ImageAttribute *) attribute;
2484 if (p->value != (char *) NULL)
2485 p->value=DestroyString(p->value);
2486 return(RelinquishMagickMemory(p));
2489 MagickExport const ImageAttribute *GetImageAttribute(const Image *image,
2498 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
2499 value=GetImageProperty(image,key);
2500 if (value == (const char *) NULL)
2501 return((const ImageAttribute *) NULL);
2502 if (image->attributes == (void *) NULL)
2503 ((Image *) image)->attributes=NewSplayTree(CompareSplayTreeString,
2504 RelinquishMagickMemory,DestroyAttribute);
2507 const ImageAttribute
2510 attribute=(const ImageAttribute *) GetValueFromSplayTree((SplayTreeInfo *)
2511 image->attributes,key);
2512 if (attribute != (const ImageAttribute *) NULL)
2515 attribute=(ImageAttribute *) AcquireAlignedMemory(1,sizeof(*attribute));
2516 if (attribute == (ImageAttribute *) NULL)
2517 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
2518 (void) ResetMagickMemory(attribute,0,sizeof(*attribute));
2519 attribute->key=ConstantString(key);
2520 attribute->value=ConstantString(value);
2521 (void) AddValueToSplayTree((SplayTreeInfo *) ((Image *) image)->attributes,
2522 attribute->key,attribute);
2523 return((const ImageAttribute *) attribute);
2527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2531 % 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 %
2535 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2537 % GetImageClippingPathAttribute() searches the list of image attributes and
2538 % returns a pointer to a clipping path if it exists otherwise NULL.
2540 % Deprecated, replace with:
2542 % GetImageAttribute(image,"8BIM:1999,2998");
2544 % The format of the GetImageClippingPathAttribute method is:
2546 % const ImageAttribute *GetImageClippingPathAttribute(Image *image)
2548 % A description of each parameter follows:
2550 % o attribute: Method GetImageClippingPathAttribute returns the clipping
2551 % path if it exists otherwise NULL.
2553 % o image: the image.
2556 MagickExport const ImageAttribute *GetImageClippingPathAttribute(Image *image)
2558 return(GetImageAttribute(image,"8BIM:1999,2998"));
2562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2566 % 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 %
2570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2572 % GetImageFromMagickRegistry() gets an image from the registry as defined by
2573 % its name. If the image is not found, a NULL image is returned.
2575 % Deprecated, replace with:
2577 % GetImageRegistry(ImageRegistryType,name,exception);
2579 % The format of the GetImageFromMagickRegistry method is:
2581 % Image *GetImageFromMagickRegistry(const char *name,ssize_t *id,
2582 % ExceptionInfo *exception)
2584 % A description of each parameter follows:
2586 % o name: the name of the image to retrieve from the registry.
2588 % o id: the registry id.
2590 % o exception: return any errors or warnings in this structure.
2593 MagickExport Image *GetImageFromMagickRegistry(const char *name,ssize_t *id,
2594 ExceptionInfo *exception)
2597 return((Image *) GetImageRegistry(ImageRegistryType,name,exception));
2601 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2605 % G e t M a g i c k R e g i s t r y %
2609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2611 % GetMagickRegistry() gets a blob from the registry as defined by the id. If
2612 % the blob that matches the id is not found, NULL is returned.
2614 % The format of the GetMagickRegistry method is:
2616 % const void *GetMagickRegistry(const ssize_t id,RegistryType *type,
2617 % size_t *length,ExceptionInfo *exception)
2619 % A description of each parameter follows:
2621 % o id: the registry id.
2623 % o type: the registry type.
2625 % o length: the blob length in number of bytes.
2627 % o exception: return any errors or warnings in this structure.
2630 MagickExport void *GetMagickRegistry(const ssize_t id,RegistryType *type,
2631 size_t *length,ExceptionInfo *exception)
2639 *type=UndefinedRegistryType;
2641 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",(long) id);
2642 blob=(void *) GetImageRegistry(ImageRegistryType,key,exception);
2643 if (blob != (void *) NULL)
2645 blob=(void *) GetImageRegistry(ImageInfoRegistryType,key,exception);
2646 if (blob != (void *) NULL)
2648 return((void *) GetImageRegistry(UndefinedRegistryType,key,exception));
2652 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2656 % G e t I m a g e G e o m e t r y %
2660 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2662 % GetImageGeometry() returns a region as defined by the geometry string with
2663 % respect to the image and its gravity.
2665 % Deprecated, replace with:
2667 % if (size_to_fit != MagickFalse)
2668 % ParseRegionGeometry(image,geometry,region_info,&image->exception); else
2669 % ParsePageGeometry(image,geometry,region_info,&image->exception);
2671 % The format of the GetImageGeometry method is:
2673 % int GetImageGeometry(Image *image,const char *geometry,
2674 % const unsigned int size_to_fit,RectangeInfo *region_info)
2676 % A description of each parameter follows:
2678 % o flags: Method GetImageGeometry returns a bitmask that indicates
2679 % which of the four values were located in the geometry string.
2681 % o geometry: The geometry (e.g. 100x100+10+10).
2683 % o size_to_fit: A value other than 0 means to scale the region so it
2684 % fits within the specified width and height.
2686 % o region_info: the region as defined by the geometry string with
2687 % respect to the image and its gravity.
2690 MagickExport int GetImageGeometry(Image *image,const char *geometry,
2691 const unsigned int size_to_fit,RectangleInfo *region_info)
2693 if (image->debug != MagickFalse)
2694 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.4");
2695 if (size_to_fit != MagickFalse)
2696 return((int) ParseRegionGeometry(image,geometry,region_info,&image->exception));
2697 return((int) ParsePageGeometry(image,geometry,region_info,&image->exception));
2701 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2705 % G e t I m a g e L i s t %
2709 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2711 % GetImageList() returns an image at the specified position in the list.
2713 % Deprecated, replace with:
2715 % CloneImage(GetImageFromList(images,(ssize_t) offset),0,0,MagickTrue,
2718 % The format of the GetImageList method is:
2720 % Image *GetImageList(const Image *images,const ssize_t offset,
2721 % ExceptionInfo *exception)
2723 % A description of each parameter follows:
2725 % o images: the image list.
2727 % o offset: the position within the list.
2729 % o exception: return any errors or warnings in this structure.
2732 MagickExport Image *GetImageList(const Image *images,const ssize_t offset,
2733 ExceptionInfo *exception)
2738 if (images->debug != MagickFalse)
2739 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2740 image=CloneImage(GetImageFromList(images,(ssize_t) offset),0,0,MagickTrue,
2746 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2750 % G e t I m a g e L i s t I n d e x %
2754 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2756 % GetImageListIndex() returns the position in the list of the specified
2759 % Deprecated, replace with:
2761 % GetImageIndexInList(images);
2763 % The format of the GetImageListIndex method is:
2765 % ssize_t GetImageListIndex(const Image *images)
2767 % A description of each parameter follows:
2769 % o images: the image list.
2772 MagickExport ssize_t GetImageListIndex(const Image *images)
2774 if (images->debug != MagickFalse)
2775 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2776 return(GetImageIndexInList(images));
2780 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2784 % G e t I m a g e L i s t S i z e %
2788 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2790 % GetImageListSize() returns the number of images in the list.
2792 % Deprecated, replace with:
2794 % GetImageListLength(images);
2796 % The format of the GetImageListSize method is:
2798 % size_t GetImageListSize(const Image *images)
2800 % A description of each parameter follows:
2802 % o images: the image list.
2805 MagickExport size_t GetImageListSize(const Image *images)
2807 if (images->debug != MagickFalse)
2808 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2809 return(GetImageListLength(images));
2813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2817 % G e t I m a g e P i x e l s %
2821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2823 % GetImagePixels() obtains a pixel region for read/write access. If the
2824 % region is successfully accessed, a pointer to a PixelPacket array
2825 % representing the region is returned, otherwise NULL is returned.
2827 % The returned pointer may point to a temporary working copy of the pixels
2828 % or it may point to the original pixels in memory. Performance is maximized
2829 % if the selected region is part of one row, or one or more full rows, since
2830 % then there is opportunity to access the pixels in-place (without a copy)
2831 % if the image is in RAM, or in a memory-mapped file. The returned pointer
2832 % should *never* be deallocated by the user.
2834 % Pixels accessed via the returned pointer represent a simple array of type
2835 % PixelPacket. If the image type is CMYK or if the storage class is
2836 % PseduoClass, call GetAuthenticIndexQueue() after invoking GetImagePixels()
2837 % to obtain the black color component or colormap indexes (of type IndexPacket)
2838 % corresponding to the region. Once the PixelPacket (and/or IndexPacket)
2839 % array has been updated, the changes must be saved back to the underlying
2840 % image using SyncAuthenticPixels() or they may be lost.
2842 % Deprecated, replace with:
2844 % GetAuthenticPixels(image,x,y,columns,rows,&image->exception);
2846 % The format of the GetImagePixels() method is:
2848 % PixelPacket *GetImagePixels(Image *image,const ssize_t x,const ssize_t y,
2849 % const size_t columns,const size_t rows)
2851 % A description of each parameter follows:
2853 % o image: the image.
2855 % o x,y,columns,rows: These values define the perimeter of a region of
2859 MagickExport PixelPacket *GetImagePixels(Image *image,const ssize_t x,const ssize_t y,
2860 const size_t columns,const size_t rows)
2862 return(GetAuthenticPixels(image,x,y,columns,rows,&image->exception));
2866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2870 % G e t I n d e x e s %
2874 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2876 % GetIndexes() returns the black channel or the colormap indexes associated
2877 % with the last call to QueueAuthenticPixels() or GetVirtualPixels(). NULL is
2878 % returned if the black channel or colormap indexes are not available.
2880 % Deprecated, replace with:
2882 % GetAuthenticIndexQueue(image);
2884 % The format of the GetIndexes() method is:
2886 % IndexPacket *GetIndexes(const Image *image)
2888 % A description of each parameter follows:
2890 % o indexes: GetIndexes() returns the indexes associated with the last
2891 % call to QueueAuthenticPixels() or GetAuthenticPixels().
2893 % o image: the image.
2896 MagickExport IndexPacket *GetIndexes(const Image *image)
2898 return(GetAuthenticIndexQueue(image));
2902 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2906 + G e t M a g i c k G e o m e t r y %
2910 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2912 % GetMagickGeometry() is similar to GetGeometry() except the returned
2913 % geometry is modified as determined by the meta characters: %, !, <, >,
2916 % Deprecated, replace with:
2918 % ParseMetaGeometry(geometry,x,y,width,height);
2920 % The format of the GetMagickGeometry method is:
2922 % unsigned int GetMagickGeometry(const char *geometry,ssize_t *x,ssize_t *y,
2923 % size_t *width,size_t *height)
2925 % A description of each parameter follows:
2927 % o geometry: Specifies a character string representing the geometry
2930 % o x,y: A pointer to an integer. The x and y offset as determined by
2931 % the geometry specification is returned here.
2933 % o width,height: A pointer to an unsigned integer. The width and height
2934 % as determined by the geometry specification is returned here.
2937 MagickExport unsigned int GetMagickGeometry(const char *geometry,ssize_t *x,
2938 ssize_t *y,size_t *width,size_t *height)
2940 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.3");
2941 return(ParseMetaGeometry(geometry,x,y,width,height));
2945 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2949 % G e t N e x t I m a g e %
2953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2955 % GetNextImage() returns the next image in a list.
2957 % Deprecated, replace with:
2959 % GetNextImageInList(images);
2961 % The format of the GetNextImage method is:
2963 % Image *GetNextImage(const Image *images)
2965 % A description of each parameter follows:
2967 % o images: the image list.
2970 MagickExport Image *GetNextImage(const Image *images)
2972 if (images->debug != MagickFalse)
2973 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2974 return(GetNextImageInList(images));
2978 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2982 % G e t N e x t I m a g e A t t r i b u t e %
2986 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2988 % GetNextImageAttribute() gets the next image attribute.
2990 % Deprecated, replace with:
2992 % const char *property;
2993 % property=GetNextImageProperty(image);
2994 % if (property != (const char *) NULL)
2995 % GetImageAttribute(image,property);
2997 % The format of the GetNextImageAttribute method is:
2999 % const ImageAttribute *GetNextImageAttribute(const Image *image)
3001 % A description of each parameter follows:
3003 % o image: the image.
3006 MagickExport const ImageAttribute *GetNextImageAttribute(const Image *image)
3011 property=GetNextImageProperty(image);
3012 if (property == (const char *) NULL)
3013 return((const ImageAttribute *) NULL);
3014 return(GetImageAttribute(image,property));
3018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3022 % G e t N u m b e r S c e n e s %
3026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3028 % GetNumberScenes() returns the number of images in the list.
3030 % Deprecated, replace with:
3032 % GetImageListLength(image);
3034 % The format of the GetNumberScenes method is:
3036 % unsigned int GetNumberScenes(const Image *images)
3038 % A description of each parameter follows:
3040 % o images: the image list.
3043 MagickExport unsigned int GetNumberScenes(const Image *image)
3045 if (image->debug != MagickFalse)
3046 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
3047 return((unsigned int) GetImageListLength(image));
3051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3055 % G e t O n e P i x e l %
3059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3061 % GetOnePixel() returns a single pixel at the specified (x,y) location.
3062 % The image background color is returned if an error occurs.
3064 % Deprecated, replace with:
3066 % GetOneAuthenticPixel(image,x,y,&pixel,&image->exception);
3068 % The format of the GetOnePixel() method is:
3070 % PixelPacket GetOnePixel(const Image image,const ssize_t x,const ssize_t y)
3072 % A description of each parameter follows:
3074 % o image: the image.
3076 % o x,y: These values define the location of the pixel to return.
3079 MagickExport PixelPacket GetOnePixel(Image *image,const ssize_t x,const ssize_t y)
3084 (void) GetOneAuthenticPixel(image,x,y,&pixel,&image->exception);
3089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3093 % G e t P i x e l s %
3097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3099 % GetPixels() returns the pixels associated with the last call to
3100 % QueueAuthenticPixels() or GetAuthenticPixels().
3102 % Deprecated, replace with:
3104 % GetAuthenticPixelQueue(image);
3106 % The format of the GetPixels() method is:
3108 % PixelPacket *GetPixels(const Image image)
3110 % A description of each parameter follows:
3112 % o pixels: GetPixels() returns the pixels associated with the last call
3113 % to QueueAuthenticPixels() or GetAuthenticPixels().
3115 % o image: the image.
3118 MagickExport PixelPacket *GetPixels(const Image *image)
3120 return(GetAuthenticPixelQueue(image));
3124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3128 % G e t P r e v i o u s I m a g e %
3132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3134 % GetPreviousImage() returns the previous image in a list.
3136 % Deprecated, replace with:
3138 % GetPreviousImageInList(images));
3140 % The format of the GetPreviousImage method is:
3142 % Image *GetPreviousImage(const Image *images)
3144 % A description of each parameter follows:
3146 % o images: the image list.
3149 MagickExport Image *GetPreviousImage(const Image *images)
3151 if (images->debug != MagickFalse)
3152 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
3153 return(GetPreviousImageInList(images));
3157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3161 % H S L T r a n s f o r m %
3165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3167 % HSLTransform() converts a (hue, saturation, lightness) to a (red, green,
3170 % The format of the HSLTransformImage method is:
3172 % void HSLTransform(const double hue,const double saturation,
3173 % const double lightness,Quantum *red,Quantum *green,Quantum *blue)
3175 % A description of each parameter follows:
3177 % o hue, saturation, lightness: A double value representing a
3178 % component of the HSL color space.
3180 % o red, green, blue: A pointer to a pixel component of type Quantum.
3184 static inline MagickRealType HueToRGB(MagickRealType m1,MagickRealType m2,
3191 if ((6.0*hue) < 1.0)
3192 return(m1+6.0*(m2-m1)*hue);
3193 if ((2.0*hue) < 1.0)
3195 if ((3.0*hue) < 2.0)
3196 return(m1+6.0*(m2-m1)*(2.0/3.0-hue));
3200 MagickExport void HSLTransform(const double hue,const double saturation,
3201 const double lightness,Quantum *red,Quantum *green,Quantum *blue)
3211 Convert HSL to RGB colorspace.
3213 assert(red != (Quantum *) NULL);
3214 assert(green != (Quantum *) NULL);
3215 assert(blue != (Quantum *) NULL);
3216 if (lightness <= 0.5)
3217 m2=lightness*(saturation+1.0);
3219 m2=lightness+saturation-lightness*saturation;
3220 m1=2.0*lightness-m2;
3221 r=HueToRGB(m1,m2,hue+1.0/3.0);
3222 g=HueToRGB(m1,m2,hue);
3223 b=HueToRGB(m1,m2,hue-1.0/3.0);
3224 *red=ClampToQuantum((MagickRealType) QuantumRange*r);
3225 *green=ClampToQuantum((MagickRealType) QuantumRange*g);
3226 *blue=ClampToQuantum((MagickRealType) QuantumRange*b);
3230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3234 % I d e n t i t y A f f i n e %
3238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3240 % IdentityAffine() initializes the affine transform to the identity matrix.
3242 % The format of the IdentityAffine method is:
3244 % IdentityAffine(AffineMatrix *affine)
3246 % A description of each parameter follows:
3248 % o affine: A pointer the affine transform of type AffineMatrix.
3251 MagickExport void IdentityAffine(AffineMatrix *affine)
3253 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3254 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3255 assert(affine != (AffineMatrix *) NULL);
3256 (void) ResetMagickMemory(affine,0,sizeof(AffineMatrix));
3262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3266 % I n i t i a l i z e M a g i c k %
3270 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3272 % InitializeMagick() initializes the ImageMagick environment.
3274 % Deprecated, replace with:
3276 % MagickCoreGenesis(path,MagickFalse);
3278 % The format of the InitializeMagick function is:
3280 % InitializeMagick(const char *path)
3282 % A description of each parameter follows:
3284 % o path: the execution path of the current ImageMagick client.
3287 MagickExport void InitializeMagick(const char *path)
3289 MagickCoreGenesis(path,MagickFalse);
3293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3297 % I n t e r p o l a t e P i x e l C o l o r %
3301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3303 % InterpolatePixelColor() applies bi-linear or tri-linear interpolation
3304 % between a pixel and it's neighbors.
3306 % The format of the InterpolatePixelColor method is:
3308 % MagickPixelPacket InterpolatePixelColor(const Image *image,
3309 % CacheView *view_info,InterpolatePixelMethod method,const double x,
3310 % const double y,ExceptionInfo *exception)
3312 % A description of each parameter follows:
3314 % o image: the image.
3316 % o image_view: the image cache view.
3318 % o type: the type of pixel color interpolation.
3320 % o x,y: A double representing the current (x,y) position of the pixel.
3322 % o exception: return any errors or warnings in this structure.
3326 static inline double MagickMax(const double x,const double y)
3333 static void BicubicInterpolate(const MagickPixelPacket *pixels,const double dx,
3334 MagickPixelPacket *pixel)
3344 p=(pixels[3].red-pixels[2].red)-(pixels[0].red-pixels[1].red);
3345 q=(pixels[0].red-pixels[1].red)-p;
3346 r=pixels[2].red-pixels[0].red;
3348 pixel->red=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3349 p=(pixels[3].green-pixels[2].green)-(pixels[0].green-pixels[1].green);
3350 q=(pixels[0].green-pixels[1].green)-p;
3351 r=pixels[2].green-pixels[0].green;
3353 pixel->green=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3354 p=(pixels[3].blue-pixels[2].blue)-(pixels[0].blue-pixels[1].blue);
3355 q=(pixels[0].blue-pixels[1].blue)-p;
3356 r=pixels[2].blue-pixels[0].blue;
3358 pixel->blue=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3359 p=(pixels[3].opacity-pixels[2].opacity)-(pixels[0].opacity-pixels[1].opacity);
3360 q=(pixels[0].opacity-pixels[1].opacity)-p;
3361 r=pixels[2].opacity-pixels[0].opacity;
3362 s=pixels[1].opacity;
3363 pixel->opacity=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3364 if (pixel->colorspace == CMYKColorspace)
3366 p=(pixels[3].index-pixels[2].index)-(pixels[0].index-pixels[1].index);
3367 q=(pixels[0].index-pixels[1].index)-p;
3368 r=pixels[2].index-pixels[0].index;
3370 pixel->index=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3374 static inline MagickRealType CubicWeightingFunction(const MagickRealType x)
3380 alpha=MagickMax(x+2.0,0.0);
3381 gamma=1.0*alpha*alpha*alpha;
3382 alpha=MagickMax(x+1.0,0.0);
3383 gamma-=4.0*alpha*alpha*alpha;
3384 alpha=MagickMax(x+0.0,0.0);
3385 gamma+=6.0*alpha*alpha*alpha;
3386 alpha=MagickMax(x-1.0,0.0);
3387 gamma-=4.0*alpha*alpha*alpha;
3391 static inline double MeshInterpolate(const PointInfo *delta,const double p,
3392 const double x,const double y)
3394 return(delta->x*x+delta->y*y+(1.0-delta->x-delta->y)*p);
3397 static inline ssize_t NearestNeighbor(MagickRealType x)
3400 return((ssize_t) (x+0.5));
3401 return((ssize_t) (x-0.5));
3404 MagickExport MagickPixelPacket InterpolatePixelColor(const Image *image,
3405 CacheView *image_view,const InterpolatePixelMethod method,const double x,
3406 const double y,ExceptionInfo *exception)
3411 register const IndexPacket
3414 register const PixelPacket
3420 assert(image != (Image *) NULL);
3421 assert(image->signature == MagickSignature);
3422 assert(image_view != (CacheView *) NULL);
3423 GetMagickPixelPacket(image,&pixel);
3426 case AverageInterpolatePixel:
3435 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x)-1,(ssize_t) floor(y)-
3437 if (p == (const PixelPacket *) NULL)
3439 indexes=GetCacheViewVirtualIndexQueue(image_view);
3440 for (i=0; i < 16L; i++)
3442 GetMagickPixelPacket(image,pixels+i);
3443 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3445 if (image->matte != MagickFalse)
3447 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3448 pixels[i].red*=alpha[i];
3449 pixels[i].green*=alpha[i];
3450 pixels[i].blue*=alpha[i];
3451 if (image->colorspace == CMYKColorspace)
3452 pixels[i].index*=alpha[i];
3455 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3456 pixel.red+=gamma*0.0625*pixels[i].red;
3457 pixel.green+=gamma*0.0625*pixels[i].green;
3458 pixel.blue+=gamma*0.0625*pixels[i].blue;
3459 pixel.opacity+=0.0625*pixels[i].opacity;
3460 if (image->colorspace == CMYKColorspace)
3461 pixel.index+=gamma*0.0625*pixels[i].index;
3466 case BicubicInterpolatePixel:
3478 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x)-1,(ssize_t) floor(y)-
3480 if (p == (const PixelPacket *) NULL)
3482 indexes=GetCacheViewVirtualIndexQueue(image_view);
3483 for (i=0; i < 16L; i++)
3485 GetMagickPixelPacket(image,pixels+i);
3486 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3488 if (image->matte != MagickFalse)
3490 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3491 pixels[i].red*=alpha[i];
3492 pixels[i].green*=alpha[i];
3493 pixels[i].blue*=alpha[i];
3494 if (image->colorspace == CMYKColorspace)
3495 pixels[i].index*=alpha[i];
3500 for (i=0; i < 4L; i++)
3501 BicubicInterpolate(pixels+4*i,delta.x,u+i);
3503 BicubicInterpolate(u,delta.y,&pixel);
3506 case BilinearInterpolatePixel:
3519 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x),(ssize_t) floor(y),2,
3521 if (p == (const PixelPacket *) NULL)
3523 indexes=GetCacheViewVirtualIndexQueue(image_view);
3524 for (i=0; i < 4L; i++)
3526 GetMagickPixelPacket(image,pixels+i);
3527 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3529 if (image->matte != MagickFalse)
3531 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3532 pixels[i].red*=alpha[i];
3533 pixels[i].green*=alpha[i];
3534 pixels[i].blue*=alpha[i];
3535 if (image->colorspace == CMYKColorspace)
3536 pixels[i].index*=alpha[i];
3542 gamma=(((1.0-delta.y)*((1.0-delta.x)*alpha[0]+delta.x*alpha[1])+delta.y*
3543 ((1.0-delta.x)*alpha[2]+delta.x*alpha[3])));
3544 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3545 pixel.red=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].red+delta.x*
3546 pixels[1].red)+delta.y*((1.0-delta.x)*pixels[2].red+delta.x*
3548 pixel.green=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].green+delta.x*
3549 pixels[1].green)+delta.y*((1.0-delta.x)*pixels[2].green+
3550 delta.x*pixels[3].green));
3551 pixel.blue=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].blue+delta.x*
3552 pixels[1].blue)+delta.y*((1.0-delta.x)*pixels[2].blue+delta.x*
3554 pixel.opacity=((1.0-delta.y)*((1.0-delta.x)*pixels[0].opacity+delta.x*
3555 pixels[1].opacity)+delta.y*((1.0-delta.x)*pixels[2].opacity+delta.x*
3556 pixels[3].opacity));
3557 if (image->colorspace == CMYKColorspace)
3558 pixel.index=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].index+delta.x*
3559 pixels[1].index)+delta.y*((1.0-delta.x)*pixels[2].index+delta.x*
3563 case FilterInterpolatePixel:
3577 geometry.x=(ssize_t) floor(x)-1L;
3578 geometry.y=(ssize_t) floor(y)-1L;
3579 excerpt_image=ExcerptImage(image,&geometry,exception);
3580 if (excerpt_image == (Image *) NULL)
3582 filter_image=ResizeImage(excerpt_image,1,1,image->filter,image->blur,
3584 excerpt_image=DestroyImage(excerpt_image);
3585 if (filter_image == (Image *) NULL)
3587 p=GetVirtualPixels(filter_image,0,0,1,1,exception);
3588 if (p == (const PixelPacket *) NULL)
3590 filter_image=DestroyImage(filter_image);
3593 indexes=GetVirtualIndexQueue(filter_image);
3594 GetMagickPixelPacket(image,pixels);
3595 SetMagickPixelPacket(image,p,indexes,&pixel);
3596 filter_image=DestroyImage(filter_image);
3599 case IntegerInterpolatePixel:
3604 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x),(ssize_t) floor(y),1,
3606 if (p == (const PixelPacket *) NULL)
3608 indexes=GetCacheViewVirtualIndexQueue(image_view);
3609 GetMagickPixelPacket(image,pixels);
3610 SetMagickPixelPacket(image,p,indexes,&pixel);
3613 case MeshInterpolatePixel:
3626 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x),(ssize_t) floor(y),
3628 if (p == (const PixelPacket *) NULL)
3630 indexes=GetCacheViewVirtualIndexQueue(image_view);
3631 for (i=0; i < 4L; i++)
3633 GetMagickPixelPacket(image,pixels+i);
3634 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3636 if (image->matte != MagickFalse)
3638 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3639 pixels[i].red*=alpha[i];
3640 pixels[i].green*=alpha[i];
3641 pixels[i].blue*=alpha[i];
3642 if (image->colorspace == CMYKColorspace)
3643 pixels[i].index*=alpha[i];
3649 luminance.x=MagickPixelLuminance(pixels+0)-MagickPixelLuminance(pixels+3);
3650 luminance.y=MagickPixelLuminance(pixels+1)-MagickPixelLuminance(pixels+2);
3651 if (fabs(luminance.x) < fabs(luminance.y))
3656 if (delta.x <= delta.y)
3659 Bottom-left triangle (pixel:2, diagonal: 0-3).
3661 delta.y=1.0-delta.y;
3662 gamma=MeshInterpolate(&delta,alpha[2],alpha[3],alpha[0]);
3663 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3664 pixel.red=gamma*MeshInterpolate(&delta,pixels[2].red,
3665 pixels[3].red,pixels[0].red);
3666 pixel.green=gamma*MeshInterpolate(&delta,pixels[2].green,
3667 pixels[3].green,pixels[0].green);
3668 pixel.blue=gamma*MeshInterpolate(&delta,pixels[2].blue,
3669 pixels[3].blue,pixels[0].blue);
3670 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[2].opacity,
3671 pixels[3].opacity,pixels[0].opacity);
3672 if (image->colorspace == CMYKColorspace)
3673 pixel.index=gamma*MeshInterpolate(&delta,pixels[2].index,
3674 pixels[3].index,pixels[0].index);
3679 Top-right triangle (pixel:1, diagonal: 0-3).
3681 delta.x=1.0-delta.x;
3682 gamma=MeshInterpolate(&delta,alpha[1],alpha[0],alpha[3]);
3683 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3684 pixel.red=gamma*MeshInterpolate(&delta,pixels[1].red,
3685 pixels[0].red,pixels[3].red);
3686 pixel.green=gamma*MeshInterpolate(&delta,pixels[1].green,
3687 pixels[0].green,pixels[3].green);
3688 pixel.blue=gamma*MeshInterpolate(&delta,pixels[1].blue,
3689 pixels[0].blue,pixels[3].blue);
3690 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[1].opacity,
3691 pixels[0].opacity,pixels[3].opacity);
3692 if (image->colorspace == CMYKColorspace)
3693 pixel.index=gamma*MeshInterpolate(&delta,pixels[1].index,
3694 pixels[0].index,pixels[3].index);
3702 if (delta.x <= (1.0-delta.y))
3705 Top-left triangle (pixel 0, diagonal: 1-2).
3707 gamma=MeshInterpolate(&delta,alpha[0],alpha[1],alpha[2]);
3708 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3709 pixel.red=gamma*MeshInterpolate(&delta,pixels[0].red,
3710 pixels[1].red,pixels[2].red);
3711 pixel.green=gamma*MeshInterpolate(&delta,pixels[0].green,
3712 pixels[1].green,pixels[2].green);
3713 pixel.blue=gamma*MeshInterpolate(&delta,pixels[0].blue,
3714 pixels[1].blue,pixels[2].blue);
3715 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[0].opacity,
3716 pixels[1].opacity,pixels[2].opacity);
3717 if (image->colorspace == CMYKColorspace)
3718 pixel.index=gamma*MeshInterpolate(&delta,pixels[0].index,
3719 pixels[1].index,pixels[2].index);
3724 Bottom-right triangle (pixel: 3, diagonal: 1-2).
3726 delta.x=1.0-delta.x;
3727 delta.y=1.0-delta.y;
3728 gamma=MeshInterpolate(&delta,alpha[3],alpha[2],alpha[1]);
3729 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3730 pixel.red=gamma*MeshInterpolate(&delta,pixels[3].red,
3731 pixels[2].red,pixels[1].red);
3732 pixel.green=gamma*MeshInterpolate(&delta,pixels[3].green,
3733 pixels[2].green,pixels[1].green);
3734 pixel.blue=gamma*MeshInterpolate(&delta,pixels[3].blue,
3735 pixels[2].blue,pixels[1].blue);
3736 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[3].opacity,
3737 pixels[2].opacity,pixels[1].opacity);
3738 if (image->colorspace == CMYKColorspace)
3739 pixel.index=gamma*MeshInterpolate(&delta,pixels[3].index,
3740 pixels[2].index,pixels[1].index);
3745 case NearestNeighborInterpolatePixel:
3750 p=GetCacheViewVirtualPixels(image_view,NearestNeighbor(x),
3751 NearestNeighbor(y),1,1,exception);
3752 if (p == (const PixelPacket *) NULL)
3754 indexes=GetCacheViewVirtualIndexQueue(image_view);
3755 GetMagickPixelPacket(image,pixels);
3756 SetMagickPixelPacket(image,p,indexes,&pixel);
3759 case SplineInterpolatePixel:
3777 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x)-1,(ssize_t) floor(y)-
3779 if (p == (const PixelPacket *) NULL)
3781 indexes=GetCacheViewVirtualIndexQueue(image_view);
3785 for (i=(-1); i < 3L; i++)
3787 dy=CubicWeightingFunction((MagickRealType) i-delta.y);
3788 for (j=(-1); j < 3L; j++)
3790 GetMagickPixelPacket(image,pixels+n);
3791 SetMagickPixelPacket(image,p,indexes+n,pixels+n);
3793 if (image->matte != MagickFalse)
3795 alpha[n]=QuantumScale*((MagickRealType)
3796 GetAlphaPixelComponent(p));
3797 pixels[n].red*=alpha[n];
3798 pixels[n].green*=alpha[n];
3799 pixels[n].blue*=alpha[n];
3800 if (image->colorspace == CMYKColorspace)
3801 pixels[n].index*=alpha[n];
3803 dx=CubicWeightingFunction(delta.x-(MagickRealType) j);
3805 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3806 pixel.red+=gamma*dx*dy*pixels[n].red;
3807 pixel.green+=gamma*dx*dy*pixels[n].green;
3808 pixel.blue+=gamma*dx*dy*pixels[n].blue;
3809 if (image->matte != MagickFalse)
3810 pixel.opacity+=dx*dy*pixels[n].opacity;
3811 if (image->colorspace == CMYKColorspace)
3812 pixel.index+=gamma*dx*dy*pixels[n].index;
3824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3828 % I n t e r p r e t I m a g e A t t r i b u t e s %
3832 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3834 % InterpretImageAttributes() replaces any embedded formatting characters with
3835 % the appropriate image attribute and returns the translated text.
3837 % Deprecated, replace with:
3839 % InterpretImageProperties(image_info,image,embed_text);
3841 % The format of the InterpretImageAttributes method is:
3843 % char *InterpretImageAttributes(const ImageInfo *image_info,Image *image,
3844 % const char *embed_text)
3846 % A description of each parameter follows:
3848 % o image_info: the image info.
3850 % o image: the image.
3852 % o embed_text: the address of a character string containing the embedded
3853 % formatting characters.
3856 MagickExport char *InterpretImageAttributes(const ImageInfo *image_info,
3857 Image *image,const char *embed_text)
3859 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
3860 return(InterpretImageProperties(image_info,image,embed_text));
3864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3868 + I s S u b i m a g e %
3872 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3874 % IsSubimage() returns MagickTrue if the geometry is a valid subimage
3875 % specification (e.g. [1], [1-9], [1,7,4]).
3877 % The format of the IsSubimage method is:
3879 % unsigned int IsSubimage(const char *geometry,const unsigned int pedantic)
3881 % A description of each parameter follows:
3883 % o geometry: This string is the geometry specification.
3885 % o pedantic: A value other than 0 invokes a more restrictive set of
3886 % conditions for a valid specification (e.g. [1], [1-4], [4-1]).
3889 MagickExport unsigned int IsSubimage(const char *geometry,
3890 const unsigned int pedantic)
3892 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3893 if (geometry == (const char *) NULL)
3894 return(MagickFalse);
3895 if ((strchr(geometry,'x') != (char *) NULL) ||
3896 (strchr(geometry,'X') != (char *) NULL))
3897 return(MagickFalse);
3898 if ((pedantic != MagickFalse) && (strchr(geometry,',') != (char *) NULL))
3899 return(MagickFalse);
3904 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3908 % L e v e l I m a g e C o l o r s %
3912 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3914 % LevelImageColor() will map the given color to "black" and "white"
3915 % values, limearly spreading out the colors, and level values on a channel by
3916 % channel bases, as per LevelImage(). The given colors allows you to specify
3917 % different level ranges for each of the color channels seperatally.
3919 % If the boolean 'invert' is set true the image values will modifyed in the
3920 % reverse direction. That is any existing "black" and "white" colors in the
3921 % image will become the color values given, with all other values compressed
3922 % appropriatally. This effectivally maps a greyscale gradient into the given
3925 % Deprecated, replace with:
3927 % LevelColorsImageChannel(image,channel,black_color,white_color,invert);
3929 % The format of the LevelImageColors method is:
3931 % MagickBooleanType LevelImageColors(Image *image,const ChannelType channel,
3932 % const MagickPixelPacket *black_color,const MagickPixelPacket *white_color,
3933 % const MagickBooleanType invert)
3935 % A description of each parameter follows:
3937 % o image: the image.
3939 % o channel: the channel.
3941 % o black_color: The color to map black to/from
3943 % o white_point: The color to map white to/from
3945 % o invert: if true map the colors (levelize), rather than from (level)
3948 MagickBooleanType LevelImageColors(Image *image,const ChannelType channel,
3949 const MagickPixelPacket *black_color,const MagickPixelPacket *white_color,
3950 const MagickBooleanType invert)
3952 return(LevelColorsImageChannel(image,channel,black_color,white_color,invert));
3956 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3960 % L i b e r a t e M e m o r y %
3964 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3966 % LiberateMemory() frees memory that has already been allocated, and NULL's
3967 % the pointer to it.
3969 % The format of the LiberateMemory method is:
3971 % void LiberateMemory(void **memory)
3973 % A description of each parameter follows:
3975 % o memory: A pointer to a block of memory to free for reuse.
3978 MagickExport void LiberateMemory(void **memory)
3980 assert(memory != (void **) NULL);
3981 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3982 if (*memory == (void *) NULL)
3985 *memory=(void *) NULL;
3989 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3993 % L i b e r a t e S e m a p h o r e I n f o %
3997 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3999 % LiberateSemaphoreInfo() relinquishes a semaphore.
4001 % Deprecated, replace with:
4003 % UnlockSemaphoreInfo(*semaphore_info);
4005 % The format of the LiberateSemaphoreInfo method is:
4007 % LiberateSemaphoreInfo(void **semaphore_info)
4009 % A description of each parameter follows:
4011 % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
4014 MagickExport void LiberateSemaphoreInfo(SemaphoreInfo **semaphore_info)
4016 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
4017 UnlockSemaphoreInfo(*semaphore_info);
4021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4025 % M a g i c k I n c a r n a t e %
4029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4031 % MagickIncarnate() initializes the ImageMagick environment.
4033 % Deprecated, replace with:
4035 % MagickCoreGenesis(path,MagickFalse);
4037 % The format of the MagickIncarnate function is:
4039 % MagickIncarnate(const char *path)
4041 % A description of each parameter follows:
4043 % o path: the execution path of the current ImageMagick client.
4047 MagickExport void MagickIncarnate(const char *path)
4049 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
4050 MagickCoreGenesis(path,MagickFalse);
4054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4058 % M a g i c k M o n i t o r %
4062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4064 % MagickMonitor() calls the monitor handler method with a text string that
4065 % describes the task and a measure of completion. The method returns
4066 % MagickTrue on success otherwise MagickFalse if an error is encountered, e.g.
4067 % if there was a user interrupt.
4069 % The format of the MagickMonitor method is:
4071 % MagickBooleanType MagickMonitor(const char *text,
4072 % const MagickOffsetType offset,const MagickSizeType span,
4073 % void *client_data)
4075 % A description of each parameter follows:
4077 % o offset: the position relative to the span parameter which represents
4078 % how much progress has been made toward completing a task.
4080 % o span: the span relative to completing a task.
4082 % o client_data: the client data.
4085 MagickExport MagickBooleanType MagickMonitor(const char *text,
4086 const MagickOffsetType offset,const MagickSizeType span,
4087 void *magick_unused(client_data))
4095 assert(text != (const char *) NULL);
4096 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",text);
4097 ProcessPendingEvents(text);
4099 exception=AcquireExceptionInfo();
4100 if (monitor_handler != (MonitorHandler) NULL)
4101 status=(*monitor_handler)(text,offset,span,exception);
4102 exception=DestroyExceptionInfo(exception);
4107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4117 % MapImage() replaces the colors of an image with the closest color from a
4120 % Deprecated, replace with:
4122 % QuantizeInfo quantize_info;
4123 % GetQuantizeInfo(&quantize_info);
4124 % quantize_info.dither=dither;
4125 % RemapImage(&quantize_info,image,map_image);
4127 % The format of the MapImage method is:
4129 % MagickBooleanType MapImage(Image *image,const Image *map_image,
4130 % const MagickBooleanType dither)
4132 % A description of each parameter follows:
4134 % o image: Specifies a pointer to an Image structure.
4136 % o map_image: the image. Reduce image to a set of colors represented by
4139 % o dither: Set this integer value to something other than zero to
4140 % dither the mapped image.
4143 MagickExport MagickBooleanType MapImage(Image *image,const Image *map_image,
4144 const MagickBooleanType dither)
4150 Initialize color cube.
4152 assert(image != (Image *) NULL);
4153 assert(image->signature == MagickSignature);
4154 if (image->debug != MagickFalse)
4155 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4156 assert(map_image != (Image *) NULL);
4157 assert(map_image->signature == MagickSignature);
4158 GetQuantizeInfo(&quantize_info);
4159 quantize_info.dither=dither;
4160 return(RemapImage(&quantize_info,image,map_image));
4164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4168 % M a p I m a g e s %
4172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4174 % MapImages() replaces the colors of a sequence of images with the closest
4175 % color from a reference image.
4177 % Deprecated, replace with:
4179 % QuantizeInfo quantize_info;
4180 % GetQuantizeInfo(&quantize_info);
4181 % quantize_info.dither=dither;
4182 % RemapImages(&quantize_info,images,map_image);
4184 % The format of the MapImage method is:
4186 % MagickBooleanType MapImages(Image *images,Image *map_image,
4187 % const MagickBooleanType dither)
4189 % A description of each parameter follows:
4191 % o image: Specifies a pointer to a set of Image structures.
4193 % o map_image: the image. Reduce image to a set of colors represented by
4196 % o dither: Set this integer value to something other than zero to
4197 % dither the quantized image.
4200 MagickExport MagickBooleanType MapImages(Image *images,const Image *map_image,
4201 const MagickBooleanType dither)
4206 assert(images != (Image *) NULL);
4207 assert(images->signature == MagickSignature);
4208 if (images->debug != MagickFalse)
4209 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
4210 GetQuantizeInfo(&quantize_info);
4211 quantize_info.dither=dither;
4212 return(RemapImages(&quantize_info,images,map_image));
4216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4220 % M a t t e F l o o d f i l l I m a g e %
4224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4226 % MatteFloodfill() changes the transparency value of any pixel that matches
4227 % target and is an immediate neighbor. If the method FillToBorderMethod
4228 % is specified, the transparency value is changed for any neighbor pixel
4229 % that does not match the bordercolor member of image.
4231 % By default target must match a particular pixel transparency exactly.
4232 % However, in many cases two transparency values may differ by a
4233 % small amount. The fuzz member of image defines how much tolerance is
4234 % acceptable to consider two transparency values as the same. For example,
4235 % set fuzz to 10 and the opacity values of 100 and 102 respectively are
4236 % now interpreted as the same value for the purposes of the floodfill.
4238 % The format of the MatteFloodfillImage method is:
4240 % MagickBooleanType MatteFloodfillImage(Image *image,
4241 % const PixelPacket target,const Quantum opacity,const ssize_t x_offset,
4242 % const ssize_t y_offset,const PaintMethod method)
4244 % A description of each parameter follows:
4246 % o image: the image.
4248 % o target: the RGB value of the target color.
4250 % o opacity: the level of transparency: 0 is fully opaque and QuantumRange is
4251 % fully transparent.
4253 % o x,y: the starting location of the operation.
4255 % o method: Choose either FloodfillMethod or FillToBorderMethod.
4258 MagickExport MagickBooleanType MatteFloodfillImage(Image *image,
4259 const PixelPacket target,const Quantum opacity,const ssize_t x_offset,
4260 const ssize_t y_offset,const PaintMethod method)
4276 register SegmentInfo
4283 Check boundary conditions.
4285 assert(image != (Image *) NULL);
4286 assert(image->signature == MagickSignature);
4287 if (image->debug != MagickFalse)
4288 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4289 if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
4290 return(MagickFalse);
4291 if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
4292 return(MagickFalse);
4293 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
4294 return(MagickFalse);
4295 if (image->matte == MagickFalse)
4296 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
4297 floodplane_image=CloneImage(image,image->columns,image->rows,MagickTrue,
4299 if (floodplane_image == (Image *) NULL)
4300 return(MagickFalse);
4301 (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel);
4303 Set floodfill color.
4305 segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
4306 sizeof(*segment_stack));
4307 if (segment_stack == (SegmentInfo *) NULL)
4309 floodplane_image=DestroyImage(floodplane_image);
4310 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
4314 Push initial segment on stack.
4320 PushSegmentStack(y,x,x,1);
4321 PushSegmentStack(y+1,x,x,-1);
4322 while (s > segment_stack)
4324 register const PixelPacket
4330 register PixelPacket
4334 Pop segment off stack.
4339 offset=(ssize_t) s->y2;
4340 y=(ssize_t) s->y1+offset;
4342 Recolor neighboring pixels.
4344 p=GetVirtualPixels(image,0,y,(size_t) (x1+1),1,&image->exception);
4345 q=GetAuthenticPixels(floodplane_image,0,y,(size_t) (x1+1),1,
4347 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4351 for (x=x1; x >= 0; x--)
4353 if (q->opacity == (Quantum) TransparentOpacity)
4355 if (method == FloodfillMethod)
4357 if (IsColorSimilar(image,p,&target) == MagickFalse)
4361 if (IsColorSimilar(image,p,&target) != MagickFalse)
4363 q->opacity=(Quantum) TransparentOpacity;
4367 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
4369 skip=x >= x1 ? MagickTrue : MagickFalse;
4370 if (skip == MagickFalse)
4374 PushSegmentStack(y,start,x1-1,-offset);
4379 if (skip == MagickFalse)
4381 if (x < (ssize_t) image->columns)
4383 p=GetVirtualPixels(image,x,y,image->columns-x,1,
4385 q=GetAuthenticPixels(floodplane_image,x,y,image->columns-x,1,
4387 if ((p == (const PixelPacket *) NULL) ||
4388 (q == (PixelPacket *) NULL))
4390 for ( ; x < (ssize_t) image->columns; x++)
4392 if (q->opacity == (Quantum) TransparentOpacity)
4394 if (method == FloodfillMethod)
4396 if (IsColorSimilar(image,p,&target) == MagickFalse)
4400 if (IsColorSimilar(image,p,&target) != MagickFalse)
4402 q->opacity=(Quantum) TransparentOpacity;
4406 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
4409 PushSegmentStack(y,start,x-1,offset);
4411 PushSegmentStack(y,x2+1,x-1,-offset);
4417 p=GetVirtualPixels(image,x,y,(size_t) (x2-x+1),1,
4419 q=GetAuthenticPixels(floodplane_image,x,y,(size_t) (x2-x+1),1,
4421 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4423 for ( ; x <= x2; x++)
4425 if (q->opacity == (Quantum) TransparentOpacity)
4427 if (method == FloodfillMethod)
4429 if (IsColorSimilar(image,p,&target) != MagickFalse)
4433 if (IsColorSimilar(image,p,&target) == MagickFalse)
4442 for (y=0; y < (ssize_t) image->rows; y++)
4444 register const PixelPacket
4450 register PixelPacket
4454 Tile fill color onto floodplane.
4456 p=GetVirtualPixels(floodplane_image,0,y,image->columns,1,
4458 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4459 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4461 for (x=0; x < (ssize_t) image->columns; x++)
4463 if (p->opacity != OpaqueOpacity)
4468 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4471 segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
4472 floodplane_image=DestroyImage(floodplane_image);
4473 return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
4477 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4481 % M a x i m u m I m a g e s %
4485 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4487 % MaximumImages() returns the maximum intensity of an image sequence.
4489 % Deprecated, replace with:
4491 % EvaluateImages(images,MinEvaluateOperator,exception);
4493 % The format of the MaxImages method is:
4495 % Image *MaximumImages(Image *images,ExceptionInfo *exception)
4497 % A description of each parameter follows:
4499 % o images: the image sequence.
4501 % o exception: return any errors or warnings in this structure.
4504 MagickExport Image *MaximumImages(const Image *images,ExceptionInfo *exception)
4506 return(EvaluateImages(images,MinEvaluateOperator,exception));
4510 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4514 % M i n i m u m I m a g e s %
4518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4520 % MinimumImages() returns the minimum intensity of an image sequence.
4522 % Deprecated, replace with:
4524 % EvaluateImages(images,MinEvaluateOperator,exception);
4526 % The format of the MinimumImages method is:
4528 % Image *MinimumImages(Image *images,ExceptionInfo *exception)
4530 % A description of each parameter follows:
4532 % o images: the image sequence.
4534 % o exception: return any errors or warnings in this structure.
4537 MagickExport Image *MinimumImages(const Image *images,ExceptionInfo *exception)
4539 return(EvaluateImages(images,MinEvaluateOperator,exception));
4543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4547 % M o s a i c I m a g e s %
4551 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4553 % MosaicImages() Obsolete Function: Use MergeImageLayers() instead.
4555 % Deprecated, replace with:
4557 % MergeImageLayers(image,MosaicLayer,exception);
4559 % The format of the MosaicImage method is:
4561 % Image *MosaicImages(const Image *image,ExceptionInfo *exception)
4563 % A description of each parameter follows:
4565 % o image: the image list to be composited together
4567 % o exception: return any errors or warnings in this structure.
4570 MagickExport Image *MosaicImages(Image *image,ExceptionInfo *exception)
4572 return(MergeImageLayers(image,MosaicLayer,exception));
4576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4580 % O p a q u e I m a g e %
4584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4586 % OpaqueImage() changes any pixel that matches color with the color
4589 % By default color must match a particular pixel color exactly. However,
4590 % in many cases two colors may differ by a small amount. Fuzz defines
4591 % how much tolerance is acceptable to consider two colors as the same.
4592 % For example, set fuzz to 10 and the color red at intensities of 100 and
4593 % 102 respectively are now interpreted as the same color.
4595 % The format of the OpaqueImage method is:
4597 % MagickBooleanType OpaqueImage(Image *image,
4598 % const PixelPacket *target,const PixelPacket fill)
4600 % A description of each parameter follows:
4602 % o image: the image.
4604 % o target: the RGB value of the target color.
4606 % o fill: the replacement color.
4609 MagickExport MagickBooleanType OpaqueImage(Image *image,
4610 const PixelPacket target,const PixelPacket fill)
4612 #define OpaqueImageTag "Opaque/Image"
4624 Make image color opaque.
4626 assert(image != (Image *) NULL);
4627 assert(image->signature == MagickSignature);
4628 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.1.0");
4629 if (image->debug != MagickFalse)
4630 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4631 switch (image->storage_class)
4637 Make DirectClass image opaque.
4639 for (y=0; y < (ssize_t) image->rows; y++)
4644 register PixelPacket
4647 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4648 if (q == (PixelPacket *) NULL)
4650 for (x=0; x < (ssize_t) image->columns; x++)
4652 if (IsColorSimilar(image,q,&target) != MagickFalse)
4656 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4658 proceed=SetImageProgress(image,OpaqueImageTag,(MagickOffsetType) y,
4660 if (proceed == MagickFalse)
4668 Make PseudoClass image opaque.
4670 for (i=0; i < (ssize_t) image->colors; i++)
4672 if (IsColorSimilar(image,&image->colormap[i],&target) != MagickFalse)
4673 image->colormap[i]=fill;
4675 if (fill.opacity != OpaqueOpacity)
4677 for (y=0; y < (ssize_t) image->rows; y++)
4682 register PixelPacket
4685 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4686 if (q == (PixelPacket *) NULL)
4688 for (x=0; x < (ssize_t) image->columns; x++)
4690 if (IsColorSimilar(image,q,&target) != MagickFalse)
4691 q->opacity=fill.opacity;
4694 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4698 (void) SyncImage(image);
4702 if (fill.opacity != OpaqueOpacity)
4703 image->matte=MagickTrue;
4708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4712 % O p e n C a c h e V i e w %
4716 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4718 % OpenCacheView() opens a view into the pixel cache, using the
4719 % VirtualPixelMethod that is defined within the given image itself.
4721 % Deprecated, replace with:
4723 % AcquireCacheView(image);
4725 % The format of the OpenCacheView method is:
4727 % CacheView *OpenCacheView(const Image *image)
4729 % A description of each parameter follows:
4731 % o image: the image.
4734 MagickExport CacheView *OpenCacheView(const Image *image)
4736 return(AcquireCacheView(image));
4740 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4744 % P a i n t F l o o d f i l l I m a g e %
4748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4750 % PaintFloodfill() changes the color value of any pixel that matches
4751 % target and is an immediate neighbor. If the method FillToBorderMethod is
4752 % specified, the color value is changed for any neighbor pixel that does not
4753 % match the bordercolor member of image.
4755 % By default target must match a particular pixel color exactly.
4756 % However, in many cases two colors may differ by a small amount. The
4757 % fuzz member of image defines how much tolerance is acceptable to
4758 % consider two colors as the same. For example, set fuzz to 10 and the
4759 % color red at intensities of 100 and 102 respectively are now
4760 % interpreted as the same color for the purposes of the floodfill.
4762 % Deprecated, replace with:
4764 % FloodfillPaintImage(image,channel,draw_info,target,x,y,
4765 % method == FloodfillMethod ? MagickFalse : MagickTrue);
4767 % The format of the PaintFloodfillImage method is:
4769 % MagickBooleanType PaintFloodfillImage(Image *image,
4770 % const ChannelType channel,const MagickPixelPacket target,const ssize_t x,
4771 % const ssize_t y,const DrawInfo *draw_info,const PaintMethod method)
4773 % A description of each parameter follows:
4775 % o image: the image.
4777 % o channel: the channel(s).
4779 % o target: the RGB value of the target color.
4781 % o x,y: the starting location of the operation.
4783 % o draw_info: the draw info.
4785 % o method: Choose either FloodfillMethod or FillToBorderMethod.
4788 MagickExport MagickBooleanType PaintFloodfillImage(Image *image,
4789 const ChannelType channel,const MagickPixelPacket *target,const ssize_t x,
4790 const ssize_t y,const DrawInfo *draw_info,const PaintMethod method)
4795 status=FloodfillPaintImage(image,channel,draw_info,target,x,y,
4796 method == FloodfillMethod ? MagickFalse : MagickTrue);
4801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4804 % P a i n t O p a q u e I m a g e %
4807 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4809 % PaintOpaqueImage() changes any pixel that matches color with the color
4812 % By default color must match a particular pixel color exactly. However,
4813 % in many cases two colors may differ by a small amount. Fuzz defines
4814 % how much tolerance is acceptable to consider two colors as the same.
4815 % For example, set fuzz to 10 and the color red at intensities of 100 and
4816 % 102 respectively are now interpreted as the same color.
4818 % Deprecated, replace with:
4820 % OpaquePaintImageChannel(image,DefaultChannels,target,fill,MagickFalse);
4821 % OpaquePaintImageChannel(image,channel,target,fill,MagickFalse);
4823 % The format of the PaintOpaqueImage method is:
4825 % MagickBooleanType PaintOpaqueImage(Image *image,
4826 % const PixelPacket *target,const PixelPacket *fill)
4827 % MagickBooleanType PaintOpaqueImageChannel(Image *image,
4828 % const ChannelType channel,const PixelPacket *target,
4829 % const PixelPacket *fill)
4831 % A description of each parameter follows:
4833 % o image: the image.
4835 % o channel: the channel(s).
4837 % o target: the RGB value of the target color.
4839 % o fill: the replacement color.
4843 MagickExport MagickBooleanType PaintOpaqueImage(Image *image,
4844 const MagickPixelPacket *target,const MagickPixelPacket *fill)
4849 status=OpaquePaintImageChannel(image,DefaultChannels,target,fill,MagickFalse);
4853 MagickExport MagickBooleanType PaintOpaqueImageChannel(Image *image,
4854 const ChannelType channel,const MagickPixelPacket *target,
4855 const MagickPixelPacket *fill)
4857 return(OpaquePaintImageChannel(image,channel,target,fill,MagickFalse));
4861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4865 % P a i n t T r a n s p a r e n t I m a g e %
4869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4871 % PaintTransparentImage() changes the opacity value associated with any pixel
4872 % that matches color to the value defined by opacity.
4874 % By default color must match a particular pixel color exactly. However,
4875 % in many cases two colors may differ by a small amount. Fuzz defines
4876 % how much tolerance is acceptable to consider two colors as the same.
4877 % For example, set fuzz to 10 and the color red at intensities of 100 and
4878 % 102 respectively are now interpreted as the same color.
4880 % Deprecated, replace with:
4882 % TransparentPaintImage(image,target,opacity,MagickFalse);
4884 % The format of the PaintTransparentImage method is:
4886 % MagickBooleanType PaintTransparentImage(Image *image,
4887 % const MagickPixelPacket *target,const Quantum opacity)
4889 % A description of each parameter follows:
4891 % o image: the image.
4893 % o target: the RGB value of the target color.
4895 % o opacity: the replacement opacity value.
4898 MagickExport MagickBooleanType PaintTransparentImage(Image *image,
4899 const MagickPixelPacket *target,const Quantum opacity)
4901 return(TransparentPaintImage(image,target,opacity,MagickFalse));
4905 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4909 + P a r s e I m a g e G e o m e t r y %
4913 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4915 % ParseImageGeometry() is similar to GetGeometry() except the returned
4916 % geometry is modified as determined by the meta characters: %, !, <,
4919 % Deprecated, replace with:
4921 % ParseMetaGeometry(geometry,x,y,width,height);
4923 % The format of the ParseImageGeometry method is:
4925 % int ParseImageGeometry(char *geometry,ssize_t *x,ssize_t *y,
4926 % size_t *width,size_t *height)
4928 % A description of each parameter follows:
4930 % o flags: Method ParseImageGeometry returns a bitmask that indicates
4931 % which of the four values were located in the geometry string.
4933 % o image_geometry: Specifies a character string representing the geometry
4936 % o x,y: A pointer to an integer. The x and y offset as determined by
4937 % the geometry specification is returned here.
4939 % o width,height: A pointer to an unsigned integer. The width and height
4940 % as determined by the geometry specification is returned here.
4943 MagickExport int ParseImageGeometry(const char *geometry,ssize_t *x,ssize_t *y,
4944 size_t *width,size_t *height)
4946 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
4947 return((int) ParseMetaGeometry(geometry,x,y,width,height));
4951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4955 % P a r s e S i z e G e o m e t r y %
4959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4961 % ParseSizeGeometry() returns a region as defined by the geometry string with
4962 % respect to the image dimensions and aspect ratio.
4964 % Deprecated, replace with:
4966 % ParseMetaGeometry(geometry,®ion_info->x,®ion_info->y,
4967 % ®ion_info->width,®ion_info->height);
4969 % The format of the ParseSizeGeometry method is:
4971 % MagickStatusType ParseSizeGeometry(const Image *image,
4972 % const char *geometry,RectangeInfo *region_info)
4974 % A description of each parameter follows:
4976 % o geometry: The geometry (e.g. 100x100+10+10).
4978 % o region_info: the region as defined by the geometry string.
4981 MagickExport MagickStatusType ParseSizeGeometry(const Image *image,
4982 const char *geometry,RectangleInfo *region_info)
4987 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.4.7");
4988 SetGeometry(image,region_info);
4989 flags=ParseMetaGeometry(geometry,®ion_info->x,®ion_info->y,
4990 ®ion_info->width,®ion_info->height);
4995 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4999 % P o p I m a g e L i s t %
5003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5005 % PopImageList() removes the last image in the list.
5007 % Deprecated, replace with:
5009 % RemoveLastImageFromList(images);
5011 % The format of the PopImageList method is:
5013 % Image *PopImageList(Image **images)
5015 % A description of each parameter follows:
5017 % o images: the image list.
5020 MagickExport Image *PopImageList(Image **images)
5022 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5023 return(RemoveLastImageFromList(images));
5027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5031 % P o p I m a g e P i x e l s %
5035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5037 % PopImagePixels() transfers one or more pixel components from the image pixel
5038 % cache to a user supplied buffer. The pixels are returned in network byte
5039 % order. MagickTrue is returned if the pixels are successfully transferred,
5040 % otherwise MagickFalse.
5042 % The format of the PopImagePixels method is:
5044 % size_t PopImagePixels(Image *,const QuantumType quantum,
5045 % unsigned char *destination)
5047 % A description of each parameter follows:
5049 % o image: the image.
5051 % o quantum: Declare which pixel components to transfer (RGB, RGBA, etc).
5053 % o destination: The components are transferred to this buffer.
5056 MagickExport size_t PopImagePixels(Image *image,const QuantumType quantum,
5057 unsigned char *destination)
5065 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
5066 if (quantum_info == (QuantumInfo *) NULL)
5068 length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
5069 quantum,destination,&image->exception);
5070 quantum_info=DestroyQuantumInfo(quantum_info);
5075 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5079 % P o s t s c r i p t G e o m e t r y %
5083 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5085 % PostscriptGeometry() replaces any page mneumonic with the equivalent size in
5088 % Deprecated, replace with:
5090 % GetPageGeometry(page);
5092 % The format of the PostscriptGeometry method is:
5094 % char *PostscriptGeometry(const char *page)
5096 % A description of each parameter follows.
5098 % o page: Specifies a pointer to an array of characters.
5099 % The string is either a Postscript page name (e.g. A4) or a postscript
5100 % page geometry (e.g. 612x792+36+36).
5103 MagickExport char *PostscriptGeometry(const char *page)
5105 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
5106 return(GetPageGeometry(page));
5110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5114 % P u s h I m a g e L i s t %
5118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5120 % PushImageList() adds an image to the end of the list.
5122 % Deprecated, replace with:
5124 % AppendImageToList(images,CloneImageList(image,exception));
5126 % The format of the PushImageList method is:
5128 % unsigned int PushImageList(Image *images,const Image *image,
5129 % ExceptionInfo *exception)
5131 % A description of each parameter follows:
5133 % o images: the image list.
5135 % o image: the image.
5137 % o exception: return any errors or warnings in this structure.
5140 MagickExport unsigned int PushImageList(Image **images,const Image *image,
5141 ExceptionInfo *exception)
5143 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5144 AppendImageToList(images,CloneImageList(image,exception));
5149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5153 % P u s h I m a g e P i x e l s %
5157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5159 % PushImagePixels() transfers one or more pixel components from a user
5160 % supplied buffer into the image pixel cache of an image. The pixels are
5161 % expected in network byte order. It returns MagickTrue if the pixels are
5162 % successfully transferred, otherwise MagickFalse.
5164 % The format of the PushImagePixels method is:
5166 % size_t PushImagePixels(Image *image,const QuantumType quantum,
5167 % const unsigned char *source)
5169 % A description of each parameter follows:
5171 % o image: the image.
5173 % o quantum: Declare which pixel components to transfer (red, green, blue,
5174 % opacity, RGB, or RGBA).
5176 % o source: The pixel components are transferred from this buffer.
5179 MagickExport size_t PushImagePixels(Image *image,const QuantumType quantum,
5180 const unsigned char *source)
5188 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
5189 if (quantum_info == (QuantumInfo *) NULL)
5191 length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,quantum,
5192 source,&image->exception);
5193 quantum_info=DestroyQuantumInfo(quantum_info);
5198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5202 % Q u a n t i z a t i o n E r r o r %
5206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5208 % QuantizationError() measures the difference between the original and
5209 % quantized images. This difference is the total quantization error. The
5210 % error is computed by summing over all pixels in an image the distance
5211 % squared in RGB space between each reference pixel value and its quantized
5212 % value. These values are computed:
5214 % o mean_error_per_pixel: This value is the mean error for any single
5215 % pixel in the image.
5217 % o normalized_mean_square_error: This value is the normalized mean
5218 % quantization error for any single pixel in the image. This distance
5219 % measure is normalized to a range between 0 and 1. It is independent
5220 % of the range of red, green, and blue values in the image.
5222 % o normalized_maximum_square_error: Thsi value is the normalized
5223 % maximum quantization error for any single pixel in the image. This
5224 % distance measure is normalized to a range between 0 and 1. It is
5225 % independent of the range of red, green, and blue values in your image.
5227 % Deprecated, replace with:
5229 % GetImageQuantizeError(image);
5231 % The format of the QuantizationError method is:
5233 % unsigned int QuantizationError(Image *image)
5235 % A description of each parameter follows.
5237 % o image: Specifies a pointer to an Image structure; returned from
5241 MagickExport unsigned int QuantizationError(Image *image)
5243 if (image->debug != MagickFalse)
5244 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.3");
5245 return(GetImageQuantizeError(image));
5249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5252 % 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 %
5256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5258 % RandomChannelThresholdImage() changes the value of individual pixels based
5259 % on the intensity of each pixel compared to a random threshold. The result
5260 % is a low-contrast, two color image.
5262 % The format of the RandomChannelThresholdImage method is:
5264 % unsigned int RandomChannelThresholdImage(Image *image,
5265 % const char *channel, const char *thresholds,
5266 % ExceptionInfo *exception)
5268 % A description of each parameter follows:
5270 % o image: the image.
5272 % o channel: the channel or channels to be thresholded.
5274 % o thresholds: a geometry string containing LOWxHIGH thresholds.
5275 % If the string contains 2x2, 3x3, or 4x4, then an ordered
5276 % dither of order 2, 3, or 4 will be performed instead.
5278 % o exception: return any errors or warnings in this structure.
5281 MagickExport unsigned int RandomChannelThresholdImage(Image *image,const char
5282 *channel,const char *thresholds,ExceptionInfo *exception)
5284 #define RandomChannelThresholdImageText " RandomChannelThreshold image... "
5297 static MagickRealType
5298 o2[4]={0.2f, 0.6f, 0.8f, 0.4f},
5299 o3[9]={0.1f, 0.6f, 0.3f, 0.7f, 0.5f, 0.8f, 0.4f, 0.9f, 0.2f},
5300 o4[16]={0.1f, 0.7f, 1.1f, 0.3f, 1.0f, 0.5f, 1.5f, 0.8f, 1.4f, 1.6f, 0.6f,
5301 1.2f, 0.4f, 0.9f, 1.3f, 0.2f},
5310 assert(image != (Image *) NULL);
5311 assert(image->signature == MagickSignature);
5312 if (image->debug != MagickFalse)
5313 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
5314 assert(exception != (ExceptionInfo *) NULL);
5315 assert(exception->signature == MagickSignature);
5316 if (image->debug != MagickFalse)
5317 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5318 if (thresholds == (const char *) NULL)
5320 if (LocaleCompare(thresholds,"2x2") == 0)
5323 if (LocaleCompare(thresholds,"3x3") == 0)
5326 if (LocaleCompare(thresholds,"4x4") == 0)
5333 count=(ssize_t) sscanf(thresholds,"%lf[/x%%]%lf",&lower_threshold,
5335 if (strchr(thresholds,'%') != (char *) NULL)
5337 upper_threshold*=(.01*QuantumRange);
5338 lower_threshold*=(.01*QuantumRange);
5341 upper_threshold=(MagickRealType) QuantumRange-lower_threshold;
5343 if (image->debug != MagickFalse)
5344 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
5345 " RandomChannelThresholdImage: channel type=%s",channel);
5346 if (image->debug != MagickFalse)
5347 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
5348 " Thresholds: %s (%fx%f)",thresholds,lower_threshold,upper_threshold);
5349 if (LocaleCompare(channel,"all") == 0 ||
5350 LocaleCompare(channel,"intensity") == 0)
5351 if (AcquireImageColormap(image,2) == MagickFalse)
5352 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
5354 random_info=AcquireRandomInfo();
5355 for (y=0; y < (ssize_t) image->rows; y++)
5360 register IndexPacket
5364 register PixelPacket
5367 q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
5368 if (q == (PixelPacket *) NULL)
5370 if (LocaleCompare(channel,"all") == 0 ||
5371 LocaleCompare(channel,"intensity") == 0)
5373 indexes=GetAuthenticIndexQueue(image);
5374 for (x=0; x < (ssize_t) image->columns; x++)
5379 intensity=(MagickRealType) PixelIntensityToQuantum(q);
5382 if (intensity < lower_threshold)
5383 threshold=lower_threshold;
5384 else if (intensity > upper_threshold)
5385 threshold=upper_threshold;
5387 threshold=(MagickRealType) (QuantumRange*
5388 GetPseudoRandomValue(random_info));
5390 else if (order == 2)
5391 threshold=(MagickRealType) QuantumRange*o2[(x%2)+2*(y%2)];
5392 else if (order == 3)
5393 threshold=(MagickRealType) QuantumRange*o3[(x%3)+3*(y%3)];
5394 else if (order == 4)
5395 threshold=(MagickRealType) QuantumRange*o4[(x%4)+4*(y%4)];
5396 q->red=q->green=q->blue=(Quantum) (intensity <=
5397 threshold ? 0 : QuantumRange);
5398 index=(IndexPacket) (intensity <= threshold ? 0 : 1);
5400 q->red=q->green=q->blue=image->colormap[(ssize_t) index].red;
5404 if (LocaleCompare(channel,"opacity") == 0 ||
5405 LocaleCompare(channel,"all") == 0 ||
5406 LocaleCompare(channel,"matte") == 0)
5408 if (image->matte != MagickFalse)
5409 for (x=0; x < (ssize_t) image->columns; x++)
5413 if ((MagickRealType) q->opacity < lower_threshold)
5414 threshold=lower_threshold;
5415 else if ((MagickRealType) q->opacity > upper_threshold)
5416 threshold=upper_threshold;
5418 threshold=(MagickRealType) (QuantumRange*
5419 GetPseudoRandomValue(random_info));
5421 else if (order == 2)
5422 threshold=(MagickRealType) QuantumRange*o2[(x%2)+2*(y%2)];
5423 else if (order == 3)
5424 threshold=(MagickRealType) QuantumRange*o3[(x%3)+3*(y%3)];
5425 else if (order == 4)
5426 threshold=(MagickRealType) QuantumRange*o4[(x%4)+4*(y%4)]/1.7;
5427 q->opacity=(Quantum) ((MagickRealType) q->opacity <= threshold ?
5434 /* To Do: red, green, blue, cyan, magenta, yellow, black */
5435 if (LocaleCompare(channel,"intensity") != 0)
5436 ThrowBinaryException(OptionError,"UnrecognizedChannelType",
5439 if (SyncAuthenticPixels(image,exception) == MagickFalse)
5442 random_info=DestroyRandomInfo(random_info);
5447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5451 % R e a c q u i r e M e m o r y %
5455 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5457 % ReacquireMemory() changes the size of the memory and returns a pointer to
5458 % the (possibly moved) block. The contents will be unchanged up to the
5459 % lesser of the new and old sizes.
5461 % The format of the ReacquireMemory method is:
5463 % void ReacquireMemory(void **memory,const size_t size)
5465 % A description of each parameter follows:
5467 % o memory: A pointer to a memory allocation. On return the pointer
5468 % may change but the contents of the original allocation will not.
5470 % o size: the new size of the allocated memory.
5473 MagickExport void ReacquireMemory(void **memory,const size_t size)
5478 assert(memory != (void **) NULL);
5479 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5480 if (*memory == (void *) NULL)
5482 *memory=AcquireMagickMemory(size);
5485 allocation=realloc(*memory,size);
5486 if (allocation == (void *) NULL)
5487 *memory=RelinquishMagickMemory(*memory);
5492 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5496 % R e c o l o r I m a g e %
5500 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5502 % RecolorImage() apply color transformation to an image. The method permits
5503 % saturation changes, hue rotation, luminance to alpha, and various other
5504 % effects. Although variable-sized transformation matrices can be used,
5505 % typically one uses a 5x5 matrix for an RGBA image and a 6x6 for CMYKA
5506 % (or RGBA with offsets). The matrix is similar to those used by Adobe Flash
5507 % except offsets are in column 6 rather than 5 (in support of CMYKA images)
5508 % and offsets are normalized (divide Flash offset by 255).
5510 % The format of the RecolorImage method is:
5512 % Image *RecolorImage(const Image *image,const size_t order,
5513 % const double *color_matrix,ExceptionInfo *exception)
5515 % A description of each parameter follows:
5517 % o image: the image.
5519 % o order: the number of columns and rows in the recolor matrix.
5521 % o color_matrix: An array of double representing the recolor matrix.
5523 % o exception: return any errors or warnings in this structure.
5526 MagickExport Image *RecolorImage(const Image *image,const size_t order,
5527 const double *color_matrix,ExceptionInfo *exception)
5535 kernel_info=AcquireKernelInfo("1");
5536 if (kernel_info == (KernelInfo *) NULL)
5537 return((Image *) NULL);
5538 kernel_info->width=order;
5539 kernel_info->height=order;
5540 kernel_info->values=(double *) color_matrix;
5541 recolor_image=ColorMatrixImage(image,kernel_info,exception);
5542 kernel_info->values=(double *) NULL;
5543 kernel_info=DestroyKernelInfo(kernel_info);
5544 return(recolor_image);
5548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5552 % 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 %
5556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5558 % ResetImageAttributeIterator() resets the image attributes iterator. Use it
5559 % in conjunction with GetNextImageAttribute() to iterate over all the values
5560 % associated with an image.
5562 % Deprecated, replace with:
5564 % ResetImagePropertyIterator(image);
5566 % The format of the ResetImageAttributeIterator method is:
5568 % ResetImageAttributeIterator(const ImageInfo *image)
5570 % A description of each parameter follows:
5572 % o image: the image.
5575 MagickExport void ResetImageAttributeIterator(const Image *image)
5577 ResetImagePropertyIterator(image);
5581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5585 % S e t C a c h e V i e w P i x e l s %
5589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5591 % SetCacheViewPixels() gets pixels from the in-memory or disk pixel cache as
5592 % defined by the geometry parameters. A pointer to the pixels is returned
5593 % if the pixels are transferred, otherwise a NULL is returned.
5595 % Deprecated, replace with:
5597 % QueueCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
5598 % GetCacheViewException(cache_view));
5600 % The format of the SetCacheViewPixels method is:
5602 % PixelPacket *SetCacheViewPixels(CacheView *cache_view,const ssize_t x,
5603 % const ssize_t y,const size_t columns,const size_t rows)
5605 % A description of each parameter follows:
5607 % o cache_view: the cache view.
5609 % o x,y,columns,rows: These values define the perimeter of a region of
5613 MagickExport PixelPacket *SetCacheViewPixels(CacheView *cache_view,const ssize_t x,
5614 const ssize_t y,const size_t columns,const size_t rows)
5619 pixels=QueueCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
5620 GetCacheViewException(cache_view));
5625 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5629 + S e t C a c h e T h e s h o l d %
5633 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5635 % SetCacheThreshold() sets the amount of free memory allocated for the pixel
5636 % cache. Once this threshold is exceeded, all subsequent pixels cache
5637 % operations are to/from disk.
5639 % The format of the SetCacheThreshold() method is:
5641 % void SetCacheThreshold(const size_t threshold)
5643 % A description of each parameter follows:
5645 % o threshold: the number of megabytes of memory available to the pixel
5649 MagickExport void SetCacheThreshold(const size_t size)
5651 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
5652 (void) SetMagickResourceLimit(MemoryResource,size*1024*1024);
5653 (void) SetMagickResourceLimit(MapResource,2*size*1024*1024);
5657 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5661 % S e t E x c e p t i o n I n f o %
5665 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5667 % SetExceptionInfo() sets the exception severity.
5669 % The format of the SetExceptionInfo method is:
5671 % MagickBooleanType SetExceptionInfo(ExceptionInfo *exception,
5672 % ExceptionType severity)
5674 % A description of each parameter follows:
5676 % o exception: the exception info.
5678 % o severity: the exception severity.
5681 MagickExport MagickBooleanType SetExceptionInfo(ExceptionInfo *exception,
5682 ExceptionType severity)
5684 assert(exception != (ExceptionInfo *) NULL);
5685 ClearMagickException(exception);
5686 exception->severity=severity;
5691 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5699 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5701 % SetImage() sets the red, green, and blue components of each pixel to
5702 % the image background color and the opacity component to the specified
5703 % level of transparency. The background color is defined by the
5704 % background_color member of the image.
5706 % The format of the SetImage method is:
5708 % void SetImage(Image *image,const Quantum opacity)
5710 % A description of each parameter follows:
5712 % o image: the image.
5714 % o opacity: Set each pixel to this level of transparency.
5717 MagickExport void SetImage(Image *image,const Quantum opacity)
5725 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.0");
5726 assert(image != (Image *) NULL);
5727 if (image->debug != MagickFalse)
5728 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
5729 assert(image->signature == MagickSignature);
5730 background_color=image->background_color;
5731 if (opacity != OpaqueOpacity)
5732 background_color.opacity=opacity;
5733 if (background_color.opacity != OpaqueOpacity)
5735 (void) SetImageStorageClass(image,DirectClass);
5736 image->matte=MagickTrue;
5738 if ((image->storage_class == PseudoClass) ||
5739 (image->colorspace == CMYKColorspace))
5742 Set colormapped or CMYK image.
5744 for (y=0; y < (ssize_t) image->rows; y++)
5746 register IndexPacket
5752 register PixelPacket
5755 q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
5756 if (q == (PixelPacket *) NULL)
5758 for (x=0; x < (ssize_t) image->columns; x++)
5759 *q++=background_color;
5760 indexes=GetAuthenticIndexQueue(image);
5761 for (x=0; x < (ssize_t) image->columns; x++)
5762 indexes[x]=(IndexPacket) 0;
5763 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
5769 Set DirectClass image.
5771 for (y=0; y < (ssize_t) image->rows; y++)
5776 register PixelPacket
5779 q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
5780 if (q == (PixelPacket *) NULL)
5782 for (x=0; x < (ssize_t) image->columns; x++)
5783 *q++=background_color;
5784 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
5790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5794 % S e t I m a g e A t t r i b u t e %
5798 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5800 % SetImageAttribute() searches the list of image attributes and replaces the
5801 % attribute value. If it is not found in the list, the attribute name
5802 % and value is added to the list.
5804 % Deprecated, replace with:
5806 % SetImageProperty(image,key,value);
5808 % The format of the SetImageAttribute method is:
5810 % MagickBooleanType SetImageAttribute(Image *image,const char *key,
5811 % const char *value)
5813 % A description of each parameter follows:
5815 % o image: the image.
5819 % o value: the value.
5822 MagickExport MagickBooleanType SetImageAttribute(Image *image,const char *key,
5825 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
5826 return(SetImageProperty(image,key,value));
5830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5834 % S e t I m a g e L i s t %
5838 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5840 % SetImageList() inserts an image into the list at the specified position.
5842 % The format of the SetImageList method is:
5844 % unsigned int SetImageList(Image *images,const Image *image,
5845 % const ssize_t offset,ExceptionInfo *exception)
5847 % A description of each parameter follows:
5849 % o images: the image list.
5851 % o image: the image.
5853 % o offset: the position within the list.
5855 % o exception: return any errors or warnings in this structure.
5858 MagickExport unsigned int SetImageList(Image **images,const Image *image,
5859 const ssize_t offset,ExceptionInfo *exception)
5867 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5868 clone=CloneImageList(image,exception);
5869 while (GetPreviousImageInList(*images) != (Image *) NULL)
5870 (*images)=GetPreviousImageInList(*images);
5871 for (i=0; i < offset; i++)
5873 if (GetNextImageInList(*images) == (Image *) NULL)
5874 return(MagickFalse);
5875 (*images)=GetNextImageInList(*images);
5877 InsertImageInList(images,clone);
5882 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5886 % S e t I m a g e P i x e l s %
5890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5892 % SetImagePixels() queues a mutable pixel region.
5893 % If the region is successfully intialized a pointer to a PixelPacket
5894 % array representing the region is returned, otherwise NULL is returned.
5895 % The returned pointer may point to a temporary working buffer for the
5896 % pixels or it may point to the final location of the pixels in memory.
5898 % Write-only access means that any existing pixel values corresponding to
5899 % the region are ignored. This useful while the initial image is being
5900 % created from scratch, or if the existing pixel values are to be
5901 % completely replaced without need to refer to their pre-existing values.
5902 % The application is free to read and write the pixel buffer returned by
5903 % SetImagePixels() any way it pleases. SetImagePixels() does not initialize
5904 % the pixel array values. Initializing pixel array values is the
5905 % application's responsibility.
5907 % Performance is maximized if the selected region is part of one row, or
5908 % one or more full rows, since then there is opportunity to access the
5909 % pixels in-place (without a copy) if the image is in RAM, or in a
5910 % memory-mapped file. The returned pointer should *never* be deallocated
5913 % Pixels accessed via the returned pointer represent a simple array of type
5914 % PixelPacket. If the image type is CMYK or the storage class is PseudoClass,
5915 % call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to obtain
5916 % the black color component or the colormap indexes (of type IndexPacket)
5917 % corresponding to the region. Once the PixelPacket (and/or IndexPacket)
5918 % array has been updated, the changes must be saved back to the underlying
5919 % image using SyncAuthenticPixels() or they may be lost.
5921 % Deprecated, replace with:
5923 % QueueAuthenticPixels(image,x,y,columns,rows,&image->exception);
5925 % The format of the SetImagePixels() method is:
5927 % PixelPacket *SetImagePixels(Image *image,const ssize_t x,const ssize_t y,
5928 % const size_t columns,const size_t rows)
5930 % A description of each parameter follows:
5932 % o pixels: SetImagePixels returns a pointer to the pixels if they are
5933 % transferred, otherwise a NULL is returned.
5935 % o image: the image.
5937 % o x,y,columns,rows: These values define the perimeter of a region of
5941 MagickExport PixelPacket *SetImagePixels(Image *image,const ssize_t x,const ssize_t y,
5942 const size_t columns,const size_t rows)
5944 return(QueueAuthenticPixels(image,x,y,columns,rows,&image->exception));
5948 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5952 % S e t M a g i c k R e g i s t r y %
5956 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5958 % SetMagickRegistry() sets a blob into the registry and returns a unique ID.
5959 % If an error occurs, -1 is returned.
5961 % The format of the SetMagickRegistry method is:
5963 % ssize_t SetMagickRegistry(const RegistryType type,const void *blob,
5964 % const size_t length,ExceptionInfo *exception)
5966 % A description of each parameter follows:
5968 % o type: the registry type.
5970 % o blob: the address of a Binary Large OBject.
5972 % o length: For a registry type of ImageRegistryType use sizeof(Image)
5973 % otherise the blob length in number of bytes.
5975 % o exception: return any errors or warnings in this structure.
5978 MagickExport ssize_t SetMagickRegistry(const RegistryType type,const void *blob,
5979 const size_t magick_unused(length),ExceptionInfo *exception)
5990 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",(long) id);
5991 status=SetImageRegistry(type,key,blob,exception);
5992 if (status == MagickFalse)
5998 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6002 % S e t M o n i t o r H a n d l e r %
6006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6008 % SetMonitorHandler() sets the monitor handler to the specified method
6009 % and returns the previous monitor handler.
6011 % The format of the SetMonitorHandler method is:
6013 % MonitorHandler SetMonitorHandler(MonitorHandler handler)
6015 % A description of each parameter follows:
6017 % o handler: Specifies a pointer to a method to handle monitors.
6021 MagickExport MonitorHandler GetMonitorHandler(void)
6023 return(monitor_handler);
6026 MagickExport MonitorHandler SetMonitorHandler(MonitorHandler handler)
6031 previous_handler=monitor_handler;
6032 monitor_handler=handler;
6033 return(previous_handler);
6037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6041 % S h i f t I m a g e L i s t %
6045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6047 % ShiftImageList() removes an image from the beginning of the list.
6049 % Deprecated, replace with:
6051 % RemoveFirstImageFromList(images);
6053 % The format of the ShiftImageList method is:
6055 % Image *ShiftImageList(Image **images)
6057 % A description of each parameter follows:
6059 % o images: the image list.
6062 MagickExport Image *ShiftImageList(Image **images)
6064 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
6065 return(RemoveFirstImageFromList(images));
6069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6079 % SizeBlob() returns the current length of the image file or blob.
6081 % Deprecated, replace with:
6083 % GetBlobSize(image);
6085 % The format of the SizeBlob method is:
6087 % off_t SizeBlob(Image *image)
6089 % A description of each parameter follows:
6091 % o size: Method SizeBlob returns the current length of the image file
6094 % o image: the image.
6097 MagickExport MagickOffsetType SizeBlob(Image *image)
6099 if (image->debug != MagickFalse)
6100 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.3");
6101 return((MagickOffsetType) GetBlobSize(image));
6105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6109 % S p l i c e I m a g e L i s t %
6113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6115 % SpliceImageList() removes the images designated by offset and length from
6116 % the list and replaces them with the specified list.
6118 % The format of the SpliceImageList method is:
6120 % Image *SpliceImageList(Image *images,const ssize_t offset,
6121 % const size_t length,const Image *splices,
6122 % ExceptionInfo *exception)
6124 % A description of each parameter follows:
6126 % o images: the image list.
6128 % o offset: the position within the list.
6130 % o length: the length of the image list to remove.
6132 % o splice: Replace the removed image list with this list.
6134 % o exception: return any errors or warnings in this structure.
6137 MagickExport Image *SpliceImageList(Image *images,const ssize_t offset,
6138 const size_t length,const Image *splices,ExceptionInfo *exception)
6146 if (images->debug != MagickFalse)
6147 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
6148 clone=CloneImageList(splices,exception);
6149 while (GetPreviousImageInList(images) != (Image *) NULL)
6150 images=GetPreviousImageInList(images);
6151 for (i=0; i < offset; i++)
6153 if (GetNextImageInList(images) == (Image *) NULL)
6154 return((Image *) NULL);
6155 images=GetNextImageInList(images);
6157 (void) SpliceImageIntoList(&images,length,clone);
6162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6172 % Strip() strips any whitespace or quotes from the beginning and end of a
6173 % string of characters.
6175 % The format of the Strip method is:
6177 % void Strip(char *message)
6179 % A description of each parameter follows:
6181 % o message: Specifies an array of characters.
6184 MagickExport void Strip(char *message)
6190 assert(message != (char *) NULL);
6191 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
6192 if (*message == '\0')
6194 if (strlen(message) == 1)
6197 while (isspace((int) ((unsigned char) *p)) != 0)
6199 if ((*p == '\'') || (*p == '"'))
6201 q=message+strlen(message)-1;
6202 while ((isspace((int) ((unsigned char) *q)) != 0) && (q > p))
6205 if ((*q == '\'') || (*q == '"'))
6207 (void) CopyMagickMemory(message,p,(size_t) (q-p+1));
6208 message[q-p+1]='\0';
6212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6216 % S y n c C a c h e V i e w %
6220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6222 % SyncCacheView() saves the cache view pixels to the in-memory or disk
6223 % cache. It returns MagickTrue if the pixel region is synced, otherwise
6226 % Deprecated, replace with:
6228 % SyncCacheViewAuthenticPixels(cache_view,GetCacheViewException(cache_view));
6230 % The format of the SyncCacheView method is:
6232 % MagickBooleanType SyncCacheView(CacheView *cache_view)
6234 % A description of each parameter follows:
6236 % o cache_view: the cache view.
6239 MagickExport MagickBooleanType SyncCacheView(CacheView *cache_view)
6244 status=SyncCacheViewAuthenticPixels(cache_view,
6245 GetCacheViewException(cache_view));
6250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6254 % S y n c C a c h e V i e w P i x e l s %
6258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6260 % SyncCacheViewPixels() saves the cache view pixels to the in-memory
6261 % or disk cache. It returns MagickTrue if the pixel region is flushed,
6262 % otherwise MagickFalse.
6264 % Deprecated, replace with:
6266 % SyncCacheViewAuthenticPixels(cache_view,GetCacheViewException(cache_view));
6268 % The format of the SyncCacheViewPixels method is:
6270 % MagickBooleanType SyncCacheViewPixels(CacheView *cache_view)
6272 % A description of each parameter follows:
6274 % o cache_view: the cache view.
6276 % o exception: return any errors or warnings in this structure.
6279 MagickExport MagickBooleanType SyncCacheViewPixels(CacheView *cache_view)
6284 status=SyncCacheViewAuthenticPixels(cache_view,
6285 GetCacheViewException(cache_view));
6290 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6294 % S y n c I m a g e P i x e l s %
6298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6300 % SyncImagePixels() saves the image pixels to the in-memory or disk cache.
6301 % The method returns MagickTrue if the pixel region is synced, otherwise
6304 % Deprecated, replace with:
6306 % SyncAuthenticPixels(image,&image->exception);
6308 % The format of the SyncImagePixels() method is:
6310 % MagickBooleanType SyncImagePixels(Image *image)
6312 % A description of each parameter follows:
6314 % o image: the image.
6317 MagickExport MagickBooleanType SyncImagePixels(Image *image)
6319 return(SyncAuthenticPixels(image,&image->exception));
6323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6327 % T e m p o r a r y F i l e n a m e %
6331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6333 % TemporaryFilename() replaces the contents of path by a unique path name.
6335 % The format of the TemporaryFilename method is:
6337 % void TemporaryFilename(char *path)
6339 % A description of each parameter follows.
6341 % o path: Specifies a pointer to an array of characters. The unique path
6342 % name is returned in this array.
6345 MagickExport void TemporaryFilename(char *path)
6347 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
6348 (void) AcquireUniqueFilename(path);
6349 (void) RelinquishUniqueFileResource(path);
6353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6357 % T h r e s h o l d I m a g e %
6361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6363 % ThresholdImage() changes the value of individual pixels based on
6364 % the intensity of each pixel compared to threshold. The result is a
6365 % high-contrast, two color image.
6367 % The format of the ThresholdImage method is:
6369 % unsigned int ThresholdImage(Image *image,const double threshold)
6371 % A description of each parameter follows:
6373 % o image: the image.
6375 % o threshold: Define the threshold value
6378 MagickExport unsigned int ThresholdImage(Image *image,const double threshold)
6380 #define ThresholdImageTag "Threshold/Image"
6391 assert(image != (Image *) NULL);
6392 assert(image->signature == MagickSignature);
6393 if (image->debug != MagickFalse)
6394 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6395 if (image->debug != MagickFalse)
6396 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
6397 if (!AcquireImageColormap(image,2))
6398 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
6399 "UnableToThresholdImage");
6400 for (y=0; y < (ssize_t) image->rows; y++)
6402 register IndexPacket
6408 register PixelPacket
6411 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6412 if (q == (PixelPacket *) NULL)
6414 indexes=GetAuthenticIndexQueue(image);
6415 for (x=0; x < (ssize_t) image->columns; x++)
6417 index=(IndexPacket) ((MagickRealType)
6418 PixelIntensityToQuantum(q) <= threshold ? 0 : 1);
6420 q->red=image->colormap[(ssize_t) index].red;
6421 q->green=image->colormap[(ssize_t) index].green;
6422 q->blue=image->colormap[(ssize_t) index].blue;
6425 if (!SyncAuthenticPixels(image,&image->exception))
6432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6436 % T h r e s h o l d I m a g e C h a n n e l %
6440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6442 % ThresholdImageChannel() changes the value of individual pixels based on
6443 % the intensity of each pixel channel. The result is a high-contrast image.
6445 % The format of the ThresholdImageChannel method is:
6447 % unsigned int ThresholdImageChannel(Image *image,const char *threshold)
6449 % A description of each parameter follows:
6451 % o image: the image.
6453 % o threshold: define the threshold values.
6456 MagickExport unsigned int ThresholdImageChannel(Image *image,
6457 const char *threshold)
6459 #define ThresholdImageTag "Threshold/Image"
6479 assert(image != (Image *) NULL);
6480 assert(image->signature == MagickSignature);
6481 if (image->debug != MagickFalse)
6482 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6483 if (threshold == (const char *) NULL)
6485 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
6486 return(MagickFalse);
6487 flags=ParseGeometry(threshold,&geometry_info);
6488 pixel.red=geometry_info.rho;
6489 if (flags & SigmaValue)
6490 pixel.green=geometry_info.sigma;
6492 pixel.green=pixel.red;
6493 if (flags & XiValue)
6494 pixel.blue=geometry_info.xi;
6496 pixel.blue=pixel.red;
6497 if (flags & PsiValue)
6498 pixel.opacity=geometry_info.psi;
6500 pixel.opacity=(MagickRealType) OpaqueOpacity;
6501 if (flags & PercentValue)
6503 pixel.red*=QuantumRange/100.0f;
6504 pixel.green*=QuantumRange/100.0f;
6505 pixel.blue*=QuantumRange/100.0f;
6506 pixel.opacity*=QuantumRange/100.0f;
6508 if (!(flags & SigmaValue))
6510 if (!AcquireImageColormap(image,2))
6511 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
6512 "UnableToThresholdImage");
6514 (void) GetImageDynamicThreshold(image,2.0,2.0,&pixel,&image->exception);
6516 for (y=0; y < (ssize_t) image->rows; y++)
6518 register IndexPacket
6524 register PixelPacket
6527 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6528 if (q == (PixelPacket *) NULL)
6530 indexes=GetAuthenticIndexQueue(image);
6531 if (IsMagickGray(&pixel) != MagickFalse)
6532 for (x=0; x < (ssize_t) image->columns; x++)
6534 index=(IndexPacket) ((MagickRealType)
6535 PixelIntensityToQuantum(q) <= pixel.red ? 0 : 1);
6537 q->red=image->colormap[(ssize_t) index].red;
6538 q->green=image->colormap[(ssize_t) index].green;
6539 q->blue=image->colormap[(ssize_t) index].blue;
6543 for (x=0; x < (ssize_t) image->columns; x++)
6545 q->red=(Quantum) ((MagickRealType)
6546 q->red <= pixel.red ? 0 : QuantumRange);
6547 q->green=(Quantum) ((MagickRealType)
6548 q->green <= pixel.green ? 0 : QuantumRange);
6549 q->blue=(Quantum) ((MagickRealType)
6550 q->blue <= pixel.blue ? 0 : QuantumRange);
6551 q->opacity=(Quantum) ((MagickRealType)
6552 q->opacity <= pixel.opacity ? 0 : QuantumRange);
6555 if (!SyncAuthenticPixels(image,&image->exception))
6562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6566 + T r a n s f o r m C o l o r s p a c e %
6570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6572 % TransformColorspace() converts the image to a specified colorspace.
6573 % If the image is already in the requested colorspace, no work is performed.
6574 % Note that the current colorspace is stored in the image colorspace member.
6575 % The transformation matrices are not necessarily the standard ones: the
6576 % weights are rescaled to normalize the range of the transformed values to
6577 % be [0..QuantumRange].
6579 % Deprecated, replace with:
6581 % TransformImageColorspace(image,colorspace);
6583 % The format of the TransformColorspace method is:
6585 % unsigned int (void) TransformColorspace(Image *image,
6586 % const ColorspaceType colorspace)
6588 % A description of each parameter follows:
6590 % o image: the image to transform
6592 % o colorspace: the desired colorspace.
6595 MagickExport unsigned int TransformColorspace(Image *image,
6596 const ColorspaceType colorspace)
6598 assert(image != (Image *) NULL);
6599 assert(image->signature == MagickSignature);
6600 if (image->debug != MagickFalse)
6601 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
6602 return(TransformImageColorspace(image,colorspace));
6606 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6610 % T r a n s f o r m H S L %
6614 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6616 % TransformHSL() converts a (red, green, blue) to a (hue, saturation,
6617 % lightness) triple.
6619 % The format of the TransformHSL method is:
6621 % void TransformHSL(const Quantum red,const Quantum green,
6622 % const Quantum blue,double *hue,double *saturation,double *lightness)
6624 % A description of each parameter follows:
6626 % o red, green, blue: A Quantum value representing the red, green, and
6627 % blue component of a pixel..
6629 % o hue, saturation, lightness: A pointer to a double value representing a
6630 % component of the HSL color space.
6634 static inline double MagickMin(const double x,const double y)
6641 MagickExport void TransformHSL(const Quantum red,const Quantum green,
6642 const Quantum blue,double *hue,double *saturation,double *lightness)
6653 Convert RGB to HSL colorspace.
6655 assert(hue != (double *) NULL);
6656 assert(saturation != (double *) NULL);
6657 assert(lightness != (double *) NULL);
6659 g=QuantumScale*green;
6660 b=QuantumScale*blue;
6661 max=MagickMax(r,MagickMax(g,b));
6662 min=MagickMin(r,MagickMin(g,b));
6665 *lightness=(double) ((min+max)/2.0);
6669 *saturation=(double) (delta/((*lightness < 0.5) ? (min+max) :
6672 *hue=(double) (g == min ? 5.0+(max-b)/delta : 1.0-(max-g)/delta);
6675 *hue=(double) (b == min ? 1.0+(max-r)/delta : 3.0-(max-b)/delta);
6677 *hue=(double) (r == min ? 3.0+(max-g)/delta : 5.0-(max-r)/delta);
6682 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6686 % T r a n s l a t e T e x t %
6690 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6692 % TranslateText() replaces any embedded formatting characters with the
6693 % appropriate image attribute and returns the translated text.
6695 % Deprecated, replace with:
6697 % InterpretImageProperties(image_info,image,embed_text);
6699 % The format of the TranslateText method is:
6701 % char *TranslateText(const ImageInfo *image_info,Image *image,
6702 % const char *embed_text)
6704 % A description of each parameter follows:
6706 % o image_info: the image info.
6708 % o image: the image.
6710 % o embed_text: the address of a character string containing the embedded
6711 % formatting characters.
6714 MagickExport char *TranslateText(const ImageInfo *image_info,Image *image,
6715 const char *embed_text)
6717 assert(image != (Image *) NULL);
6718 assert(image->signature == MagickSignature);
6719 if (image->debug != MagickFalse)
6720 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.6");
6721 return(InterpretImageProperties(image_info,image,embed_text));
6725 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6729 % T r a n s p a r e n t I m a g e %
6733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6735 % TransparentImage() changes the opacity value associated with any pixel
6736 % that matches color to the value defined by opacity.
6738 % By default color must match a particular pixel color exactly. However,
6739 % in many cases two colors may differ by a small amount. Fuzz defines
6740 % how much tolerance is acceptable to consider two colors as the same.
6741 % For example, set fuzz to 10 and the color red at intensities of 100 and
6742 % 102 respectively are now interpreted as the same color.
6744 % The format of the TransparentImage method is:
6746 % MagickBooleanType TransparentImage(Image *image,
6747 % const PixelPacket target,const Quantum opacity)
6749 % A description of each parameter follows:
6751 % o image: the image.
6753 % o target: the RGB value of the target color.
6755 % o opacity: the replacement opacity value.
6758 MagickExport MagickBooleanType TransparentImage(Image *image,
6759 const PixelPacket target,const Quantum opacity)
6761 #define TransparentImageTag "Transparent/Image"
6770 Make image color transparent.
6772 assert(image != (Image *) NULL);
6773 assert(image->signature == MagickSignature);
6774 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.1.0");
6775 if (image->debug != MagickFalse)
6776 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6777 if (image->matte == MagickFalse)
6778 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
6779 for (y=0; y < (ssize_t) image->rows; y++)
6784 register PixelPacket
6787 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6788 if (q == (PixelPacket *) NULL)
6790 for (x=0; x < (ssize_t) image->columns; x++)
6792 if (IsColorSimilar(image,q,&target) != MagickFalse)
6796 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
6798 proceed=SetImageProgress(image,TransparentImageTag,(MagickOffsetType) y,
6800 if (proceed == MagickFalse)
6807 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6811 % U n s h i f t I m a g e L i s t %
6815 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6817 % UnshiftImageList() adds the image to the beginning of the list.
6819 % Deprecated, replace with:
6821 % PrependImageToList(images,CloneImageList(image,exception));
6823 % The format of the UnshiftImageList method is:
6825 % unsigned int UnshiftImageList(Image *images,const Image *image,
6826 % ExceptionInfo *exception)
6828 % A description of each parameter follows:
6830 % o images: the image list.
6832 % o image: the image.
6834 % o exception: return any errors or warnings in this structure.
6837 MagickExport unsigned int UnshiftImageList(Image **images,const Image *image,
6838 ExceptionInfo *exception)
6840 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
6841 PrependImageToList(images,CloneImageList(image,exception));
6846 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6850 + V a l i d a t e C o l o r m a p I n d e x %
6854 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6856 % ValidateColormapIndex() validates the colormap index. If the index does
6857 % not range from 0 to the number of colors in the colormap an exception
6858 % issued and 0 is returned.
6860 % Deprecated, replace with:
6862 % ConstrainColormapIndex(image,index);
6864 % The format of the ValidateColormapIndex method is:
6866 % IndexPacket ValidateColormapIndex(Image *image,const unsigned int index)
6868 % A description of each parameter follows:
6870 % o index: Method ValidateColormapIndex returns colormap index if it is
6871 % valid other an exception issued and 0 is returned.
6873 % o image: the image.
6875 % o index: This integer is the colormap index.
6878 MagickExport IndexPacket ValidateColormapIndex(Image *image,
6881 if (image->debug != MagickFalse)
6882 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.4");
6883 return(ConstrainColormapIndex(image,index));