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-2011 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)
1166 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,"%.20g\n",(double) id);
1493 return(DeleteImageRegistry(key));
1497 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1501 + D e s t r o y C o n s t i t u t e %
1505 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1507 % DestroyConstitute() destroys the constitute component.
1509 % The format of the DestroyConstitute method is:
1511 % DestroyConstitute(void)
1514 MagickExport void DestroyConstitute(void)
1516 ConstituteComponentTerminus();
1520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1524 + D e s t r o y M a g i c k R e g i s t r y %
1528 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1530 % DestroyMagickRegistry() deallocates memory associated the magick registry.
1532 % Deprecated, replace with:
1534 % RegistryComponentTerminus();
1536 % The format of the DestroyMagickRegistry method is:
1538 % void DestroyMagickRegistry(void)
1541 MagickExport void DestroyMagickRegistry(void)
1543 RegistryComponentTerminus();
1547 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1551 % D e s c r i b e I m a g e %
1555 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1557 % DescribeImage() describes an image by printing its attributes to the file.
1558 % Attributes include the image width, height, size, and others.
1560 % Deprecated, replace with:
1562 % IdentifyImage(image,file,verbose);
1564 % The format of the DescribeImage method is:
1566 % MagickBooleanType DescribeImage(Image *image,FILE *file,
1567 % const MagickBooleanType verbose)
1569 % A description of each parameter follows:
1571 % o image: the image.
1573 % o file: the file, typically stdout.
1575 % o verbose: A value other than zero prints more detailed information
1579 MagickExport MagickBooleanType DescribeImage(Image *image,FILE *file,
1580 const MagickBooleanType verbose)
1582 return(IdentifyImage(image,file,verbose));
1586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1590 % D e s t r o y I m a g e A t t r i b u t e s %
1594 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1596 % DestroyImageAttributes() deallocates memory associated with the image
1599 % The format of the DestroyImageAttributes method is:
1601 % DestroyImageAttributes(Image *image)
1603 % A description of each parameter follows:
1605 % o image: the image.
1608 MagickExport void DestroyImageAttributes(Image *image)
1610 assert(image != (Image *) NULL);
1611 assert(image->signature == MagickSignature);
1612 if (image->debug != MagickFalse)
1613 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1614 if (image->attributes != (void *) NULL)
1615 image->attributes=(void *) DestroySplayTree((SplayTreeInfo *)
1620 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1624 % D e s t r o y I m a g e s %
1628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1630 % DestroyImages() destroys an image list.
1632 % Deprecated, replace with:
1634 % DestroyImageList(image);
1636 % The format of the DestroyImages method is:
1638 % void DestroyImages(Image *image)
1640 % A description of each parameter follows:
1642 % o image: the image sequence.
1645 MagickExport void DestroyImages(Image *image)
1647 if (image == (Image *) NULL)
1649 if (image->debug != MagickFalse)
1650 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.3");
1651 image=DestroyImageList(image);
1655 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1659 % D e s t r o y M a g i c k %
1663 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1665 % DestroyMagick() destroys the ImageMagick environment.
1667 % Deprecated, replace with:
1669 % MagickCoreTerminus();
1671 % The format of the DestroyMagick function is:
1673 % DestroyMagick(void)
1676 MagickExport void DestroyMagick(void)
1678 MagickCoreTerminus();
1682 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1686 % D i s p a t c h I m a g e %
1690 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1692 % DispatchImage() extracts pixel data from an image and returns it to you.
1693 % The method returns MagickFalse on success otherwise MagickTrue if an error is
1694 % encountered. The data is returned as char, short int, int, ssize_t, float,
1695 % or double in the order specified by map.
1697 % Suppose you want to extract the first scanline of a 640x480 image as
1698 % character data in red-green-blue order:
1700 % DispatchImage(image,0,0,640,1,"RGB",CharPixel,pixels,exception);
1702 % Deprecated, replace with:
1704 % ExportImagePixels(image,x_offset,y_offset,columns,rows,map,type,pixels,
1707 % The format of the DispatchImage method is:
1709 % unsigned int DispatchImage(const Image *image,const ssize_t x_offset,
1710 % const ssize_t y_offset,const size_t columns,
1711 % const size_t rows,const char *map,const StorageType type,
1712 % void *pixels,ExceptionInfo *exception)
1714 % A description of each parameter follows:
1716 % o image: the image.
1718 % o x_offset, y_offset, columns, rows: These values define the perimeter
1719 % of a region of pixels you want to extract.
1721 % o map: This string reflects the expected ordering of the pixel array.
1722 % It can be any combination or order of R = red, G = green, B = blue,
1723 % A = alpha, C = cyan, Y = yellow, M = magenta, K = black, or
1724 % I = intensity (for grayscale).
1726 % o type: Define the data type of the pixels. Float and double types are
1727 % normalized to [0..1] otherwise [0..QuantumRange]. Choose from these
1728 % types: CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel, or
1731 % o pixels: This array of values contain the pixel components as defined by
1732 % map and type. You must preallocate this array where the expected
1733 % length varies depending on the values of width, height, map, and type.
1735 % o exception: return any errors or warnings in this structure.
1738 MagickExport unsigned int DispatchImage(const Image *image,const ssize_t x_offset,
1739 const ssize_t y_offset,const size_t columns,const size_t rows,
1740 const char *map,const StorageType type,void *pixels,ExceptionInfo *exception)
1745 if (image->debug != MagickFalse)
1746 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
1747 status=ExportImagePixels(image,x_offset,y_offset,columns,rows,map,type,pixels,
1753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1757 % E x t r a c t S u b i m a g e F r o m I m a g e %
1761 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1763 % ExtractSubimageFromImageImage() extracts a region of the image that most
1764 % closely resembles the reference.
1766 % The format of the ExtractSubimageFromImageImage method is:
1768 % Image *ExtractSubimageFromImage(const Image *image,
1769 % const Image *reference,ExceptionInfo *exception)
1771 % A description of each parameter follows:
1773 % o image: the image.
1775 % o reference: find an area of the image that closely resembles this image.
1777 % o exception: return any errors or warnings in this structure.
1781 static double GetSimilarityMetric(const Image *image,const Image *reference,
1782 const ssize_t x_offset,const ssize_t y_offset,
1783 const double similarity_threshold,ExceptionInfo *exception)
1791 normalized_similarity,
1798 Compute the similarity in pixels between two images.
1800 normalized_similarity=1.0;
1803 if ((image->matte != MagickFalse) && (reference->matte != MagickFalse))
1805 if ((image->colorspace == CMYKColorspace) &&
1806 (reference->colorspace == CMYKColorspace))
1808 image_view=AcquireCacheView(image);
1809 reference_view=AcquireCacheView(reference);
1810 for (y=0; y < (ssize_t) reference->rows; y++)
1812 register const IndexPacket
1816 register const PixelPacket
1823 p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset+y,
1824 reference->columns,1,exception);
1825 q=GetCacheViewVirtualPixels(reference_view,0,y,reference->columns,1,
1827 if ((p == (const PixelPacket *) NULL) || (q == (const PixelPacket *) NULL))
1829 indexes=GetCacheViewVirtualIndexQueue(image_view);
1830 reference_indexes=GetCacheViewVirtualIndexQueue(reference_view);
1831 for (x=0; x < (ssize_t) reference->columns; x++)
1836 pixel=QuantumScale*(p->red-(double) q->red);
1837 similarity+=pixel*pixel;
1838 pixel=QuantumScale*(p->green-(double) q->green);
1839 similarity+=pixel*pixel;
1840 pixel=QuantumScale*(p->blue-(double) q->blue);
1841 similarity+=pixel*pixel;
1842 if ((image->matte != MagickFalse) && (reference->matte != MagickFalse))
1844 pixel=QuantumScale*(p->opacity-(double) q->opacity);
1845 similarity+=pixel*pixel;
1847 if ((image->colorspace == CMYKColorspace) &&
1848 (reference->colorspace == CMYKColorspace))
1850 pixel=QuantumScale*(indexes[x]-(double) reference_indexes[x]);
1851 similarity+=pixel*pixel;
1856 normalized_similarity=sqrt(similarity)/reference->columns/reference->rows/
1858 if (normalized_similarity > similarity_threshold)
1861 reference_view=DestroyCacheView(reference_view);
1862 image_view=DestroyCacheView(image_view);
1863 return(normalized_similarity);
1866 MagickExport Image *ExtractSubimageFromImage(Image *image,
1867 const Image *reference,ExceptionInfo *exception)
1870 similarity_threshold;
1879 Extract reference from image.
1881 if ((reference->columns > image->columns) || (reference->rows > image->rows))
1882 return((Image *) NULL);
1883 similarity_threshold=(double) image->columns*image->rows;
1884 SetGeometry(reference,&offset);
1885 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1886 #pragma omp parallel for schedule(dynamic,4)
1888 for (y=0; y < (ssize_t) (image->rows-reference->rows); y++)
1896 for (x=0; x < (ssize_t) (image->columns-reference->columns); x++)
1898 similarity=GetSimilarityMetric(image,reference,x,y,similarity_threshold,
1900 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1901 #pragma omp critical (MagickCore_ExtractSubimageFromImage)
1903 if (similarity < similarity_threshold)
1905 similarity_threshold=similarity;
1911 if (similarity_threshold > (QuantumScale*reference->fuzz/100.0))
1912 return((Image *) NULL);
1913 return(CropImage(image,&offset,exception));
1917 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1921 % F l a t t e n I m a g e %
1925 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1927 % FlattenImages() Obsolete Function: Use MergeImageLayers() instead.
1929 % Deprecated, replace with:
1931 % MergeImageLayers(image,FlattenLayer,exception);
1933 % The format of the FlattenImage method is:
1935 % Image *FlattenImage(Image *image,ExceptionInfo *exception)
1937 % A description of each parameter follows:
1939 % o image: the image sequence.
1941 % o exception: return any errors or warnings in this structure.
1944 MagickExport Image *FlattenImages(Image *image,ExceptionInfo *exception)
1946 return(MergeImageLayers(image,FlattenLayer,exception));
1950 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1954 % F o r m a t I m a g e A t t r i b u t e %
1958 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1960 % FormatImageAttribute() permits formatted key/value pairs to be saved as an
1963 % The format of the FormatImageAttribute method is:
1965 % MagickBooleanType FormatImageAttribute(Image *image,const char *key,
1966 % const char *format,...)
1968 % A description of each parameter follows.
1970 % o image: The image.
1972 % o key: The attribute key.
1974 % o format: A string describing the format to use to write the remaining
1979 MagickExport MagickBooleanType FormatImageAttributeList(Image *image,
1980 const char *key,const char *format,va_list operands)
1983 value[MaxTextExtent];
1988 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
1989 n=vsnprintf(value,MaxTextExtent,format,operands);
1991 n=vsprintf(value,format,operands);
1994 value[MaxTextExtent-1]='\0';
1995 return(SetImageProperty(image,key,value));
1998 MagickExport MagickBooleanType FormatImageAttribute(Image *image,
1999 const char *key,const char *format,...)
2007 va_start(operands,format);
2008 status=FormatImagePropertyList(image,key,format,operands);
2014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2018 % F o r m a t S t r i n g %
2022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2024 % FormatString() prints formatted output of a variable argument list.
2026 % The format of the FormatString method is:
2028 % void FormatString(char *string,const char *format,...)
2030 % A description of each parameter follows.
2032 % o string: Method FormatString returns the formatted string in this
2035 % o format: A string describing the format to use to write the remaining
2040 MagickExport void FormatStringList(char *string,const char *format,
2046 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
2047 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
2048 n=vsnprintf(string,MaxTextExtent,format,operands);
2050 n=vsprintf(string,format,operands);
2053 string[MaxTextExtent-1]='\0';
2056 MagickExport void FormatString(char *string,const char *format,...)
2061 va_start(operands,format);
2062 (void) FormatMagickStringList(string,MaxTextExtent,format,operands);
2068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2072 + F u z z y C o l o r M a t c h %
2076 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2078 % FuzzyColorMatch() returns true if two pixels are identical in color.
2080 % The format of the ColorMatch method is:
2082 % void FuzzyColorMatch(const PixelPacket *p,const PixelPacket *q,
2083 % const double fuzz)
2085 % A description of each parameter follows:
2091 % o distance: Define how much tolerance is acceptable to consider
2092 % two colors as the same.
2095 MagickExport unsigned int FuzzyColorMatch(const PixelPacket *p,
2096 const PixelPacket *q,const double fuzz)
2101 register MagickRealType
2104 if ((fuzz == 0.0) && (p->red == q->red) && (p->green == q->green) &&
2105 (p->blue == q->blue))
2107 pixel.red=p->red-(MagickRealType) q->red;
2108 distance=pixel.red*pixel.red;
2109 if (distance > (fuzz*fuzz))
2110 return(MagickFalse);
2111 pixel.green=p->green-(MagickRealType) q->green;
2112 distance+=pixel.green*pixel.green;
2113 if (distance > (fuzz*fuzz))
2114 return(MagickFalse);
2115 pixel.blue=p->blue-(MagickRealType) q->blue;
2116 distance+=pixel.blue*pixel.blue;
2117 if (distance > (fuzz*fuzz))
2118 return(MagickFalse);
2123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2127 + F u z z y C o l o r C o m p a r e %
2131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2133 % FuzzyColorCompare() returns MagickTrue if the distance between two colors is
2134 % less than the specified distance in a linear three dimensional color space.
2135 % This method is used by ColorFloodFill() and other algorithms which
2136 % compare two colors.
2138 % The format of the FuzzyColorCompare method is:
2140 % void FuzzyColorCompare(const Image *image,const PixelPacket *p,
2141 % const PixelPacket *q)
2143 % A description of each parameter follows:
2145 % o image: the image.
2152 MagickExport MagickBooleanType FuzzyColorCompare(const Image *image,
2153 const PixelPacket *p,const PixelPacket *q)
2155 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.5");
2156 return(IsColorSimilar(image,p,q));
2160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2164 + F u z z y O p a c i t y C o m p a r e %
2168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2170 % FuzzyOpacityCompare() returns true if the distance between two opacity
2171 % values is less than the specified distance in a linear color space. This
2172 % method is used by MatteFloodFill() and other algorithms which compare
2173 % two opacity values.
2175 % Deprecated, replace with:
2177 % IsOpacitySimilar(image,p,q);
2179 % The format of the FuzzyOpacityCompare method is:
2181 % void FuzzyOpacityCompare(const Image *image,const PixelPacket *p,
2182 % const PixelPacket *q)
2184 % A description of each parameter follows:
2186 % o image: the image.
2193 MagickExport MagickBooleanType FuzzyOpacityCompare(const Image *image,
2194 const PixelPacket *p,const PixelPacket *q)
2196 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.5");
2197 return(IsOpacitySimilar(image,p,q));
2201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2205 % G e t C o n f i g u r e B l o b %
2209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2211 % GetConfigureBlob() returns the specified configure file as a blob.
2213 % The format of the GetConfigureBlob method is:
2215 % void *GetConfigureBlob(const char *filename,ExceptionInfo *exception)
2217 % A description of each parameter follows:
2219 % o filename: the configure file name.
2221 % o path: return the full path information of the configure file.
2223 % o length: This pointer to a size_t integer sets the initial length of the
2224 % blob. On return, it reflects the actual length of the blob.
2226 % o exception: return any errors or warnings in this structure.
2229 MagickExport void *GetConfigureBlob(const char *filename,char *path,
2230 size_t *length,ExceptionInfo *exception)
2235 assert(filename != (const char *) NULL);
2236 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
2237 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
2238 assert(path != (char *) NULL);
2239 assert(length != (size_t *) NULL);
2240 assert(exception != (ExceptionInfo *) NULL);
2242 (void) CopyMagickString(path,filename,MaxTextExtent);
2243 #if defined(MAGICKCORE_INSTALLED_SUPPORT)
2244 #if defined(MAGICKCORE_LIBRARY_PATH)
2245 if (blob == (void *) NULL)
2248 Search hard coded paths.
2250 (void) FormatMagickString(path,MaxTextExtent,"%s%s",
2251 MAGICKCORE_LIBRARY_PATH,filename);
2252 if (IsPathAccessible(path) != MagickFalse)
2253 blob=FileToBlob(path,~0,length,exception);
2256 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !(defined(MAGICKCORE_CONFIGURE_PATH) || defined(MAGICKCORE_SHARE_CONFIGURE_PATH))
2257 if (blob == (void *) NULL)
2263 Locate file via registry key.
2265 key_value=NTRegistryKeyLookup("ConfigurePath");
2266 if (key_value != (char *) NULL)
2268 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",key_value,
2269 DirectorySeparator,filename);
2270 if (IsPathAccessible(path) != MagickFalse)
2271 blob=FileToBlob(path,~0,length,exception);
2276 if (blob == (void *) NULL)
2281 home=GetEnvironmentValue("MAGICK_HOME");
2282 if (home != (char *) NULL)
2287 #if !defined(MAGICKCORE_POSIX_SUPPORT)
2288 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",home,
2289 DirectorySeparator,filename);
2291 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/%s",home,
2292 MAGICKCORE_LIBRARY_RELATIVE_PATH,filename);
2294 if (IsPathAccessible(path) != MagickFalse)
2295 blob=FileToBlob(path,~0,length,exception);
2296 home=DestroyString(home);
2298 home=GetEnvironmentValue("HOME");
2299 if (home == (char *) NULL)
2300 home=GetEnvironmentValue("USERPROFILE");
2301 if (home != (char *) NULL)
2304 Search $HOME/.magick.
2306 (void) FormatMagickString(path,MaxTextExtent,"%s%s.magick%s%s",home,
2307 DirectorySeparator,DirectorySeparator,filename);
2308 if ((IsPathAccessible(path) != MagickFalse) && (blob == (void *) NULL))
2309 blob=FileToBlob(path,~0,length,exception);
2310 home=DestroyString(home);
2313 if ((blob == (void *) NULL) && (*GetClientPath() != '\0'))
2315 #if !defined(MAGICKCORE_POSIX_SUPPORT)
2316 (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",GetClientPath(),
2317 DirectorySeparator,filename);
2320 prefix[MaxTextExtent];
2323 Search based on executable directory if directory is known.
2325 (void) CopyMagickString(prefix,GetClientPath(),
2327 ChopPathComponents(prefix,1);
2328 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/%s",prefix,
2329 MAGICKCORE_LIBRARY_RELATIVE_PATH,filename);
2331 if (IsPathAccessible(path) != MagickFalse)
2332 blob=FileToBlob(path,~0,length,exception);
2335 Search current directory.
2337 if ((blob == (void *) NULL) && (IsPathAccessible(path) != MagickFalse))
2338 blob=FileToBlob(path,~0,length,exception);
2339 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
2341 Search Windows registry.
2343 if (blob == (void *) NULL)
2344 blob=NTResourceToBlob(filename);
2347 if (blob == (void *) NULL)
2348 (void) ThrowMagickException(exception,GetMagickModule(),ConfigureWarning,
2349 "UnableToOpenConfigureFile","`%s'",path);
2354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2358 % G e t C a c h e V i e w %
2362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2364 % GetCacheView() gets pixels from the in-memory or disk pixel cache as
2365 % defined by the geometry parameters. A pointer to the pixels is returned if
2366 % the pixels are transferred, otherwise a NULL is returned.
2368 % Deprecated, replace with:
2370 % GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2371 % GetCacheViewException(cache_view));
2373 % The format of the GetCacheView method is:
2375 % PixelPacket *GetCacheView(CacheView *cache_view,const ssize_t x,
2376 % const ssize_t y,const size_t columns,const size_t rows)
2378 % A description of each parameter follows:
2380 % o cache_view: the address of a structure of type CacheView.
2382 % o x,y,columns,rows: These values define the perimeter of a region of
2386 MagickExport PixelPacket *GetCacheView(CacheView *cache_view,const ssize_t x,
2387 const ssize_t y,const size_t columns,const size_t rows)
2392 pixels=GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2393 GetCacheViewException(cache_view));
2398 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2402 % G e t C a c h e V i e w I n d e x e s %
2406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2408 % GetCacheViewIndexes() returns the indexes associated with the specified
2411 % Deprecated, replace with:
2413 % GetCacheViewAuthenticIndexQueue(cache_view);
2415 % The format of the GetCacheViewIndexes method is:
2417 % IndexPacket *GetCacheViewIndexes(CacheView *cache_view)
2419 % A description of each parameter follows:
2421 % o cache_view: the cache view.
2424 MagickExport IndexPacket *GetCacheViewIndexes(CacheView *cache_view)
2426 return(GetCacheViewAuthenticIndexQueue(cache_view));
2430 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2434 % G e t C a c h e V i e w P i x e l s %
2438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2440 % GetCacheViewPixels() gets pixels from the in-memory or disk pixel cache as
2441 % defined by the geometry parameters. A pointer to the pixels is returned if
2442 % the pixels are transferred, otherwise a NULL is returned.
2444 % Deprecated, replace with:
2446 % GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2447 % GetCacheViewException(cache_view));
2449 % The format of the GetCacheViewPixels method is:
2451 % PixelPacket *GetCacheViewPixels(CacheView *cache_view,const ssize_t x,
2452 % const ssize_t y,const size_t columns,const size_t rows)
2454 % A description of each parameter follows:
2456 % o cache_view: the cache view.
2458 % o x,y,columns,rows: These values define the perimeter of a region of
2462 MagickExport PixelPacket *GetCacheViewPixels(CacheView *cache_view,const ssize_t x,
2463 const ssize_t y,const size_t columns,const size_t rows)
2468 pixels=GetCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
2469 GetCacheViewException(cache_view));
2474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2478 % G e t I m a g e A t t r i b u t e %
2482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2484 % GetImageAttribute() searches the list of image attributes and returns
2485 % a pointer to the attribute if it exists otherwise NULL.
2487 % The format of the GetImageAttribute method is:
2489 % const ImageAttribute *GetImageAttribute(const Image *image,
2492 % A description of each parameter follows:
2494 % o image: the image.
2496 % o key: These character strings are the name of an image attribute to
2501 static void *DestroyAttribute(void *attribute)
2503 register ImageAttribute
2506 p=(ImageAttribute *) attribute;
2507 if (p->value != (char *) NULL)
2508 p->value=DestroyString(p->value);
2509 return(RelinquishMagickMemory(p));
2512 MagickExport const ImageAttribute *GetImageAttribute(const Image *image,
2521 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
2522 value=GetImageProperty(image,key);
2523 if (value == (const char *) NULL)
2524 return((const ImageAttribute *) NULL);
2525 if (image->attributes == (void *) NULL)
2526 ((Image *) image)->attributes=NewSplayTree(CompareSplayTreeString,
2527 RelinquishMagickMemory,DestroyAttribute);
2530 const ImageAttribute
2533 attribute=(const ImageAttribute *) GetValueFromSplayTree((SplayTreeInfo *)
2534 image->attributes,key);
2535 if (attribute != (const ImageAttribute *) NULL)
2538 attribute=(ImageAttribute *) AcquireMagickMemory(sizeof(*attribute));
2539 if (attribute == (ImageAttribute *) NULL)
2540 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
2541 (void) ResetMagickMemory(attribute,0,sizeof(*attribute));
2542 attribute->key=ConstantString(key);
2543 attribute->value=ConstantString(value);
2544 (void) AddValueToSplayTree((SplayTreeInfo *) ((Image *) image)->attributes,
2545 attribute->key,attribute);
2546 return((const ImageAttribute *) attribute);
2550 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2554 % 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 %
2558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2560 % GetImageClippingPathAttribute() searches the list of image attributes and
2561 % returns a pointer to a clipping path if it exists otherwise NULL.
2563 % Deprecated, replace with:
2565 % GetImageAttribute(image,"8BIM:1999,2998");
2567 % The format of the GetImageClippingPathAttribute method is:
2569 % const ImageAttribute *GetImageClippingPathAttribute(Image *image)
2571 % A description of each parameter follows:
2573 % o attribute: Method GetImageClippingPathAttribute returns the clipping
2574 % path if it exists otherwise NULL.
2576 % o image: the image.
2579 MagickExport const ImageAttribute *GetImageClippingPathAttribute(Image *image)
2581 return(GetImageAttribute(image,"8BIM:1999,2998"));
2585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2589 % 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 %
2593 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2595 % GetImageFromMagickRegistry() gets an image from the registry as defined by
2596 % its name. If the image is not found, a NULL image is returned.
2598 % Deprecated, replace with:
2600 % GetImageRegistry(ImageRegistryType,name,exception);
2602 % The format of the GetImageFromMagickRegistry method is:
2604 % Image *GetImageFromMagickRegistry(const char *name,ssize_t *id,
2605 % ExceptionInfo *exception)
2607 % A description of each parameter follows:
2609 % o name: the name of the image to retrieve from the registry.
2611 % o id: the registry id.
2613 % o exception: return any errors or warnings in this structure.
2616 MagickExport Image *GetImageFromMagickRegistry(const char *name,ssize_t *id,
2617 ExceptionInfo *exception)
2620 return((Image *) GetImageRegistry(ImageRegistryType,name,exception));
2624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2628 % G e t M a g i c k R e g i s t r y %
2632 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2634 % GetMagickRegistry() gets a blob from the registry as defined by the id. If
2635 % the blob that matches the id is not found, NULL is returned.
2637 % The format of the GetMagickRegistry method is:
2639 % const void *GetMagickRegistry(const ssize_t id,RegistryType *type,
2640 % size_t *length,ExceptionInfo *exception)
2642 % A description of each parameter follows:
2644 % o id: the registry id.
2646 % o type: the registry type.
2648 % o length: the blob length in number of bytes.
2650 % o exception: return any errors or warnings in this structure.
2653 MagickExport void *GetMagickRegistry(const ssize_t id,RegistryType *type,
2654 size_t *length,ExceptionInfo *exception)
2662 *type=UndefinedRegistryType;
2664 (void) FormatMagickString(key,MaxTextExtent,"%.20g\n",(double) id);
2665 blob=(void *) GetImageRegistry(ImageRegistryType,key,exception);
2666 if (blob != (void *) NULL)
2668 blob=(void *) GetImageRegistry(ImageInfoRegistryType,key,exception);
2669 if (blob != (void *) NULL)
2671 return((void *) GetImageRegistry(UndefinedRegistryType,key,exception));
2675 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2679 % G e t I m a g e G e o m e t r y %
2683 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2685 % GetImageGeometry() returns a region as defined by the geometry string with
2686 % respect to the image and its gravity.
2688 % Deprecated, replace with:
2690 % if (size_to_fit != MagickFalse)
2691 % ParseRegionGeometry(image,geometry,region_info,&image->exception); else
2692 % ParsePageGeometry(image,geometry,region_info,&image->exception);
2694 % The format of the GetImageGeometry method is:
2696 % int GetImageGeometry(Image *image,const char *geometry,
2697 % const unsigned int size_to_fit,RectangeInfo *region_info)
2699 % A description of each parameter follows:
2701 % o flags: Method GetImageGeometry returns a bitmask that indicates
2702 % which of the four values were located in the geometry string.
2704 % o geometry: The geometry (e.g. 100x100+10+10).
2706 % o size_to_fit: A value other than 0 means to scale the region so it
2707 % fits within the specified width and height.
2709 % o region_info: the region as defined by the geometry string with
2710 % respect to the image and its gravity.
2713 MagickExport int GetImageGeometry(Image *image,const char *geometry,
2714 const unsigned int size_to_fit,RectangleInfo *region_info)
2716 if (image->debug != MagickFalse)
2717 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.4");
2718 if (size_to_fit != MagickFalse)
2719 return((int) ParseRegionGeometry(image,geometry,region_info,&image->exception));
2720 return((int) ParsePageGeometry(image,geometry,region_info,&image->exception));
2724 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2728 % G e t I m a g e L i s t %
2732 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2734 % GetImageList() returns an image at the specified position in the list.
2736 % Deprecated, replace with:
2738 % CloneImage(GetImageFromList(images,(ssize_t) offset),0,0,MagickTrue,
2741 % The format of the GetImageList method is:
2743 % Image *GetImageList(const Image *images,const ssize_t offset,
2744 % ExceptionInfo *exception)
2746 % A description of each parameter follows:
2748 % o images: the image list.
2750 % o offset: the position within the list.
2752 % o exception: return any errors or warnings in this structure.
2755 MagickExport Image *GetImageList(const Image *images,const ssize_t offset,
2756 ExceptionInfo *exception)
2761 if (images->debug != MagickFalse)
2762 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2763 image=CloneImage(GetImageFromList(images,(ssize_t) offset),0,0,MagickTrue,
2769 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2773 % G e t I m a g e L i s t I n d e x %
2777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2779 % GetImageListIndex() returns the position in the list of the specified
2782 % Deprecated, replace with:
2784 % GetImageIndexInList(images);
2786 % The format of the GetImageListIndex method is:
2788 % ssize_t GetImageListIndex(const Image *images)
2790 % A description of each parameter follows:
2792 % o images: the image list.
2795 MagickExport ssize_t GetImageListIndex(const Image *images)
2797 if (images->debug != MagickFalse)
2798 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2799 return(GetImageIndexInList(images));
2803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2807 % G e t I m a g e L i s t S i z e %
2811 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2813 % GetImageListSize() returns the number of images in the list.
2815 % Deprecated, replace with:
2817 % GetImageListLength(images);
2819 % The format of the GetImageListSize method is:
2821 % size_t GetImageListSize(const Image *images)
2823 % A description of each parameter follows:
2825 % o images: the image list.
2828 MagickExport size_t GetImageListSize(const Image *images)
2830 if (images->debug != MagickFalse)
2831 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2832 return(GetImageListLength(images));
2836 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2840 % G e t I m a g e P i x e l s %
2844 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2846 % GetImagePixels() obtains a pixel region for read/write access. If the
2847 % region is successfully accessed, a pointer to a PixelPacket array
2848 % representing the region is returned, otherwise NULL is returned.
2850 % The returned pointer may point to a temporary working copy of the pixels
2851 % or it may point to the original pixels in memory. Performance is maximized
2852 % if the selected region is part of one row, or one or more full rows, since
2853 % then there is opportunity to access the pixels in-place (without a copy)
2854 % if the image is in RAM, or in a memory-mapped file. The returned pointer
2855 % should *never* be deallocated by the user.
2857 % Pixels accessed via the returned pointer represent a simple array of type
2858 % PixelPacket. If the image type is CMYK or if the storage class is
2859 % PseduoClass, call GetAuthenticIndexQueue() after invoking GetImagePixels()
2860 % to obtain the black color component or colormap indexes (of type IndexPacket)
2861 % corresponding to the region. Once the PixelPacket (and/or IndexPacket)
2862 % array has been updated, the changes must be saved back to the underlying
2863 % image using SyncAuthenticPixels() or they may be lost.
2865 % Deprecated, replace with:
2867 % GetAuthenticPixels(image,x,y,columns,rows,&image->exception);
2869 % The format of the GetImagePixels() method is:
2871 % PixelPacket *GetImagePixels(Image *image,const ssize_t x,const ssize_t y,
2872 % const size_t columns,const size_t rows)
2874 % A description of each parameter follows:
2876 % o image: the image.
2878 % o x,y,columns,rows: These values define the perimeter of a region of
2882 MagickExport PixelPacket *GetImagePixels(Image *image,const ssize_t x,const ssize_t y,
2883 const size_t columns,const size_t rows)
2885 return(GetAuthenticPixels(image,x,y,columns,rows,&image->exception));
2889 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2893 % G e t I n d e x e s %
2897 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2899 % GetIndexes() returns the black channel or the colormap indexes associated
2900 % with the last call to QueueAuthenticPixels() or GetVirtualPixels(). NULL is
2901 % returned if the black channel or colormap indexes are not available.
2903 % Deprecated, replace with:
2905 % GetAuthenticIndexQueue(image);
2907 % The format of the GetIndexes() method is:
2909 % IndexPacket *GetIndexes(const Image *image)
2911 % A description of each parameter follows:
2913 % o indexes: GetIndexes() returns the indexes associated with the last
2914 % call to QueueAuthenticPixels() or GetAuthenticPixels().
2916 % o image: the image.
2919 MagickExport IndexPacket *GetIndexes(const Image *image)
2921 return(GetAuthenticIndexQueue(image));
2925 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2929 + G e t M a g i c k G e o m e t r y %
2933 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2935 % GetMagickGeometry() is similar to GetGeometry() except the returned
2936 % geometry is modified as determined by the meta characters: %, !, <, >,
2939 % Deprecated, replace with:
2941 % ParseMetaGeometry(geometry,x,y,width,height);
2943 % The format of the GetMagickGeometry method is:
2945 % unsigned int GetMagickGeometry(const char *geometry,ssize_t *x,ssize_t *y,
2946 % size_t *width,size_t *height)
2948 % A description of each parameter follows:
2950 % o geometry: Specifies a character string representing the geometry
2953 % o x,y: A pointer to an integer. The x and y offset as determined by
2954 % the geometry specification is returned here.
2956 % o width,height: A pointer to an unsigned integer. The width and height
2957 % as determined by the geometry specification is returned here.
2960 MagickExport unsigned int GetMagickGeometry(const char *geometry,ssize_t *x,
2961 ssize_t *y,size_t *width,size_t *height)
2963 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.3");
2964 return(ParseMetaGeometry(geometry,x,y,width,height));
2968 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2972 % G e t N e x t I m a g e %
2976 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2978 % GetNextImage() returns the next image in a list.
2980 % Deprecated, replace with:
2982 % GetNextImageInList(images);
2984 % The format of the GetNextImage method is:
2986 % Image *GetNextImage(const Image *images)
2988 % A description of each parameter follows:
2990 % o images: the image list.
2993 MagickExport Image *GetNextImage(const Image *images)
2995 if (images->debug != MagickFalse)
2996 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
2997 return(GetNextImageInList(images));
3001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3005 % G e t N e x t I m a g e A t t r i b u t e %
3009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3011 % GetNextImageAttribute() gets the next image attribute.
3013 % Deprecated, replace with:
3015 % const char *property;
3016 % property=GetNextImageProperty(image);
3017 % if (property != (const char *) NULL)
3018 % GetImageAttribute(image,property);
3020 % The format of the GetNextImageAttribute method is:
3022 % const ImageAttribute *GetNextImageAttribute(const Image *image)
3024 % A description of each parameter follows:
3026 % o image: the image.
3029 MagickExport const ImageAttribute *GetNextImageAttribute(const Image *image)
3034 property=GetNextImageProperty(image);
3035 if (property == (const char *) NULL)
3036 return((const ImageAttribute *) NULL);
3037 return(GetImageAttribute(image,property));
3041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3045 % G e t N u m b e r S c e n e s %
3049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3051 % GetNumberScenes() returns the number of images in the list.
3053 % Deprecated, replace with:
3055 % GetImageListLength(image);
3057 % The format of the GetNumberScenes method is:
3059 % unsigned int GetNumberScenes(const Image *images)
3061 % A description of each parameter follows:
3063 % o images: the image list.
3066 MagickExport unsigned int GetNumberScenes(const Image *image)
3068 if (image->debug != MagickFalse)
3069 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
3070 return((unsigned int) GetImageListLength(image));
3074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3078 % G e t O n e P i x e l %
3082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3084 % GetOnePixel() returns a single pixel at the specified (x,y) location.
3085 % The image background color is returned if an error occurs.
3087 % Deprecated, replace with:
3089 % GetOneAuthenticPixel(image,x,y,&pixel,&image->exception);
3091 % The format of the GetOnePixel() method is:
3093 % PixelPacket GetOnePixel(const Image image,const ssize_t x,const ssize_t y)
3095 % A description of each parameter follows:
3097 % o image: the image.
3099 % o x,y: These values define the location of the pixel to return.
3102 MagickExport PixelPacket GetOnePixel(Image *image,const ssize_t x,const ssize_t y)
3107 (void) GetOneAuthenticPixel(image,x,y,&pixel,&image->exception);
3112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3116 % G e t P i x e l s %
3120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3122 % GetPixels() returns the pixels associated with the last call to
3123 % QueueAuthenticPixels() or GetAuthenticPixels().
3125 % Deprecated, replace with:
3127 % GetAuthenticPixelQueue(image);
3129 % The format of the GetPixels() method is:
3131 % PixelPacket *GetPixels(const Image image)
3133 % A description of each parameter follows:
3135 % o pixels: GetPixels() returns the pixels associated with the last call
3136 % to QueueAuthenticPixels() or GetAuthenticPixels().
3138 % o image: the image.
3141 MagickExport PixelPacket *GetPixels(const Image *image)
3143 return(GetAuthenticPixelQueue(image));
3147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3151 % G e t P r e v i o u s I m a g e %
3155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3157 % GetPreviousImage() returns the previous image in a list.
3159 % Deprecated, replace with:
3161 % GetPreviousImageInList(images));
3163 % The format of the GetPreviousImage method is:
3165 % Image *GetPreviousImage(const Image *images)
3167 % A description of each parameter follows:
3169 % o images: the image list.
3172 MagickExport Image *GetPreviousImage(const Image *images)
3174 if (images->debug != MagickFalse)
3175 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
3176 return(GetPreviousImageInList(images));
3180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3184 % H S L T r a n s f o r m %
3188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3190 % HSLTransform() converts a (hue, saturation, lightness) to a (red, green,
3193 % The format of the HSLTransformImage method is:
3195 % void HSLTransform(const double hue,const double saturation,
3196 % const double lightness,Quantum *red,Quantum *green,Quantum *blue)
3198 % A description of each parameter follows:
3200 % o hue, saturation, lightness: A double value representing a
3201 % component of the HSL color space.
3203 % o red, green, blue: A pointer to a pixel component of type Quantum.
3207 static inline MagickRealType HueToRGB(MagickRealType m1,MagickRealType m2,
3214 if ((6.0*hue) < 1.0)
3215 return(m1+6.0*(m2-m1)*hue);
3216 if ((2.0*hue) < 1.0)
3218 if ((3.0*hue) < 2.0)
3219 return(m1+6.0*(m2-m1)*(2.0/3.0-hue));
3223 MagickExport void HSLTransform(const double hue,const double saturation,
3224 const double lightness,Quantum *red,Quantum *green,Quantum *blue)
3234 Convert HSL to RGB colorspace.
3236 assert(red != (Quantum *) NULL);
3237 assert(green != (Quantum *) NULL);
3238 assert(blue != (Quantum *) NULL);
3239 if (lightness <= 0.5)
3240 m2=lightness*(saturation+1.0);
3242 m2=lightness+saturation-lightness*saturation;
3243 m1=2.0*lightness-m2;
3244 r=HueToRGB(m1,m2,hue+1.0/3.0);
3245 g=HueToRGB(m1,m2,hue);
3246 b=HueToRGB(m1,m2,hue-1.0/3.0);
3247 *red=ClampToQuantum((MagickRealType) QuantumRange*r);
3248 *green=ClampToQuantum((MagickRealType) QuantumRange*g);
3249 *blue=ClampToQuantum((MagickRealType) QuantumRange*b);
3253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3257 % I d e n t i t y A f f i n e %
3261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3263 % IdentityAffine() initializes the affine transform to the identity matrix.
3265 % The format of the IdentityAffine method is:
3267 % IdentityAffine(AffineMatrix *affine)
3269 % A description of each parameter follows:
3271 % o affine: A pointer the affine transform of type AffineMatrix.
3274 MagickExport void IdentityAffine(AffineMatrix *affine)
3276 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3277 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3278 assert(affine != (AffineMatrix *) NULL);
3279 (void) ResetMagickMemory(affine,0,sizeof(AffineMatrix));
3285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3289 % I n i t i a l i z e M a g i c k %
3293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3295 % InitializeMagick() initializes the ImageMagick environment.
3297 % Deprecated, replace with:
3299 % MagickCoreGenesis(path,MagickFalse);
3301 % The format of the InitializeMagick function is:
3303 % InitializeMagick(const char *path)
3305 % A description of each parameter follows:
3307 % o path: the execution path of the current ImageMagick client.
3310 MagickExport void InitializeMagick(const char *path)
3312 MagickCoreGenesis(path,MagickFalse);
3316 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3320 % I n t e r p o l a t e P i x e l C o l o r %
3324 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3326 % InterpolatePixelColor() applies bi-linear or tri-linear interpolation
3327 % between a pixel and it's neighbors.
3329 % The format of the InterpolatePixelColor method is:
3331 % MagickPixelPacket InterpolatePixelColor(const Image *image,
3332 % CacheView *view_info,InterpolatePixelMethod method,const double x,
3333 % const double y,ExceptionInfo *exception)
3335 % A description of each parameter follows:
3337 % o image: the image.
3339 % o image_view: the image cache view.
3341 % o type: the type of pixel color interpolation.
3343 % o x,y: A double representing the current (x,y) position of the pixel.
3345 % o exception: return any errors or warnings in this structure.
3349 static inline double MagickMax(const double x,const double y)
3356 static void BicubicInterpolate(const MagickPixelPacket *pixels,const double dx,
3357 MagickPixelPacket *pixel)
3367 p=(pixels[3].red-pixels[2].red)-(pixels[0].red-pixels[1].red);
3368 q=(pixels[0].red-pixels[1].red)-p;
3369 r=pixels[2].red-pixels[0].red;
3371 pixel->red=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3372 p=(pixels[3].green-pixels[2].green)-(pixels[0].green-pixels[1].green);
3373 q=(pixels[0].green-pixels[1].green)-p;
3374 r=pixels[2].green-pixels[0].green;
3376 pixel->green=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3377 p=(pixels[3].blue-pixels[2].blue)-(pixels[0].blue-pixels[1].blue);
3378 q=(pixels[0].blue-pixels[1].blue)-p;
3379 r=pixels[2].blue-pixels[0].blue;
3381 pixel->blue=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3382 p=(pixels[3].opacity-pixels[2].opacity)-(pixels[0].opacity-pixels[1].opacity);
3383 q=(pixels[0].opacity-pixels[1].opacity)-p;
3384 r=pixels[2].opacity-pixels[0].opacity;
3385 s=pixels[1].opacity;
3386 pixel->opacity=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3387 if (pixel->colorspace == CMYKColorspace)
3389 p=(pixels[3].index-pixels[2].index)-(pixels[0].index-pixels[1].index);
3390 q=(pixels[0].index-pixels[1].index)-p;
3391 r=pixels[2].index-pixels[0].index;
3393 pixel->index=(dx*dx2*p)+(dx2*q)+(dx*r)+s;
3397 static inline MagickRealType CubicWeightingFunction(const MagickRealType x)
3403 alpha=MagickMax(x+2.0,0.0);
3404 gamma=1.0*alpha*alpha*alpha;
3405 alpha=MagickMax(x+1.0,0.0);
3406 gamma-=4.0*alpha*alpha*alpha;
3407 alpha=MagickMax(x+0.0,0.0);
3408 gamma+=6.0*alpha*alpha*alpha;
3409 alpha=MagickMax(x-1.0,0.0);
3410 gamma-=4.0*alpha*alpha*alpha;
3414 static inline double MeshInterpolate(const PointInfo *delta,const double p,
3415 const double x,const double y)
3417 return(delta->x*x+delta->y*y+(1.0-delta->x-delta->y)*p);
3420 static inline ssize_t NearestNeighbor(MagickRealType x)
3423 return((ssize_t) (x+0.5));
3424 return((ssize_t) (x-0.5));
3427 MagickExport MagickPixelPacket InterpolatePixelColor(const Image *image,
3428 CacheView *image_view,const InterpolatePixelMethod method,const double x,
3429 const double y,ExceptionInfo *exception)
3434 register const IndexPacket
3437 register const PixelPacket
3443 assert(image != (Image *) NULL);
3444 assert(image->signature == MagickSignature);
3445 assert(image_view != (CacheView *) NULL);
3446 GetMagickPixelPacket(image,&pixel);
3449 case AverageInterpolatePixel:
3458 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x)-1,(ssize_t) floor(y)-
3460 if (p == (const PixelPacket *) NULL)
3462 indexes=GetCacheViewVirtualIndexQueue(image_view);
3463 for (i=0; i < 16L; i++)
3465 GetMagickPixelPacket(image,pixels+i);
3466 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3468 if (image->matte != MagickFalse)
3470 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3471 pixels[i].red*=alpha[i];
3472 pixels[i].green*=alpha[i];
3473 pixels[i].blue*=alpha[i];
3474 if (image->colorspace == CMYKColorspace)
3475 pixels[i].index*=alpha[i];
3478 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3479 pixel.red+=gamma*0.0625*pixels[i].red;
3480 pixel.green+=gamma*0.0625*pixels[i].green;
3481 pixel.blue+=gamma*0.0625*pixels[i].blue;
3482 pixel.opacity+=0.0625*pixels[i].opacity;
3483 if (image->colorspace == CMYKColorspace)
3484 pixel.index+=gamma*0.0625*pixels[i].index;
3489 case BicubicInterpolatePixel:
3501 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x)-1,(ssize_t) floor(y)-
3503 if (p == (const PixelPacket *) NULL)
3505 indexes=GetCacheViewVirtualIndexQueue(image_view);
3506 for (i=0; i < 16L; i++)
3508 GetMagickPixelPacket(image,pixels+i);
3509 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3511 if (image->matte != MagickFalse)
3513 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3514 pixels[i].red*=alpha[i];
3515 pixels[i].green*=alpha[i];
3516 pixels[i].blue*=alpha[i];
3517 if (image->colorspace == CMYKColorspace)
3518 pixels[i].index*=alpha[i];
3523 for (i=0; i < 4L; i++)
3524 BicubicInterpolate(pixels+4*i,delta.x,u+i);
3526 BicubicInterpolate(u,delta.y,&pixel);
3529 case BilinearInterpolatePixel:
3542 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x),(ssize_t) floor(y),2,
3544 if (p == (const PixelPacket *) NULL)
3546 indexes=GetCacheViewVirtualIndexQueue(image_view);
3547 for (i=0; i < 4L; i++)
3549 GetMagickPixelPacket(image,pixels+i);
3550 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3552 if (image->matte != MagickFalse)
3554 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3555 pixels[i].red*=alpha[i];
3556 pixels[i].green*=alpha[i];
3557 pixels[i].blue*=alpha[i];
3558 if (image->colorspace == CMYKColorspace)
3559 pixels[i].index*=alpha[i];
3565 gamma=(((1.0-delta.y)*((1.0-delta.x)*alpha[0]+delta.x*alpha[1])+delta.y*
3566 ((1.0-delta.x)*alpha[2]+delta.x*alpha[3])));
3567 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3568 pixel.red=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].red+delta.x*
3569 pixels[1].red)+delta.y*((1.0-delta.x)*pixels[2].red+delta.x*
3571 pixel.green=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].green+delta.x*
3572 pixels[1].green)+delta.y*((1.0-delta.x)*pixels[2].green+
3573 delta.x*pixels[3].green));
3574 pixel.blue=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].blue+delta.x*
3575 pixels[1].blue)+delta.y*((1.0-delta.x)*pixels[2].blue+delta.x*
3577 pixel.opacity=((1.0-delta.y)*((1.0-delta.x)*pixels[0].opacity+delta.x*
3578 pixels[1].opacity)+delta.y*((1.0-delta.x)*pixels[2].opacity+delta.x*
3579 pixels[3].opacity));
3580 if (image->colorspace == CMYKColorspace)
3581 pixel.index=gamma*((1.0-delta.y)*((1.0-delta.x)*pixels[0].index+delta.x*
3582 pixels[1].index)+delta.y*((1.0-delta.x)*pixels[2].index+delta.x*
3586 case FilterInterpolatePixel:
3600 geometry.x=(ssize_t) floor(x)-1L;
3601 geometry.y=(ssize_t) floor(y)-1L;
3602 excerpt_image=ExcerptImage(image,&geometry,exception);
3603 if (excerpt_image == (Image *) NULL)
3605 filter_image=ResizeImage(excerpt_image,1,1,image->filter,image->blur,
3607 excerpt_image=DestroyImage(excerpt_image);
3608 if (filter_image == (Image *) NULL)
3610 p=GetVirtualPixels(filter_image,0,0,1,1,exception);
3611 if (p == (const PixelPacket *) NULL)
3613 filter_image=DestroyImage(filter_image);
3616 indexes=GetVirtualIndexQueue(filter_image);
3617 GetMagickPixelPacket(image,pixels);
3618 SetMagickPixelPacket(image,p,indexes,&pixel);
3619 filter_image=DestroyImage(filter_image);
3622 case IntegerInterpolatePixel:
3627 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x),(ssize_t) floor(y),1,
3629 if (p == (const PixelPacket *) NULL)
3631 indexes=GetCacheViewVirtualIndexQueue(image_view);
3632 GetMagickPixelPacket(image,pixels);
3633 SetMagickPixelPacket(image,p,indexes,&pixel);
3636 case MeshInterpolatePixel:
3649 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x),(ssize_t) floor(y),
3651 if (p == (const PixelPacket *) NULL)
3653 indexes=GetCacheViewVirtualIndexQueue(image_view);
3654 for (i=0; i < 4L; i++)
3656 GetMagickPixelPacket(image,pixels+i);
3657 SetMagickPixelPacket(image,p,indexes+i,pixels+i);
3659 if (image->matte != MagickFalse)
3661 alpha[i]=QuantumScale*((MagickRealType) GetAlphaPixelComponent(p));
3662 pixels[i].red*=alpha[i];
3663 pixels[i].green*=alpha[i];
3664 pixels[i].blue*=alpha[i];
3665 if (image->colorspace == CMYKColorspace)
3666 pixels[i].index*=alpha[i];
3672 luminance.x=MagickPixelLuminance(pixels+0)-MagickPixelLuminance(pixels+3);
3673 luminance.y=MagickPixelLuminance(pixels+1)-MagickPixelLuminance(pixels+2);
3674 if (fabs(luminance.x) < fabs(luminance.y))
3679 if (delta.x <= delta.y)
3682 Bottom-left triangle (pixel:2, diagonal: 0-3).
3684 delta.y=1.0-delta.y;
3685 gamma=MeshInterpolate(&delta,alpha[2],alpha[3],alpha[0]);
3686 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3687 pixel.red=gamma*MeshInterpolate(&delta,pixels[2].red,
3688 pixels[3].red,pixels[0].red);
3689 pixel.green=gamma*MeshInterpolate(&delta,pixels[2].green,
3690 pixels[3].green,pixels[0].green);
3691 pixel.blue=gamma*MeshInterpolate(&delta,pixels[2].blue,
3692 pixels[3].blue,pixels[0].blue);
3693 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[2].opacity,
3694 pixels[3].opacity,pixels[0].opacity);
3695 if (image->colorspace == CMYKColorspace)
3696 pixel.index=gamma*MeshInterpolate(&delta,pixels[2].index,
3697 pixels[3].index,pixels[0].index);
3702 Top-right triangle (pixel:1, diagonal: 0-3).
3704 delta.x=1.0-delta.x;
3705 gamma=MeshInterpolate(&delta,alpha[1],alpha[0],alpha[3]);
3706 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3707 pixel.red=gamma*MeshInterpolate(&delta,pixels[1].red,
3708 pixels[0].red,pixels[3].red);
3709 pixel.green=gamma*MeshInterpolate(&delta,pixels[1].green,
3710 pixels[0].green,pixels[3].green);
3711 pixel.blue=gamma*MeshInterpolate(&delta,pixels[1].blue,
3712 pixels[0].blue,pixels[3].blue);
3713 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[1].opacity,
3714 pixels[0].opacity,pixels[3].opacity);
3715 if (image->colorspace == CMYKColorspace)
3716 pixel.index=gamma*MeshInterpolate(&delta,pixels[1].index,
3717 pixels[0].index,pixels[3].index);
3725 if (delta.x <= (1.0-delta.y))
3728 Top-left triangle (pixel 0, diagonal: 1-2).
3730 gamma=MeshInterpolate(&delta,alpha[0],alpha[1],alpha[2]);
3731 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3732 pixel.red=gamma*MeshInterpolate(&delta,pixels[0].red,
3733 pixels[1].red,pixels[2].red);
3734 pixel.green=gamma*MeshInterpolate(&delta,pixels[0].green,
3735 pixels[1].green,pixels[2].green);
3736 pixel.blue=gamma*MeshInterpolate(&delta,pixels[0].blue,
3737 pixels[1].blue,pixels[2].blue);
3738 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[0].opacity,
3739 pixels[1].opacity,pixels[2].opacity);
3740 if (image->colorspace == CMYKColorspace)
3741 pixel.index=gamma*MeshInterpolate(&delta,pixels[0].index,
3742 pixels[1].index,pixels[2].index);
3747 Bottom-right triangle (pixel: 3, diagonal: 1-2).
3749 delta.x=1.0-delta.x;
3750 delta.y=1.0-delta.y;
3751 gamma=MeshInterpolate(&delta,alpha[3],alpha[2],alpha[1]);
3752 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3753 pixel.red=gamma*MeshInterpolate(&delta,pixels[3].red,
3754 pixels[2].red,pixels[1].red);
3755 pixel.green=gamma*MeshInterpolate(&delta,pixels[3].green,
3756 pixels[2].green,pixels[1].green);
3757 pixel.blue=gamma*MeshInterpolate(&delta,pixels[3].blue,
3758 pixels[2].blue,pixels[1].blue);
3759 pixel.opacity=gamma*MeshInterpolate(&delta,pixels[3].opacity,
3760 pixels[2].opacity,pixels[1].opacity);
3761 if (image->colorspace == CMYKColorspace)
3762 pixel.index=gamma*MeshInterpolate(&delta,pixels[3].index,
3763 pixels[2].index,pixels[1].index);
3768 case NearestNeighborInterpolatePixel:
3773 p=GetCacheViewVirtualPixels(image_view,NearestNeighbor(x),
3774 NearestNeighbor(y),1,1,exception);
3775 if (p == (const PixelPacket *) NULL)
3777 indexes=GetCacheViewVirtualIndexQueue(image_view);
3778 GetMagickPixelPacket(image,pixels);
3779 SetMagickPixelPacket(image,p,indexes,&pixel);
3782 case SplineInterpolatePixel:
3800 p=GetCacheViewVirtualPixels(image_view,(ssize_t) floor(x)-1,(ssize_t)
3801 floor(y)-1,4,4,exception);
3802 if (p == (const PixelPacket *) NULL)
3804 indexes=GetCacheViewVirtualIndexQueue(image_view);
3808 for (i=(-1); i < 3L; i++)
3810 dy=CubicWeightingFunction((MagickRealType) i-delta.y);
3811 for (j=(-1); j < 3L; j++)
3813 GetMagickPixelPacket(image,pixels+n);
3814 SetMagickPixelPacket(image,p,indexes+n,pixels+n);
3816 if (image->matte != MagickFalse)
3818 alpha[n]=QuantumScale*((MagickRealType)
3819 GetAlphaPixelComponent(p));
3820 pixels[n].red*=alpha[n];
3821 pixels[n].green*=alpha[n];
3822 pixels[n].blue*=alpha[n];
3823 if (image->colorspace == CMYKColorspace)
3824 pixels[n].index*=alpha[n];
3826 dx=CubicWeightingFunction(delta.x-(MagickRealType) j);
3828 gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
3829 pixel.red+=gamma*dx*dy*pixels[n].red;
3830 pixel.green+=gamma*dx*dy*pixels[n].green;
3831 pixel.blue+=gamma*dx*dy*pixels[n].blue;
3832 if (image->matte != MagickFalse)
3833 pixel.opacity+=dx*dy*pixels[n].opacity;
3834 if (image->colorspace == CMYKColorspace)
3835 pixel.index+=gamma*dx*dy*pixels[n].index;
3847 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3851 % I n t e r p r e t I m a g e A t t r i b u t e s %
3855 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3857 % InterpretImageAttributes() replaces any embedded formatting characters with
3858 % the appropriate image attribute and returns the translated text.
3860 % Deprecated, replace with:
3862 % InterpretImageProperties(image_info,image,embed_text);
3864 % The format of the InterpretImageAttributes method is:
3866 % char *InterpretImageAttributes(const ImageInfo *image_info,Image *image,
3867 % const char *embed_text)
3869 % A description of each parameter follows:
3871 % o image_info: the image info.
3873 % o image: the image.
3875 % o embed_text: the address of a character string containing the embedded
3876 % formatting characters.
3879 MagickExport char *InterpretImageAttributes(const ImageInfo *image_info,
3880 Image *image,const char *embed_text)
3882 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
3883 return(InterpretImageProperties(image_info,image,embed_text));
3887 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3891 + I s S u b i m a g e %
3895 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3897 % IsSubimage() returns MagickTrue if the geometry is a valid subimage
3898 % specification (e.g. [1], [1-9], [1,7,4]).
3900 % The format of the IsSubimage method is:
3902 % unsigned int IsSubimage(const char *geometry,const unsigned int pedantic)
3904 % A description of each parameter follows:
3906 % o geometry: This string is the geometry specification.
3908 % o pedantic: A value other than 0 invokes a more restrictive set of
3909 % conditions for a valid specification (e.g. [1], [1-4], [4-1]).
3912 MagickExport unsigned int IsSubimage(const char *geometry,
3913 const unsigned int pedantic)
3915 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
3916 if (geometry == (const char *) NULL)
3917 return(MagickFalse);
3918 if ((strchr(geometry,'x') != (char *) NULL) ||
3919 (strchr(geometry,'X') != (char *) NULL))
3920 return(MagickFalse);
3921 if ((pedantic != MagickFalse) && (strchr(geometry,',') != (char *) NULL))
3922 return(MagickFalse);
3927 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3931 % L e v e l I m a g e C o l o r s %
3935 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3937 % LevelImageColor() will map the given color to "black" and "white"
3938 % values, limearly spreading out the colors, and level values on a channel by
3939 % channel bases, as per LevelImage(). The given colors allows you to specify
3940 % different level ranges for each of the color channels separately.
3942 % If the boolean 'invert' is set true the image values will modifyed in the
3943 % reverse direction. That is any existing "black" and "white" colors in the
3944 % image will become the color values given, with all other values compressed
3945 % appropriatally. This effectivally maps a greyscale gradient into the given
3948 % Deprecated, replace with:
3950 % LevelColorsImageChannel(image,channel,black_color,white_color,invert);
3952 % The format of the LevelImageColors method is:
3954 % MagickBooleanType LevelImageColors(Image *image,const ChannelType channel,
3955 % const MagickPixelPacket *black_color,const MagickPixelPacket *white_color,
3956 % const MagickBooleanType invert)
3958 % A description of each parameter follows:
3960 % o image: the image.
3962 % o channel: the channel.
3964 % o black_color: The color to map black to/from
3966 % o white_point: The color to map white to/from
3968 % o invert: if true map the colors (levelize), rather than from (level)
3971 MagickBooleanType LevelImageColors(Image *image,const ChannelType channel,
3972 const MagickPixelPacket *black_color,const MagickPixelPacket *white_color,
3973 const MagickBooleanType invert)
3975 return(LevelColorsImageChannel(image,channel,black_color,white_color,invert));
3979 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3983 % L i b e r a t e M e m o r y %
3987 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3989 % LiberateMemory() frees memory that has already been allocated, and NULL's
3990 % the pointer to it.
3992 % The format of the LiberateMemory method is:
3994 % void LiberateMemory(void **memory)
3996 % A description of each parameter follows:
3998 % o memory: A pointer to a block of memory to free for reuse.
4001 MagickExport void LiberateMemory(void **memory)
4003 assert(memory != (void **) NULL);
4004 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
4005 if (*memory == (void *) NULL)
4008 *memory=(void *) NULL;
4012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4016 % L i b e r a t e S e m a p h o r e I n f o %
4020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4022 % LiberateSemaphoreInfo() relinquishes a semaphore.
4024 % Deprecated, replace with:
4026 % UnlockSemaphoreInfo(*semaphore_info);
4028 % The format of the LiberateSemaphoreInfo method is:
4030 % LiberateSemaphoreInfo(void **semaphore_info)
4032 % A description of each parameter follows:
4034 % o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
4037 MagickExport void LiberateSemaphoreInfo(SemaphoreInfo **semaphore_info)
4039 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
4040 UnlockSemaphoreInfo(*semaphore_info);
4044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4048 % M a g i c k I n c a r n a t e %
4052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4054 % MagickIncarnate() initializes the ImageMagick environment.
4056 % Deprecated, replace with:
4058 % MagickCoreGenesis(path,MagickFalse);
4060 % The format of the MagickIncarnate function is:
4062 % MagickIncarnate(const char *path)
4064 % A description of each parameter follows:
4066 % o path: the execution path of the current ImageMagick client.
4070 MagickExport void MagickIncarnate(const char *path)
4072 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
4073 MagickCoreGenesis(path,MagickFalse);
4077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4081 % M a g i c k M o n i t o r %
4085 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4087 % MagickMonitor() calls the monitor handler method with a text string that
4088 % describes the task and a measure of completion. The method returns
4089 % MagickTrue on success otherwise MagickFalse if an error is encountered, e.g.
4090 % if there was a user interrupt.
4092 % The format of the MagickMonitor method is:
4094 % MagickBooleanType MagickMonitor(const char *text,
4095 % const MagickOffsetType offset,const MagickSizeType span,
4096 % void *client_data)
4098 % A description of each parameter follows:
4100 % o offset: the position relative to the span parameter which represents
4101 % how much progress has been made toward completing a task.
4103 % o span: the span relative to completing a task.
4105 % o client_data: the client data.
4108 MagickExport MagickBooleanType MagickMonitor(const char *text,
4109 const MagickOffsetType offset,const MagickSizeType span,
4110 void *magick_unused(client_data))
4118 assert(text != (const char *) NULL);
4119 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",text);
4120 ProcessPendingEvents(text);
4122 exception=AcquireExceptionInfo();
4123 if (monitor_handler != (MonitorHandler) NULL)
4124 status=(*monitor_handler)(text,offset,span,exception);
4125 exception=DestroyExceptionInfo(exception);
4130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4140 % MapImage() replaces the colors of an image with the closest color from a
4143 % Deprecated, replace with:
4145 % QuantizeInfo quantize_info;
4146 % GetQuantizeInfo(&quantize_info);
4147 % quantize_info.dither=dither;
4148 % RemapImage(&quantize_info,image,map_image);
4150 % The format of the MapImage method is:
4152 % MagickBooleanType MapImage(Image *image,const Image *map_image,
4153 % const MagickBooleanType dither)
4155 % A description of each parameter follows:
4157 % o image: Specifies a pointer to an Image structure.
4159 % o map_image: the image. Reduce image to a set of colors represented by
4162 % o dither: Set this integer value to something other than zero to
4163 % dither the mapped image.
4166 MagickExport MagickBooleanType MapImage(Image *image,const Image *map_image,
4167 const MagickBooleanType dither)
4173 Initialize color cube.
4175 assert(image != (Image *) NULL);
4176 assert(image->signature == MagickSignature);
4177 if (image->debug != MagickFalse)
4178 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4179 assert(map_image != (Image *) NULL);
4180 assert(map_image->signature == MagickSignature);
4181 GetQuantizeInfo(&quantize_info);
4182 quantize_info.dither=dither;
4183 return(RemapImage(&quantize_info,image,map_image));
4187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4191 % M a p I m a g e s %
4195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4197 % MapImages() replaces the colors of a sequence of images with the closest
4198 % color from a reference image.
4200 % Deprecated, replace with:
4202 % QuantizeInfo quantize_info;
4203 % GetQuantizeInfo(&quantize_info);
4204 % quantize_info.dither=dither;
4205 % RemapImages(&quantize_info,images,map_image);
4207 % The format of the MapImage method is:
4209 % MagickBooleanType MapImages(Image *images,Image *map_image,
4210 % const MagickBooleanType dither)
4212 % A description of each parameter follows:
4214 % o image: Specifies a pointer to a set of Image structures.
4216 % o map_image: the image. Reduce image to a set of colors represented by
4219 % o dither: Set this integer value to something other than zero to
4220 % dither the quantized image.
4223 MagickExport MagickBooleanType MapImages(Image *images,const Image *map_image,
4224 const MagickBooleanType dither)
4229 assert(images != (Image *) NULL);
4230 assert(images->signature == MagickSignature);
4231 if (images->debug != MagickFalse)
4232 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
4233 GetQuantizeInfo(&quantize_info);
4234 quantize_info.dither=dither;
4235 return(RemapImages(&quantize_info,images,map_image));
4239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4243 % M a t t e F l o o d f i l l I m a g e %
4247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4249 % MatteFloodfill() changes the transparency value of any pixel that matches
4250 % target and is an immediate neighbor. If the method FillToBorderMethod
4251 % is specified, the transparency value is changed for any neighbor pixel
4252 % that does not match the bordercolor member of image.
4254 % By default target must match a particular pixel transparency exactly.
4255 % However, in many cases two transparency values may differ by a
4256 % small amount. The fuzz member of image defines how much tolerance is
4257 % acceptable to consider two transparency values as the same. For example,
4258 % set fuzz to 10 and the opacity values of 100 and 102 respectively are
4259 % now interpreted as the same value for the purposes of the floodfill.
4261 % The format of the MatteFloodfillImage method is:
4263 % MagickBooleanType MatteFloodfillImage(Image *image,
4264 % const PixelPacket target,const Quantum opacity,const ssize_t x_offset,
4265 % const ssize_t y_offset,const PaintMethod method)
4267 % A description of each parameter follows:
4269 % o image: the image.
4271 % o target: the RGB value of the target color.
4273 % o opacity: the level of transparency: 0 is fully opaque and QuantumRange is
4274 % fully transparent.
4276 % o x,y: the starting location of the operation.
4278 % o method: Choose either FloodfillMethod or FillToBorderMethod.
4281 MagickExport MagickBooleanType MatteFloodfillImage(Image *image,
4282 const PixelPacket target,const Quantum opacity,const ssize_t x_offset,
4283 const ssize_t y_offset,const PaintMethod method)
4291 register SegmentInfo
4306 Check boundary conditions.
4308 assert(image != (Image *) NULL);
4309 assert(image->signature == MagickSignature);
4310 if (image->debug != MagickFalse)
4311 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4312 if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
4313 return(MagickFalse);
4314 if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
4315 return(MagickFalse);
4316 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
4317 return(MagickFalse);
4318 if (image->matte == MagickFalse)
4319 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
4320 floodplane_image=CloneImage(image,image->columns,image->rows,MagickTrue,
4322 if (floodplane_image == (Image *) NULL)
4323 return(MagickFalse);
4324 (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel);
4326 Set floodfill color.
4328 segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
4329 sizeof(*segment_stack));
4330 if (segment_stack == (SegmentInfo *) NULL)
4332 floodplane_image=DestroyImage(floodplane_image);
4333 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
4337 Push initial segment on stack.
4343 PushSegmentStack(y,x,x,1);
4344 PushSegmentStack(y+1,x,x,-1);
4345 while (s > segment_stack)
4347 register const PixelPacket
4353 register PixelPacket
4357 Pop segment off stack.
4362 offset=(ssize_t) s->y2;
4363 y=(ssize_t) s->y1+offset;
4365 Recolor neighboring pixels.
4367 p=GetVirtualPixels(image,0,y,(size_t) (x1+1),1,&image->exception);
4368 q=GetAuthenticPixels(floodplane_image,0,y,(size_t) (x1+1),1,
4370 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4374 for (x=x1; x >= 0; x--)
4376 if (q->opacity == (Quantum) TransparentOpacity)
4378 if (method == FloodfillMethod)
4380 if (IsColorSimilar(image,p,&target) == MagickFalse)
4384 if (IsColorSimilar(image,p,&target) != MagickFalse)
4386 q->opacity=(Quantum) TransparentOpacity;
4390 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
4392 skip=x >= x1 ? MagickTrue : MagickFalse;
4393 if (skip == MagickFalse)
4397 PushSegmentStack(y,start,x1-1,-offset);
4402 if (skip == MagickFalse)
4404 if (x < (ssize_t) image->columns)
4406 p=GetVirtualPixels(image,x,y,image->columns-x,1,
4408 q=GetAuthenticPixels(floodplane_image,x,y,image->columns-x,1,
4410 if ((p == (const PixelPacket *) NULL) ||
4411 (q == (PixelPacket *) NULL))
4413 for ( ; x < (ssize_t) image->columns; x++)
4415 if (q->opacity == (Quantum) TransparentOpacity)
4417 if (method == FloodfillMethod)
4419 if (IsColorSimilar(image,p,&target) == MagickFalse)
4423 if (IsColorSimilar(image,p,&target) != MagickFalse)
4425 q->opacity=(Quantum) TransparentOpacity;
4429 if (SyncAuthenticPixels(floodplane_image,&image->exception) == MagickFalse)
4432 PushSegmentStack(y,start,x-1,offset);
4434 PushSegmentStack(y,x2+1,x-1,-offset);
4440 p=GetVirtualPixels(image,x,y,(size_t) (x2-x+1),1,
4442 q=GetAuthenticPixels(floodplane_image,x,y,(size_t) (x2-x+1),1,
4444 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4446 for ( ; x <= x2; x++)
4448 if (q->opacity == (Quantum) TransparentOpacity)
4450 if (method == FloodfillMethod)
4452 if (IsColorSimilar(image,p,&target) != MagickFalse)
4456 if (IsColorSimilar(image,p,&target) == MagickFalse)
4465 for (y=0; y < (ssize_t) image->rows; y++)
4467 register const PixelPacket
4473 register PixelPacket
4477 Tile fill color onto floodplane.
4479 p=GetVirtualPixels(floodplane_image,0,y,image->columns,1,
4481 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4482 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
4484 for (x=0; x < (ssize_t) image->columns; x++)
4486 if (p->opacity != OpaqueOpacity)
4491 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4494 segment_stack=(SegmentInfo *) RelinquishMagickMemory(segment_stack);
4495 floodplane_image=DestroyImage(floodplane_image);
4496 return(y == (ssize_t) image->rows ? MagickTrue : MagickFalse);
4500 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4504 % M a x i m u m I m a g e s %
4508 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4510 % MaximumImages() returns the maximum intensity of an image sequence.
4512 % Deprecated, replace with:
4514 % EvaluateImages(images,MinEvaluateOperator,exception);
4516 % The format of the MaxImages method is:
4518 % Image *MaximumImages(Image *images,ExceptionInfo *exception)
4520 % A description of each parameter follows:
4522 % o images: the image sequence.
4524 % o exception: return any errors or warnings in this structure.
4527 MagickExport Image *MaximumImages(const Image *images,ExceptionInfo *exception)
4529 return(EvaluateImages(images,MinEvaluateOperator,exception));
4533 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4537 % M i n i m u m I m a g e s %
4541 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4543 % MinimumImages() returns the minimum intensity of an image sequence.
4545 % Deprecated, replace with:
4547 % EvaluateImages(images,MinEvaluateOperator,exception);
4549 % The format of the MinimumImages method is:
4551 % Image *MinimumImages(Image *images,ExceptionInfo *exception)
4553 % A description of each parameter follows:
4555 % o images: the image sequence.
4557 % o exception: return any errors or warnings in this structure.
4560 MagickExport Image *MinimumImages(const Image *images,ExceptionInfo *exception)
4562 return(EvaluateImages(images,MinEvaluateOperator,exception));
4566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4570 % M o s a i c I m a g e s %
4574 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4576 % MosaicImages() Obsolete Function: Use MergeImageLayers() instead.
4578 % Deprecated, replace with:
4580 % MergeImageLayers(image,MosaicLayer,exception);
4582 % The format of the MosaicImage method is:
4584 % Image *MosaicImages(const Image *image,ExceptionInfo *exception)
4586 % A description of each parameter follows:
4588 % o image: the image list to be composited together
4590 % o exception: return any errors or warnings in this structure.
4593 MagickExport Image *MosaicImages(Image *image,ExceptionInfo *exception)
4595 return(MergeImageLayers(image,MosaicLayer,exception));
4599 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4603 % O p a q u e I m a g e %
4607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4609 % OpaqueImage() changes any pixel that matches color with the color
4612 % By default color must match a particular pixel color exactly. However,
4613 % in many cases two colors may differ by a small amount. Fuzz defines
4614 % how much tolerance is acceptable to consider two colors as the same.
4615 % For example, set fuzz to 10 and the color red at intensities of 100 and
4616 % 102 respectively are now interpreted as the same color.
4618 % The format of the OpaqueImage method is:
4620 % MagickBooleanType OpaqueImage(Image *image,
4621 % const PixelPacket *target,const PixelPacket fill)
4623 % A description of each parameter follows:
4625 % o image: the image.
4627 % o target: the RGB value of the target color.
4629 % o fill: the replacement color.
4632 MagickExport MagickBooleanType OpaqueImage(Image *image,
4633 const PixelPacket target,const PixelPacket fill)
4635 #define OpaqueImageTag "Opaque/Image"
4647 Make image color opaque.
4649 assert(image != (Image *) NULL);
4650 assert(image->signature == MagickSignature);
4651 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.1.0");
4652 if (image->debug != MagickFalse)
4653 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4654 switch (image->storage_class)
4660 Make DirectClass image opaque.
4662 for (y=0; y < (ssize_t) image->rows; y++)
4667 register PixelPacket
4670 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4671 if (q == (PixelPacket *) NULL)
4673 for (x=0; x < (ssize_t) image->columns; x++)
4675 if (IsColorSimilar(image,q,&target) != MagickFalse)
4679 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4681 proceed=SetImageProgress(image,OpaqueImageTag,(MagickOffsetType) y,
4683 if (proceed == MagickFalse)
4691 Make PseudoClass image opaque.
4693 for (i=0; i < (ssize_t) image->colors; i++)
4695 if (IsColorSimilar(image,&image->colormap[i],&target) != MagickFalse)
4696 image->colormap[i]=fill;
4698 if (fill.opacity != OpaqueOpacity)
4700 for (y=0; y < (ssize_t) image->rows; y++)
4705 register PixelPacket
4708 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
4709 if (q == (PixelPacket *) NULL)
4711 for (x=0; x < (ssize_t) image->columns; x++)
4713 if (IsColorSimilar(image,q,&target) != MagickFalse)
4714 q->opacity=fill.opacity;
4717 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
4721 (void) SyncImage(image);
4725 if (fill.opacity != OpaqueOpacity)
4726 image->matte=MagickTrue;
4731 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4735 % O p e n C a c h e V i e w %
4739 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4741 % OpenCacheView() opens a view into the pixel cache, using the
4742 % VirtualPixelMethod that is defined within the given image itself.
4744 % Deprecated, replace with:
4746 % AcquireCacheView(image);
4748 % The format of the OpenCacheView method is:
4750 % CacheView *OpenCacheView(const Image *image)
4752 % A description of each parameter follows:
4754 % o image: the image.
4757 MagickExport CacheView *OpenCacheView(const Image *image)
4759 return(AcquireCacheView(image));
4763 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4767 % P a i n t F l o o d f i l l I m a g e %
4771 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4773 % PaintFloodfill() changes the color value of any pixel that matches
4774 % target and is an immediate neighbor. If the method FillToBorderMethod is
4775 % specified, the color value is changed for any neighbor pixel that does not
4776 % match the bordercolor member of image.
4778 % By default target must match a particular pixel color exactly.
4779 % However, in many cases two colors may differ by a small amount. The
4780 % fuzz member of image defines how much tolerance is acceptable to
4781 % consider two colors as the same. For example, set fuzz to 10 and the
4782 % color red at intensities of 100 and 102 respectively are now
4783 % interpreted as the same color for the purposes of the floodfill.
4785 % Deprecated, replace with:
4787 % FloodfillPaintImage(image,channel,draw_info,target,x,y,
4788 % method == FloodfillMethod ? MagickFalse : MagickTrue);
4790 % The format of the PaintFloodfillImage method is:
4792 % MagickBooleanType PaintFloodfillImage(Image *image,
4793 % const ChannelType channel,const MagickPixelPacket target,const ssize_t x,
4794 % const ssize_t y,const DrawInfo *draw_info,const PaintMethod method)
4796 % A description of each parameter follows:
4798 % o image: the image.
4800 % o channel: the channel(s).
4802 % o target: the RGB value of the target color.
4804 % o x,y: the starting location of the operation.
4806 % o draw_info: the draw info.
4808 % o method: Choose either FloodfillMethod or FillToBorderMethod.
4811 MagickExport MagickBooleanType PaintFloodfillImage(Image *image,
4812 const ChannelType channel,const MagickPixelPacket *target,const ssize_t x,
4813 const ssize_t y,const DrawInfo *draw_info,const PaintMethod method)
4818 status=FloodfillPaintImage(image,channel,draw_info,target,x,y,
4819 method == FloodfillMethod ? MagickFalse : MagickTrue);
4824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4827 % P a i n t O p a q u e I m a g e %
4830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4832 % PaintOpaqueImage() changes any pixel that matches color with the color
4835 % By default color must match a particular pixel color exactly. However,
4836 % in many cases two colors may differ by a small amount. Fuzz defines
4837 % how much tolerance is acceptable to consider two colors as the same.
4838 % For example, set fuzz to 10 and the color red at intensities of 100 and
4839 % 102 respectively are now interpreted as the same color.
4841 % Deprecated, replace with:
4843 % OpaquePaintImageChannel(image,DefaultChannels,target,fill,MagickFalse);
4844 % OpaquePaintImageChannel(image,channel,target,fill,MagickFalse);
4846 % The format of the PaintOpaqueImage method is:
4848 % MagickBooleanType PaintOpaqueImage(Image *image,
4849 % const PixelPacket *target,const PixelPacket *fill)
4850 % MagickBooleanType PaintOpaqueImageChannel(Image *image,
4851 % const ChannelType channel,const PixelPacket *target,
4852 % const PixelPacket *fill)
4854 % A description of each parameter follows:
4856 % o image: the image.
4858 % o channel: the channel(s).
4860 % o target: the RGB value of the target color.
4862 % o fill: the replacement color.
4866 MagickExport MagickBooleanType PaintOpaqueImage(Image *image,
4867 const MagickPixelPacket *target,const MagickPixelPacket *fill)
4872 status=OpaquePaintImageChannel(image,DefaultChannels,target,fill,MagickFalse);
4876 MagickExport MagickBooleanType PaintOpaqueImageChannel(Image *image,
4877 const ChannelType channel,const MagickPixelPacket *target,
4878 const MagickPixelPacket *fill)
4880 return(OpaquePaintImageChannel(image,channel,target,fill,MagickFalse));
4884 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4888 % P a i n t T r a n s p a r e n t I m a g e %
4892 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4894 % PaintTransparentImage() changes the opacity value associated with any pixel
4895 % that matches color to the value defined by opacity.
4897 % By default color must match a particular pixel color exactly. However,
4898 % in many cases two colors may differ by a small amount. Fuzz defines
4899 % how much tolerance is acceptable to consider two colors as the same.
4900 % For example, set fuzz to 10 and the color red at intensities of 100 and
4901 % 102 respectively are now interpreted as the same color.
4903 % Deprecated, replace with:
4905 % TransparentPaintImage(image,target,opacity,MagickFalse);
4907 % The format of the PaintTransparentImage method is:
4909 % MagickBooleanType PaintTransparentImage(Image *image,
4910 % const MagickPixelPacket *target,const Quantum opacity)
4912 % A description of each parameter follows:
4914 % o image: the image.
4916 % o target: the RGB value of the target color.
4918 % o opacity: the replacement opacity value.
4921 MagickExport MagickBooleanType PaintTransparentImage(Image *image,
4922 const MagickPixelPacket *target,const Quantum opacity)
4924 return(TransparentPaintImage(image,target,opacity,MagickFalse));
4928 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4932 + P a r s e I m a g e G e o m e t r y %
4936 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4938 % ParseImageGeometry() is similar to GetGeometry() except the returned
4939 % geometry is modified as determined by the meta characters: %, !, <,
4942 % Deprecated, replace with:
4944 % ParseMetaGeometry(geometry,x,y,width,height);
4946 % The format of the ParseImageGeometry method is:
4948 % int ParseImageGeometry(char *geometry,ssize_t *x,ssize_t *y,
4949 % size_t *width,size_t *height)
4951 % A description of each parameter follows:
4953 % o flags: Method ParseImageGeometry returns a bitmask that indicates
4954 % which of the four values were located in the geometry string.
4956 % o image_geometry: Specifies a character string representing the geometry
4959 % o x,y: A pointer to an integer. The x and y offset as determined by
4960 % the geometry specification is returned here.
4962 % o width,height: A pointer to an unsigned integer. The width and height
4963 % as determined by the geometry specification is returned here.
4966 MagickExport int ParseImageGeometry(const char *geometry,ssize_t *x,ssize_t *y,
4967 size_t *width,size_t *height)
4969 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
4970 return((int) ParseMetaGeometry(geometry,x,y,width,height));
4974 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4978 % P a r s e S i z e G e o m e t r y %
4982 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4984 % ParseSizeGeometry() returns a region as defined by the geometry string with
4985 % respect to the image dimensions and aspect ratio.
4987 % Deprecated, replace with:
4989 % ParseMetaGeometry(geometry,®ion_info->x,®ion_info->y,
4990 % ®ion_info->width,®ion_info->height);
4992 % The format of the ParseSizeGeometry method is:
4994 % MagickStatusType ParseSizeGeometry(const Image *image,
4995 % const char *geometry,RectangeInfo *region_info)
4997 % A description of each parameter follows:
4999 % o geometry: The geometry (e.g. 100x100+10+10).
5001 % o region_info: the region as defined by the geometry string.
5004 MagickExport MagickStatusType ParseSizeGeometry(const Image *image,
5005 const char *geometry,RectangleInfo *region_info)
5010 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.4.7");
5011 SetGeometry(image,region_info);
5012 flags=ParseMetaGeometry(geometry,®ion_info->x,®ion_info->y,
5013 ®ion_info->width,®ion_info->height);
5018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5022 % P o p I m a g e L i s t %
5026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5028 % PopImageList() removes the last image in the list.
5030 % Deprecated, replace with:
5032 % RemoveLastImageFromList(images);
5034 % The format of the PopImageList method is:
5036 % Image *PopImageList(Image **images)
5038 % A description of each parameter follows:
5040 % o images: the image list.
5043 MagickExport Image *PopImageList(Image **images)
5045 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5046 return(RemoveLastImageFromList(images));
5050 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5054 % P o p I m a g e P i x e l s %
5058 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5060 % PopImagePixels() transfers one or more pixel components from the image pixel
5061 % cache to a user supplied buffer. The pixels are returned in network byte
5062 % order. MagickTrue is returned if the pixels are successfully transferred,
5063 % otherwise MagickFalse.
5065 % The format of the PopImagePixels method is:
5067 % size_t PopImagePixels(Image *,const QuantumType quantum,
5068 % unsigned char *destination)
5070 % A description of each parameter follows:
5072 % o image: the image.
5074 % o quantum: Declare which pixel components to transfer (RGB, RGBA, etc).
5076 % o destination: The components are transferred to this buffer.
5079 MagickExport size_t PopImagePixels(Image *image,const QuantumType quantum,
5080 unsigned char *destination)
5088 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
5089 if (quantum_info == (QuantumInfo *) NULL)
5091 length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
5092 quantum,destination,&image->exception);
5093 quantum_info=DestroyQuantumInfo(quantum_info);
5098 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5102 % P o s t s c r i p t G e o m e t r y %
5106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5108 % PostscriptGeometry() replaces any page mneumonic with the equivalent size in
5111 % Deprecated, replace with:
5113 % GetPageGeometry(page);
5115 % The format of the PostscriptGeometry method is:
5117 % char *PostscriptGeometry(const char *page)
5119 % A description of each parameter follows.
5121 % o page: Specifies a pointer to an array of characters.
5122 % The string is either a Postscript page name (e.g. A4) or a postscript
5123 % page geometry (e.g. 612x792+36+36).
5126 MagickExport char *PostscriptGeometry(const char *page)
5128 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
5129 return(GetPageGeometry(page));
5133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5137 % P u s h I m a g e L i s t %
5141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5143 % PushImageList() adds an image to the end of the list.
5145 % Deprecated, replace with:
5147 % AppendImageToList(images,CloneImageList(image,exception));
5149 % The format of the PushImageList method is:
5151 % unsigned int PushImageList(Image *images,const Image *image,
5152 % ExceptionInfo *exception)
5154 % A description of each parameter follows:
5156 % o images: the image list.
5158 % o image: the image.
5160 % o exception: return any errors or warnings in this structure.
5163 MagickExport unsigned int PushImageList(Image **images,const Image *image,
5164 ExceptionInfo *exception)
5166 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5167 AppendImageToList(images,CloneImageList(image,exception));
5172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5176 % P u s h I m a g e P i x e l s %
5180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5182 % PushImagePixels() transfers one or more pixel components from a user
5183 % supplied buffer into the image pixel cache of an image. The pixels are
5184 % expected in network byte order. It returns MagickTrue if the pixels are
5185 % successfully transferred, otherwise MagickFalse.
5187 % The format of the PushImagePixels method is:
5189 % size_t PushImagePixels(Image *image,const QuantumType quantum,
5190 % const unsigned char *source)
5192 % A description of each parameter follows:
5194 % o image: the image.
5196 % o quantum: Declare which pixel components to transfer (red, green, blue,
5197 % opacity, RGB, or RGBA).
5199 % o source: The pixel components are transferred from this buffer.
5202 MagickExport size_t PushImagePixels(Image *image,const QuantumType quantum,
5203 const unsigned char *source)
5211 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
5212 if (quantum_info == (QuantumInfo *) NULL)
5214 length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,quantum,
5215 source,&image->exception);
5216 quantum_info=DestroyQuantumInfo(quantum_info);
5221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5225 % Q u a n t i z a t i o n E r r o r %
5229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5231 % QuantizationError() measures the difference between the original and
5232 % quantized images. This difference is the total quantization error. The
5233 % error is computed by summing over all pixels in an image the distance
5234 % squared in RGB space between each reference pixel value and its quantized
5235 % value. These values are computed:
5237 % o mean_error_per_pixel: This value is the mean error for any single
5238 % pixel in the image.
5240 % o normalized_mean_square_error: This value is the normalized mean
5241 % quantization error for any single pixel in the image. This distance
5242 % measure is normalized to a range between 0 and 1. It is independent
5243 % of the range of red, green, and blue values in the image.
5245 % o normalized_maximum_square_error: Thsi value is the normalized
5246 % maximum quantization error for any single pixel in the image. This
5247 % distance measure is normalized to a range between 0 and 1. It is
5248 % independent of the range of red, green, and blue values in your image.
5250 % Deprecated, replace with:
5252 % GetImageQuantizeError(image);
5254 % The format of the QuantizationError method is:
5256 % unsigned int QuantizationError(Image *image)
5258 % A description of each parameter follows.
5260 % o image: Specifies a pointer to an Image structure; returned from
5264 MagickExport unsigned int QuantizationError(Image *image)
5266 if (image->debug != MagickFalse)
5267 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.3");
5268 return(GetImageQuantizeError(image));
5272 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5275 % 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 %
5279 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5281 % RandomChannelThresholdImage() changes the value of individual pixels based
5282 % on the intensity of each pixel compared to a random threshold. The result
5283 % is a low-contrast, two color image.
5285 % The format of the RandomChannelThresholdImage method is:
5287 % unsigned int RandomChannelThresholdImage(Image *image,
5288 % const char *channel, const char *thresholds,
5289 % ExceptionInfo *exception)
5291 % A description of each parameter follows:
5293 % o image: the image.
5295 % o channel: the channel or channels to be thresholded.
5297 % o thresholds: a geometry string containing LOWxHIGH thresholds.
5298 % If the string contains 2x2, 3x3, or 4x4, then an ordered
5299 % dither of order 2, 3, or 4 will be performed instead.
5301 % o exception: return any errors or warnings in this structure.
5304 MagickExport unsigned int RandomChannelThresholdImage(Image *image,const char
5305 *channel,const char *thresholds,ExceptionInfo *exception)
5307 #define RandomChannelThresholdImageText " RandomChannelThreshold image... "
5320 static MagickRealType
5321 o2[4]={0.2f, 0.6f, 0.8f, 0.4f},
5322 o3[9]={0.1f, 0.6f, 0.3f, 0.7f, 0.5f, 0.8f, 0.4f, 0.9f, 0.2f},
5323 o4[16]={0.1f, 0.7f, 1.1f, 0.3f, 1.0f, 0.5f, 1.5f, 0.8f, 1.4f, 1.6f, 0.6f,
5324 1.2f, 0.4f, 0.9f, 1.3f, 0.2f},
5333 assert(image != (Image *) NULL);
5334 assert(image->signature == MagickSignature);
5335 if (image->debug != MagickFalse)
5336 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
5337 assert(exception != (ExceptionInfo *) NULL);
5338 assert(exception->signature == MagickSignature);
5339 if (image->debug != MagickFalse)
5340 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5341 if (thresholds == (const char *) NULL)
5343 if (LocaleCompare(thresholds,"2x2") == 0)
5346 if (LocaleCompare(thresholds,"3x3") == 0)
5349 if (LocaleCompare(thresholds,"4x4") == 0)
5356 count=(ssize_t) sscanf(thresholds,"%lf[/x%%]%lf",&lower_threshold,
5358 if (strchr(thresholds,'%') != (char *) NULL)
5360 upper_threshold*=(.01*QuantumRange);
5361 lower_threshold*=(.01*QuantumRange);
5364 upper_threshold=(MagickRealType) QuantumRange-lower_threshold;
5366 if (image->debug != MagickFalse)
5367 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
5368 " RandomChannelThresholdImage: channel type=%s",channel);
5369 if (image->debug != MagickFalse)
5370 (void) LogMagickEvent(TransformEvent,GetMagickModule(),
5371 " Thresholds: %s (%fx%f)",thresholds,lower_threshold,upper_threshold);
5372 if (LocaleCompare(channel,"all") == 0 ||
5373 LocaleCompare(channel,"intensity") == 0)
5374 if (AcquireImageColormap(image,2) == MagickFalse)
5375 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
5377 random_info=AcquireRandomInfo();
5378 for (y=0; y < (ssize_t) image->rows; y++)
5383 register IndexPacket
5387 register PixelPacket
5390 q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
5391 if (q == (PixelPacket *) NULL)
5393 if (LocaleCompare(channel,"all") == 0 ||
5394 LocaleCompare(channel,"intensity") == 0)
5396 indexes=GetAuthenticIndexQueue(image);
5397 for (x=0; x < (ssize_t) image->columns; x++)
5402 intensity=(MagickRealType) PixelIntensityToQuantum(q);
5405 if (intensity < lower_threshold)
5406 threshold=lower_threshold;
5407 else if (intensity > upper_threshold)
5408 threshold=upper_threshold;
5410 threshold=(MagickRealType) (QuantumRange*
5411 GetPseudoRandomValue(random_info));
5413 else if (order == 2)
5414 threshold=(MagickRealType) QuantumRange*o2[(x%2)+2*(y%2)];
5415 else if (order == 3)
5416 threshold=(MagickRealType) QuantumRange*o3[(x%3)+3*(y%3)];
5417 else if (order == 4)
5418 threshold=(MagickRealType) QuantumRange*o4[(x%4)+4*(y%4)];
5419 q->red=q->green=q->blue=(Quantum) (intensity <=
5420 threshold ? 0 : QuantumRange);
5421 index=(IndexPacket) (intensity <= threshold ? 0 : 1);
5423 q->red=q->green=q->blue=image->colormap[(ssize_t) index].red;
5427 if (LocaleCompare(channel,"opacity") == 0 ||
5428 LocaleCompare(channel,"all") == 0 ||
5429 LocaleCompare(channel,"matte") == 0)
5431 if (image->matte != MagickFalse)
5432 for (x=0; x < (ssize_t) image->columns; x++)
5436 if ((MagickRealType) q->opacity < lower_threshold)
5437 threshold=lower_threshold;
5438 else if ((MagickRealType) q->opacity > upper_threshold)
5439 threshold=upper_threshold;
5441 threshold=(MagickRealType) (QuantumRange*
5442 GetPseudoRandomValue(random_info));
5444 else if (order == 2)
5445 threshold=(MagickRealType) QuantumRange*o2[(x%2)+2*(y%2)];
5446 else if (order == 3)
5447 threshold=(MagickRealType) QuantumRange*o3[(x%3)+3*(y%3)];
5448 else if (order == 4)
5449 threshold=(MagickRealType) QuantumRange*o4[(x%4)+4*(y%4)]/1.7;
5450 q->opacity=(Quantum) ((MagickRealType) q->opacity <= threshold ?
5457 /* To Do: red, green, blue, cyan, magenta, yellow, black */
5458 if (LocaleCompare(channel,"intensity") != 0)
5459 ThrowBinaryException(OptionError,"UnrecognizedChannelType",
5462 if (SyncAuthenticPixels(image,exception) == MagickFalse)
5465 random_info=DestroyRandomInfo(random_info);
5470 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5474 % R e a c q u i r e M e m o r y %
5478 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5480 % ReacquireMemory() changes the size of the memory and returns a pointer to
5481 % the (possibly moved) block. The contents will be unchanged up to the
5482 % lesser of the new and old sizes.
5484 % The format of the ReacquireMemory method is:
5486 % void ReacquireMemory(void **memory,const size_t size)
5488 % A description of each parameter follows:
5490 % o memory: A pointer to a memory allocation. On return the pointer
5491 % may change but the contents of the original allocation will not.
5493 % o size: the new size of the allocated memory.
5496 MagickExport void ReacquireMemory(void **memory,const size_t size)
5501 assert(memory != (void **) NULL);
5502 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
5503 if (*memory == (void *) NULL)
5505 *memory=AcquireMagickMemory(size);
5508 allocation=realloc(*memory,size);
5509 if (allocation == (void *) NULL)
5510 *memory=RelinquishMagickMemory(*memory);
5515 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5519 % R e c o l o r I m a g e %
5523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5525 % RecolorImage() apply color transformation to an image. The method permits
5526 % saturation changes, hue rotation, luminance to alpha, and various other
5527 % effects. Although variable-sized transformation matrices can be used,
5528 % typically one uses a 5x5 matrix for an RGBA image and a 6x6 for CMYKA
5529 % (or RGBA with offsets). The matrix is similar to those used by Adobe Flash
5530 % except offsets are in column 6 rather than 5 (in support of CMYKA images)
5531 % and offsets are normalized (divide Flash offset by 255).
5533 % The format of the RecolorImage method is:
5535 % Image *RecolorImage(const Image *image,const size_t order,
5536 % const double *color_matrix,ExceptionInfo *exception)
5538 % A description of each parameter follows:
5540 % o image: the image.
5542 % o order: the number of columns and rows in the recolor matrix.
5544 % o color_matrix: An array of double representing the recolor matrix.
5546 % o exception: return any errors or warnings in this structure.
5549 MagickExport Image *RecolorImage(const Image *image,const size_t order,
5550 const double *color_matrix,ExceptionInfo *exception)
5558 kernel_info=AcquireKernelInfo("1");
5559 if (kernel_info == (KernelInfo *) NULL)
5560 return((Image *) NULL);
5561 kernel_info->width=order;
5562 kernel_info->height=order;
5563 kernel_info->values=(double *) color_matrix;
5564 recolor_image=ColorMatrixImage(image,kernel_info,exception);
5565 kernel_info->values=(double *) NULL;
5566 kernel_info=DestroyKernelInfo(kernel_info);
5567 return(recolor_image);
5571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5575 % 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 %
5579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5581 % ResetImageAttributeIterator() resets the image attributes iterator. Use it
5582 % in conjunction with GetNextImageAttribute() to iterate over all the values
5583 % associated with an image.
5585 % Deprecated, replace with:
5587 % ResetImagePropertyIterator(image);
5589 % The format of the ResetImageAttributeIterator method is:
5591 % ResetImageAttributeIterator(const ImageInfo *image)
5593 % A description of each parameter follows:
5595 % o image: the image.
5598 MagickExport void ResetImageAttributeIterator(const Image *image)
5600 ResetImagePropertyIterator(image);
5604 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5608 % S e t C a c h e V i e w P i x e l s %
5612 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5614 % SetCacheViewPixels() gets pixels from the in-memory or disk pixel cache as
5615 % defined by the geometry parameters. A pointer to the pixels is returned
5616 % if the pixels are transferred, otherwise a NULL is returned.
5618 % Deprecated, replace with:
5620 % QueueCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
5621 % GetCacheViewException(cache_view));
5623 % The format of the SetCacheViewPixels method is:
5625 % PixelPacket *SetCacheViewPixels(CacheView *cache_view,const ssize_t x,
5626 % const ssize_t y,const size_t columns,const size_t rows)
5628 % A description of each parameter follows:
5630 % o cache_view: the cache view.
5632 % o x,y,columns,rows: These values define the perimeter of a region of
5636 MagickExport PixelPacket *SetCacheViewPixels(CacheView *cache_view,const ssize_t x,
5637 const ssize_t y,const size_t columns,const size_t rows)
5642 pixels=QueueCacheViewAuthenticPixels(cache_view,x,y,columns,rows,
5643 GetCacheViewException(cache_view));
5648 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5652 + S e t C a c h e T h e s h o l d %
5656 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5658 % SetCacheThreshold() sets the amount of free memory allocated for the pixel
5659 % cache. Once this threshold is exceeded, all subsequent pixels cache
5660 % operations are to/from disk.
5662 % The format of the SetCacheThreshold() method is:
5664 % void SetCacheThreshold(const size_t threshold)
5666 % A description of each parameter follows:
5668 % o threshold: the number of megabytes of memory available to the pixel
5672 MagickExport void SetCacheThreshold(const size_t size)
5674 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.1");
5675 (void) SetMagickResourceLimit(MemoryResource,size*1024*1024);
5676 (void) SetMagickResourceLimit(MapResource,2*size*1024*1024);
5680 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5684 % S e t E x c e p t i o n I n f o %
5688 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5690 % SetExceptionInfo() sets the exception severity.
5692 % The format of the SetExceptionInfo method is:
5694 % MagickBooleanType SetExceptionInfo(ExceptionInfo *exception,
5695 % ExceptionType severity)
5697 % A description of each parameter follows:
5699 % o exception: the exception info.
5701 % o severity: the exception severity.
5704 MagickExport MagickBooleanType SetExceptionInfo(ExceptionInfo *exception,
5705 ExceptionType severity)
5707 assert(exception != (ExceptionInfo *) NULL);
5708 ClearMagickException(exception);
5709 exception->severity=severity;
5714 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5724 % SetImage() sets the red, green, and blue components of each pixel to
5725 % the image background color and the opacity component to the specified
5726 % level of transparency. The background color is defined by the
5727 % background_color member of the image.
5729 % The format of the SetImage method is:
5731 % void SetImage(Image *image,const Quantum opacity)
5733 % A description of each parameter follows:
5735 % o image: the image.
5737 % o opacity: Set each pixel to this level of transparency.
5740 MagickExport void SetImage(Image *image,const Quantum opacity)
5748 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.0");
5749 assert(image != (Image *) NULL);
5750 if (image->debug != MagickFalse)
5751 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
5752 assert(image->signature == MagickSignature);
5753 background_color=image->background_color;
5754 if (opacity != OpaqueOpacity)
5755 background_color.opacity=opacity;
5756 if (background_color.opacity != OpaqueOpacity)
5758 (void) SetImageStorageClass(image,DirectClass);
5759 image->matte=MagickTrue;
5761 if ((image->storage_class == PseudoClass) ||
5762 (image->colorspace == CMYKColorspace))
5765 Set colormapped or CMYK image.
5767 for (y=0; y < (ssize_t) image->rows; y++)
5769 register IndexPacket
5775 register PixelPacket
5778 q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
5779 if (q == (PixelPacket *) NULL)
5781 for (x=0; x < (ssize_t) image->columns; x++)
5782 *q++=background_color;
5783 indexes=GetAuthenticIndexQueue(image);
5784 for (x=0; x < (ssize_t) image->columns; x++)
5785 indexes[x]=(IndexPacket) 0;
5786 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
5792 Set DirectClass image.
5794 for (y=0; y < (ssize_t) image->rows; y++)
5799 register PixelPacket
5802 q=QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
5803 if (q == (PixelPacket *) NULL)
5805 for (x=0; x < (ssize_t) image->columns; x++)
5806 *q++=background_color;
5807 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
5813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5817 % S e t I m a g e A t t r i b u t e %
5821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5823 % SetImageAttribute() searches the list of image attributes and replaces the
5824 % attribute value. If it is not found in the list, the attribute name
5825 % and value is added to the list.
5827 % Deprecated, replace with:
5829 % SetImageProperty(image,key,value);
5831 % The format of the SetImageAttribute method is:
5833 % MagickBooleanType SetImageAttribute(Image *image,const char *key,
5834 % const char *value)
5836 % A description of each parameter follows:
5838 % o image: the image.
5842 % o value: the value.
5845 MagickExport MagickBooleanType SetImageAttribute(Image *image,const char *key,
5848 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.3.1");
5849 return(SetImageProperty(image,key,value));
5853 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5857 % S e t I m a g e L i s t %
5861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5863 % SetImageList() inserts an image into the list at the specified position.
5865 % The format of the SetImageList method is:
5867 % unsigned int SetImageList(Image *images,const Image *image,
5868 % const ssize_t offset,ExceptionInfo *exception)
5870 % A description of each parameter follows:
5872 % o images: the image list.
5874 % o image: the image.
5876 % o offset: the position within the list.
5878 % o exception: return any errors or warnings in this structure.
5881 MagickExport unsigned int SetImageList(Image **images,const Image *image,
5882 const ssize_t offset,ExceptionInfo *exception)
5890 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
5891 clone=CloneImageList(image,exception);
5892 while (GetPreviousImageInList(*images) != (Image *) NULL)
5893 (*images)=GetPreviousImageInList(*images);
5894 for (i=0; i < offset; i++)
5896 if (GetNextImageInList(*images) == (Image *) NULL)
5897 return(MagickFalse);
5898 (*images)=GetNextImageInList(*images);
5900 InsertImageInList(images,clone);
5905 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5909 % S e t I m a g e P i x e l s %
5913 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5915 % SetImagePixels() queues a mutable pixel region.
5916 % If the region is successfully intialized a pointer to a PixelPacket
5917 % array representing the region is returned, otherwise NULL is returned.
5918 % The returned pointer may point to a temporary working buffer for the
5919 % pixels or it may point to the final location of the pixels in memory.
5921 % Write-only access means that any existing pixel values corresponding to
5922 % the region are ignored. This useful while the initial image is being
5923 % created from scratch, or if the existing pixel values are to be
5924 % completely replaced without need to refer to their pre-existing values.
5925 % The application is free to read and write the pixel buffer returned by
5926 % SetImagePixels() any way it pleases. SetImagePixels() does not initialize
5927 % the pixel array values. Initializing pixel array values is the
5928 % application's responsibility.
5930 % Performance is maximized if the selected region is part of one row, or
5931 % one or more full rows, since then there is opportunity to access the
5932 % pixels in-place (without a copy) if the image is in RAM, or in a
5933 % memory-mapped file. The returned pointer should *never* be deallocated
5936 % Pixels accessed via the returned pointer represent a simple array of type
5937 % PixelPacket. If the image type is CMYK or the storage class is PseudoClass,
5938 % call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to obtain
5939 % the black color component or the colormap indexes (of type IndexPacket)
5940 % corresponding to the region. Once the PixelPacket (and/or IndexPacket)
5941 % array has been updated, the changes must be saved back to the underlying
5942 % image using SyncAuthenticPixels() or they may be lost.
5944 % Deprecated, replace with:
5946 % QueueAuthenticPixels(image,x,y,columns,rows,&image->exception);
5948 % The format of the SetImagePixels() method is:
5950 % PixelPacket *SetImagePixels(Image *image,const ssize_t x,const ssize_t y,
5951 % const size_t columns,const size_t rows)
5953 % A description of each parameter follows:
5955 % o pixels: SetImagePixels returns a pointer to the pixels if they are
5956 % transferred, otherwise a NULL is returned.
5958 % o image: the image.
5960 % o x,y,columns,rows: These values define the perimeter of a region of
5964 MagickExport PixelPacket *SetImagePixels(Image *image,const ssize_t x,const ssize_t y,
5965 const size_t columns,const size_t rows)
5967 return(QueueAuthenticPixels(image,x,y,columns,rows,&image->exception));
5971 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5975 % S e t M a g i c k R e g i s t r y %
5979 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5981 % SetMagickRegistry() sets a blob into the registry and returns a unique ID.
5982 % If an error occurs, -1 is returned.
5984 % The format of the SetMagickRegistry method is:
5986 % ssize_t SetMagickRegistry(const RegistryType type,const void *blob,
5987 % const size_t length,ExceptionInfo *exception)
5989 % A description of each parameter follows:
5991 % o type: the registry type.
5993 % o blob: the address of a Binary Large OBject.
5995 % o length: For a registry type of ImageRegistryType use sizeof(Image)
5996 % otherise the blob length in number of bytes.
5998 % o exception: return any errors or warnings in this structure.
6001 MagickExport ssize_t SetMagickRegistry(const RegistryType type,const void *blob,
6002 const size_t magick_unused(length),ExceptionInfo *exception)
6013 (void) FormatMagickString(key,MaxTextExtent,"%.20g\n",(double) id);
6014 status=SetImageRegistry(type,key,blob,exception);
6015 if (status == MagickFalse)
6021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6025 % S e t M o n i t o r H a n d l e r %
6029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6031 % SetMonitorHandler() sets the monitor handler to the specified method
6032 % and returns the previous monitor handler.
6034 % The format of the SetMonitorHandler method is:
6036 % MonitorHandler SetMonitorHandler(MonitorHandler handler)
6038 % A description of each parameter follows:
6040 % o handler: Specifies a pointer to a method to handle monitors.
6044 MagickExport MonitorHandler GetMonitorHandler(void)
6046 return(monitor_handler);
6049 MagickExport MonitorHandler SetMonitorHandler(MonitorHandler handler)
6054 previous_handler=monitor_handler;
6055 monitor_handler=handler;
6056 return(previous_handler);
6060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6064 % S h i f t I m a g e L i s t %
6068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6070 % ShiftImageList() removes an image from the beginning of the list.
6072 % Deprecated, replace with:
6074 % RemoveFirstImageFromList(images);
6076 % The format of the ShiftImageList method is:
6078 % Image *ShiftImageList(Image **images)
6080 % A description of each parameter follows:
6082 % o images: the image list.
6085 MagickExport Image *ShiftImageList(Image **images)
6087 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
6088 return(RemoveFirstImageFromList(images));
6092 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6102 % SizeBlob() returns the current length of the image file or blob.
6104 % Deprecated, replace with:
6106 % GetBlobSize(image);
6108 % The format of the SizeBlob method is:
6110 % off_t SizeBlob(Image *image)
6112 % A description of each parameter follows:
6114 % o size: Method SizeBlob returns the current length of the image file
6117 % o image: the image.
6120 MagickExport MagickOffsetType SizeBlob(Image *image)
6122 if (image->debug != MagickFalse)
6123 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.3");
6124 return((MagickOffsetType) GetBlobSize(image));
6128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6132 % S p l i c e I m a g e L i s t %
6136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6138 % SpliceImageList() removes the images designated by offset and length from
6139 % the list and replaces them with the specified list.
6141 % The format of the SpliceImageList method is:
6143 % Image *SpliceImageList(Image *images,const ssize_t offset,
6144 % const size_t length,const Image *splices,
6145 % ExceptionInfo *exception)
6147 % A description of each parameter follows:
6149 % o images: the image list.
6151 % o offset: the position within the list.
6153 % o length: the length of the image list to remove.
6155 % o splice: Replace the removed image list with this list.
6157 % o exception: return any errors or warnings in this structure.
6160 MagickExport Image *SpliceImageList(Image *images,const ssize_t offset,
6161 const size_t length,const Image *splices,ExceptionInfo *exception)
6169 if (images->debug != MagickFalse)
6170 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
6171 clone=CloneImageList(splices,exception);
6172 while (GetPreviousImageInList(images) != (Image *) NULL)
6173 images=GetPreviousImageInList(images);
6174 for (i=0; i < offset; i++)
6176 if (GetNextImageInList(images) == (Image *) NULL)
6177 return((Image *) NULL);
6178 images=GetNextImageInList(images);
6180 (void) SpliceImageIntoList(&images,length,clone);
6185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6195 % Strip() strips any whitespace or quotes from the beginning and end of a
6196 % string of characters.
6198 % The format of the Strip method is:
6200 % void Strip(char *message)
6202 % A description of each parameter follows:
6204 % o message: Specifies an array of characters.
6207 MagickExport void Strip(char *message)
6213 assert(message != (char *) NULL);
6214 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
6215 if (*message == '\0')
6217 if (strlen(message) == 1)
6220 while (isspace((int) ((unsigned char) *p)) != 0)
6222 if ((*p == '\'') || (*p == '"'))
6224 q=message+strlen(message)-1;
6225 while ((isspace((int) ((unsigned char) *q)) != 0) && (q > p))
6228 if ((*q == '\'') || (*q == '"'))
6230 (void) CopyMagickMemory(message,p,(size_t) (q-p+1));
6231 message[q-p+1]='\0';
6235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6239 % S y n c C a c h e V i e w %
6243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6245 % SyncCacheView() saves the cache view pixels to the in-memory or disk
6246 % cache. It returns MagickTrue if the pixel region is synced, otherwise
6249 % Deprecated, replace with:
6251 % SyncCacheViewAuthenticPixels(cache_view,GetCacheViewException(cache_view));
6253 % The format of the SyncCacheView method is:
6255 % MagickBooleanType SyncCacheView(CacheView *cache_view)
6257 % A description of each parameter follows:
6259 % o cache_view: the cache view.
6262 MagickExport MagickBooleanType SyncCacheView(CacheView *cache_view)
6267 status=SyncCacheViewAuthenticPixels(cache_view,
6268 GetCacheViewException(cache_view));
6273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6277 % S y n c C a c h e V i e w P i x e l s %
6281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6283 % SyncCacheViewPixels() saves the cache view pixels to the in-memory
6284 % or disk cache. It returns MagickTrue if the pixel region is flushed,
6285 % otherwise MagickFalse.
6287 % Deprecated, replace with:
6289 % SyncCacheViewAuthenticPixels(cache_view,GetCacheViewException(cache_view));
6291 % The format of the SyncCacheViewPixels method is:
6293 % MagickBooleanType SyncCacheViewPixels(CacheView *cache_view)
6295 % A description of each parameter follows:
6297 % o cache_view: the cache view.
6299 % o exception: return any errors or warnings in this structure.
6302 MagickExport MagickBooleanType SyncCacheViewPixels(CacheView *cache_view)
6307 status=SyncCacheViewAuthenticPixels(cache_view,
6308 GetCacheViewException(cache_view));
6313 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6317 % S y n c I m a g e P i x e l s %
6321 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6323 % SyncImagePixels() saves the image pixels to the in-memory or disk cache.
6324 % The method returns MagickTrue if the pixel region is synced, otherwise
6327 % Deprecated, replace with:
6329 % SyncAuthenticPixels(image,&image->exception);
6331 % The format of the SyncImagePixels() method is:
6333 % MagickBooleanType SyncImagePixels(Image *image)
6335 % A description of each parameter follows:
6337 % o image: the image.
6340 MagickExport MagickBooleanType SyncImagePixels(Image *image)
6342 return(SyncAuthenticPixels(image,&image->exception));
6346 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6350 % T e m p o r a r y F i l e n a m e %
6354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6356 % TemporaryFilename() replaces the contents of path by a unique path name.
6358 % The format of the TemporaryFilename method is:
6360 % void TemporaryFilename(char *path)
6362 % A description of each parameter follows.
6364 % o path: Specifies a pointer to an array of characters. The unique path
6365 % name is returned in this array.
6368 MagickExport void TemporaryFilename(char *path)
6370 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
6371 (void) AcquireUniqueFilename(path);
6372 (void) RelinquishUniqueFileResource(path);
6376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6380 % T h r e s h o l d I m a g e %
6384 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6386 % ThresholdImage() changes the value of individual pixels based on
6387 % the intensity of each pixel compared to threshold. The result is a
6388 % high-contrast, two color image.
6390 % The format of the ThresholdImage method is:
6392 % unsigned int ThresholdImage(Image *image,const double threshold)
6394 % A description of each parameter follows:
6396 % o image: the image.
6398 % o threshold: Define the threshold value
6401 MagickExport unsigned int ThresholdImage(Image *image,const double threshold)
6403 #define ThresholdImageTag "Threshold/Image"
6414 assert(image != (Image *) NULL);
6415 assert(image->signature == MagickSignature);
6416 if (image->debug != MagickFalse)
6417 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6418 if (image->debug != MagickFalse)
6419 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
6420 if (!AcquireImageColormap(image,2))
6421 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
6422 "UnableToThresholdImage");
6423 for (y=0; y < (ssize_t) image->rows; y++)
6425 register IndexPacket
6431 register PixelPacket
6434 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6435 if (q == (PixelPacket *) NULL)
6437 indexes=GetAuthenticIndexQueue(image);
6438 for (x=0; x < (ssize_t) image->columns; x++)
6440 index=(IndexPacket) ((MagickRealType)
6441 PixelIntensityToQuantum(q) <= threshold ? 0 : 1);
6443 q->red=image->colormap[(ssize_t) index].red;
6444 q->green=image->colormap[(ssize_t) index].green;
6445 q->blue=image->colormap[(ssize_t) index].blue;
6448 if (!SyncAuthenticPixels(image,&image->exception))
6455 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6459 % T h r e s h o l d I m a g e C h a n n e l %
6463 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6465 % ThresholdImageChannel() changes the value of individual pixels based on
6466 % the intensity of each pixel channel. The result is a high-contrast image.
6468 % The format of the ThresholdImageChannel method is:
6470 % unsigned int ThresholdImageChannel(Image *image,const char *threshold)
6472 % A description of each parameter follows:
6474 % o image: the image.
6476 % o threshold: define the threshold values.
6479 MagickExport unsigned int ThresholdImageChannel(Image *image,
6480 const char *threshold)
6482 #define ThresholdImageTag "Threshold/Image"
6502 assert(image != (Image *) NULL);
6503 assert(image->signature == MagickSignature);
6504 if (image->debug != MagickFalse)
6505 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6506 if (threshold == (const char *) NULL)
6508 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
6509 return(MagickFalse);
6510 flags=ParseGeometry(threshold,&geometry_info);
6511 pixel.red=geometry_info.rho;
6512 if (flags & SigmaValue)
6513 pixel.green=geometry_info.sigma;
6515 pixel.green=pixel.red;
6516 if (flags & XiValue)
6517 pixel.blue=geometry_info.xi;
6519 pixel.blue=pixel.red;
6520 if (flags & PsiValue)
6521 pixel.opacity=geometry_info.psi;
6523 pixel.opacity=(MagickRealType) OpaqueOpacity;
6524 if (flags & PercentValue)
6526 pixel.red*=QuantumRange/100.0f;
6527 pixel.green*=QuantumRange/100.0f;
6528 pixel.blue*=QuantumRange/100.0f;
6529 pixel.opacity*=QuantumRange/100.0f;
6531 if (!(flags & SigmaValue))
6533 if (!AcquireImageColormap(image,2))
6534 ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
6535 "UnableToThresholdImage");
6537 (void) GetImageDynamicThreshold(image,2.0,2.0,&pixel,&image->exception);
6539 for (y=0; y < (ssize_t) image->rows; y++)
6541 register IndexPacket
6547 register PixelPacket
6550 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6551 if (q == (PixelPacket *) NULL)
6553 indexes=GetAuthenticIndexQueue(image);
6554 if (IsMagickGray(&pixel) != MagickFalse)
6555 for (x=0; x < (ssize_t) image->columns; x++)
6557 index=(IndexPacket) ((MagickRealType)
6558 PixelIntensityToQuantum(q) <= pixel.red ? 0 : 1);
6560 q->red=image->colormap[(ssize_t) index].red;
6561 q->green=image->colormap[(ssize_t) index].green;
6562 q->blue=image->colormap[(ssize_t) index].blue;
6566 for (x=0; x < (ssize_t) image->columns; x++)
6568 q->red=(Quantum) ((MagickRealType)
6569 q->red <= pixel.red ? 0 : QuantumRange);
6570 q->green=(Quantum) ((MagickRealType)
6571 q->green <= pixel.green ? 0 : QuantumRange);
6572 q->blue=(Quantum) ((MagickRealType)
6573 q->blue <= pixel.blue ? 0 : QuantumRange);
6574 q->opacity=(Quantum) ((MagickRealType)
6575 q->opacity <= pixel.opacity ? 0 : QuantumRange);
6578 if (!SyncAuthenticPixels(image,&image->exception))
6585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6589 + T r a n s f o r m C o l o r s p a c e %
6593 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6595 % TransformColorspace() converts the image to a specified colorspace.
6596 % If the image is already in the requested colorspace, no work is performed.
6597 % Note that the current colorspace is stored in the image colorspace member.
6598 % The transformation matrices are not necessarily the standard ones: the
6599 % weights are rescaled to normalize the range of the transformed values to
6600 % be [0..QuantumRange].
6602 % Deprecated, replace with:
6604 % TransformImageColorspace(image,colorspace);
6606 % The format of the TransformColorspace method is:
6608 % unsigned int (void) TransformColorspace(Image *image,
6609 % const ColorspaceType colorspace)
6611 % A description of each parameter follows:
6613 % o image: the image to transform
6615 % o colorspace: the desired colorspace.
6618 MagickExport unsigned int TransformColorspace(Image *image,
6619 const ColorspaceType colorspace)
6621 assert(image != (Image *) NULL);
6622 assert(image->signature == MagickSignature);
6623 if (image->debug != MagickFalse)
6624 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.6");
6625 return(TransformImageColorspace(image,colorspace));
6629 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6633 % T r a n s f o r m H S L %
6637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6639 % TransformHSL() converts a (red, green, blue) to a (hue, saturation,
6640 % lightness) triple.
6642 % The format of the TransformHSL method is:
6644 % void TransformHSL(const Quantum red,const Quantum green,
6645 % const Quantum blue,double *hue,double *saturation,double *lightness)
6647 % A description of each parameter follows:
6649 % o red, green, blue: A Quantum value representing the red, green, and
6650 % blue component of a pixel..
6652 % o hue, saturation, lightness: A pointer to a double value representing a
6653 % component of the HSL color space.
6657 static inline double MagickMin(const double x,const double y)
6664 MagickExport void TransformHSL(const Quantum red,const Quantum green,
6665 const Quantum blue,double *hue,double *saturation,double *lightness)
6676 Convert RGB to HSL colorspace.
6678 assert(hue != (double *) NULL);
6679 assert(saturation != (double *) NULL);
6680 assert(lightness != (double *) NULL);
6682 g=QuantumScale*green;
6683 b=QuantumScale*blue;
6684 max=MagickMax(r,MagickMax(g,b));
6685 min=MagickMin(r,MagickMin(g,b));
6688 *lightness=(double) ((min+max)/2.0);
6692 *saturation=(double) (delta/((*lightness < 0.5) ? (min+max) :
6695 *hue=(double) (g == min ? 5.0+(max-b)/delta : 1.0-(max-g)/delta);
6698 *hue=(double) (b == min ? 1.0+(max-r)/delta : 3.0-(max-b)/delta);
6700 *hue=(double) (r == min ? 3.0+(max-g)/delta : 5.0-(max-r)/delta);
6705 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6709 % T r a n s l a t e T e x t %
6713 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6715 % TranslateText() replaces any embedded formatting characters with the
6716 % appropriate image attribute and returns the translated text.
6718 % Deprecated, replace with:
6720 % InterpretImageProperties(image_info,image,embed_text);
6722 % The format of the TranslateText method is:
6724 % char *TranslateText(const ImageInfo *image_info,Image *image,
6725 % const char *embed_text)
6727 % A description of each parameter follows:
6729 % o image_info: the image info.
6731 % o image: the image.
6733 % o embed_text: the address of a character string containing the embedded
6734 % formatting characters.
6737 MagickExport char *TranslateText(const ImageInfo *image_info,Image *image,
6738 const char *embed_text)
6740 assert(image != (Image *) NULL);
6741 assert(image->signature == MagickSignature);
6742 if (image->debug != MagickFalse)
6743 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.2.6");
6744 return(InterpretImageProperties(image_info,image,embed_text));
6748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6752 % T r a n s p a r e n t I m a g e %
6756 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6758 % TransparentImage() changes the opacity value associated with any pixel
6759 % that matches color to the value defined by opacity.
6761 % By default color must match a particular pixel color exactly. However,
6762 % in many cases two colors may differ by a small amount. Fuzz defines
6763 % how much tolerance is acceptable to consider two colors as the same.
6764 % For example, set fuzz to 10 and the color red at intensities of 100 and
6765 % 102 respectively are now interpreted as the same color.
6767 % The format of the TransparentImage method is:
6769 % MagickBooleanType TransparentImage(Image *image,
6770 % const PixelPacket target,const Quantum opacity)
6772 % A description of each parameter follows:
6774 % o image: the image.
6776 % o target: the RGB value of the target color.
6778 % o opacity: the replacement opacity value.
6781 MagickExport MagickBooleanType TransparentImage(Image *image,
6782 const PixelPacket target,const Quantum opacity)
6784 #define TransparentImageTag "Transparent/Image"
6793 Make image color transparent.
6795 assert(image != (Image *) NULL);
6796 assert(image->signature == MagickSignature);
6797 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v6.1.0");
6798 if (image->debug != MagickFalse)
6799 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6800 if (image->matte == MagickFalse)
6801 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
6802 for (y=0; y < (ssize_t) image->rows; y++)
6807 register PixelPacket
6810 q=GetAuthenticPixels(image,0,y,image->columns,1,&image->exception);
6811 if (q == (PixelPacket *) NULL)
6813 for (x=0; x < (ssize_t) image->columns; x++)
6815 if (IsColorSimilar(image,q,&target) != MagickFalse)
6819 if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
6821 proceed=SetImageProgress(image,TransparentImageTag,(MagickOffsetType) y,
6823 if (proceed == MagickFalse)
6830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6834 % U n s h i f t I m a g e L i s t %
6838 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6840 % UnshiftImageList() adds the image to the beginning of the list.
6842 % Deprecated, replace with:
6844 % PrependImageToList(images,CloneImageList(image,exception));
6846 % The format of the UnshiftImageList method is:
6848 % unsigned int UnshiftImageList(Image *images,const Image *image,
6849 % ExceptionInfo *exception)
6851 % A description of each parameter follows:
6853 % o images: the image list.
6855 % o image: the image.
6857 % o exception: return any errors or warnings in this structure.
6860 MagickExport unsigned int UnshiftImageList(Image **images,const Image *image,
6861 ExceptionInfo *exception)
6863 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.2");
6864 PrependImageToList(images,CloneImageList(image,exception));
6869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6873 + V a l i d a t e C o l o r m a p I n d e x %
6877 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6879 % ValidateColormapIndex() validates the colormap index. If the index does
6880 % not range from 0 to the number of colors in the colormap an exception
6881 % issued and 0 is returned.
6883 % Deprecated, replace with:
6885 % ConstrainColormapIndex(image,index);
6887 % The format of the ValidateColormapIndex method is:
6889 % IndexPacket ValidateColormapIndex(Image *image,const unsigned int index)
6891 % A description of each parameter follows:
6893 % o index: Method ValidateColormapIndex returns colormap index if it is
6894 % valid other an exception issued and 0 is returned.
6896 % o image: the image.
6898 % o index: This integer is the colormap index.
6901 MagickExport IndexPacket ValidateColormapIndex(Image *image,
6904 if (image->debug != MagickFalse)
6905 (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.4.4");
6906 return(ConstrainColormapIndex(image,index));
6910 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6914 % Z o o m I m a g e %
6918 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6920 % ZoomImage() creates a new image that is a scaled size of an existing one.
6921 % It allocates the memory necessary for the new Image structure and returns a
6922 % pointer to the new image. The Point filter gives fast pixel replication,
6923 % Triangle is equivalent to bi-linear interpolation, and Mitchel giver slower,
6924 % very high-quality results. See Graphic Gems III for details on this
6927 % The filter member of the Image structure specifies which image filter to
6928 % use. Blur specifies the blur factor where > 1 is blurry, < 1 is sharp.
6930 % The format of the ZoomImage method is:
6932 % Image *ZoomImage(const Image *image,const size_t columns,
6933 % const size_t rows,ExceptionInfo *exception)
6935 % A description of each parameter follows:
6937 % o image: the image.
6939 % o columns: An integer that specifies the number of columns in the zoom
6942 % o rows: An integer that specifies the number of rows in the scaled
6945 % o exception: return any errors or warnings in this structure.
6948 MagickExport Image *ZoomImage(const Image *image,const size_t columns,
6949 const size_t rows,ExceptionInfo *exception)
6954 assert(image != (const Image *) NULL);
6955 assert(image->signature == MagickSignature);
6956 if (image->debug != MagickFalse)
6957 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
6958 assert(exception != (ExceptionInfo *) NULL);
6959 assert(exception->signature == MagickSignature);
6960 zoom_image=ResizeImage(image,columns,rows,image->filter,image->blur,