2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % IIIII M M AAA GGGG EEEEE %
8 % I M M M AAAAA G GG EEE %
10 % IIIII M M A A GGGG EEEEE %
13 % MagickCore Image Methods %
20 % Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "magick/studio.h"
44 #include "magick/animate.h"
45 #include "magick/artifact.h"
46 #include "magick/blob.h"
47 #include "magick/blob-private.h"
48 #include "magick/cache.h"
49 #include "magick/cache-private.h"
50 #include "magick/cache-view.h"
51 #include "magick/client.h"
52 #include "magick/color.h"
53 #include "magick/color-private.h"
54 #include "magick/colormap.h"
55 #include "magick/colorspace.h"
56 #include "magick/colorspace-private.h"
57 #include "magick/composite.h"
58 #include "magick/composite-private.h"
59 #include "magick/compress.h"
60 #include "magick/constitute.h"
61 #include "magick/deprecate.h"
62 #include "magick/display.h"
63 #include "magick/draw.h"
64 #include "magick/enhance.h"
65 #include "magick/exception.h"
66 #include "magick/exception-private.h"
67 #include "magick/gem.h"
68 #include "magick/geometry.h"
69 #include "magick/histogram.h"
70 #include "magick/image-private.h"
71 #include "magick/list.h"
72 #include "magick/magic.h"
73 #include "magick/magick.h"
74 #include "magick/memory_.h"
75 #include "magick/module.h"
76 #include "magick/monitor.h"
77 #include "magick/monitor-private.h"
78 #include "magick/option.h"
79 #include "magick/paint.h"
80 #include "magick/pixel-private.h"
81 #include "magick/profile.h"
82 #include "magick/property.h"
83 #include "magick/quantize.h"
84 #include "magick/random_.h"
85 #include "magick/segment.h"
86 #include "magick/semaphore.h"
87 #include "magick/signature-private.h"
88 #include "magick/statistic.h"
89 #include "magick/string_.h"
90 #include "magick/string-private.h"
91 #include "magick/thread-private.h"
92 #include "magick/threshold.h"
93 #include "magick/timer.h"
94 #include "magick/utility.h"
95 #include "magick/version.h"
96 #include "magick/xwindow-private.h"
102 BackgroundColor[] = "#ffffff", /* white */
103 BorderColor[] = "#dfdfdf", /* gray */
104 DefaultTileFrame[] = "15x15+3+3",
105 DefaultTileGeometry[] = "120x120+4+3>",
106 DefaultTileLabel[] = "%f\n%G\n%b",
107 ForegroundColor[] = "#000", /* black */
108 LoadImageTag[] = "Load/Image",
109 LoadImagesTag[] = "Load/Images",
110 MatteColor[] = "#bdbdbd", /* gray */
111 PSDensityGeometry[] = "72.0x72.0",
112 PSPageGeometry[] = "612x792",
113 SaveImageTag[] = "Save/Image",
114 SaveImagesTag[] = "Save/Images",
115 TransparentColor[] = "#00000000"; /* transparent black */
118 DefaultResolution = 72.0;
121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125 % A c q u i r e I m a g e %
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 % AcquireImage() returns a pointer to an image structure initialized to
134 % The format of the AcquireImage method is:
136 % Image *AcquireImage(const ImageInfo *image_info)
138 % A description of each parameter follows:
140 % o image_info: Many of the image default values are set from this
141 % structure. For example, filename, compression, depth, background color,
145 MagickExport Image *AcquireImage(const ImageInfo *image_info)
157 Allocate image structure.
159 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
160 image=(Image *) AcquireMagickMemory(sizeof(*image));
161 if (image == (Image *) NULL)
162 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
163 (void) ResetMagickMemory(image,0,sizeof(*image));
165 Initialize Image structure.
167 (void) CopyMagickString(image->magick,"MIFF",MaxTextExtent);
168 image->storage_class=DirectClass;
169 image->depth=MAGICKCORE_QUANTUM_DEPTH;
170 image->colorspace=RGBColorspace;
171 image->interlace=NoInterlace;
172 image->ticks_per_second=UndefinedTicksPerSecond;
173 image->compose=OverCompositeOp;
175 GetExceptionInfo(&image->exception);
176 (void) QueryColorDatabase(BackgroundColor,&image->background_color,
178 (void) QueryColorDatabase(BorderColor,&image->border_color,&image->exception);
179 (void) QueryColorDatabase(MatteColor,&image->matte_color,&image->exception);
180 (void) QueryColorDatabase(TransparentColor,&image->transparent_color,
182 image->x_resolution=DefaultResolution;
183 image->y_resolution=DefaultResolution;
184 image->units=PixelsPerInchResolution;
185 GetTimerInfo(&image->timer);
186 image->ping=MagickFalse;
187 image->cache=AcquirePixelCache(0);
188 image->blob=CloneBlobInfo((BlobInfo *) NULL);
189 image->debug=IsEventLogging();
190 image->reference_count=1;
191 image->semaphore=AllocateSemaphoreInfo();
192 image->signature=MagickSignature;
193 if (image_info == (ImageInfo *) NULL)
198 SetBlobExempt(image,image_info->file != (FILE *) NULL ? MagickTrue :
200 (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
201 (void) CopyMagickString(image->magick_filename,image_info->filename,
203 (void) CopyMagickString(image->magick,image_info->magick,MaxTextExtent);
204 if (image_info->size != (char *) NULL)
206 (void) ParseAbsoluteGeometry(image_info->size,&image->extract_info);
207 image->columns=image->extract_info.width;
208 image->rows=image->extract_info.height;
209 image->offset=image->extract_info.x;
210 image->extract_info.x=0;
211 image->extract_info.y=0;
213 if (image_info->extract != (char *) NULL)
218 flags=ParseAbsoluteGeometry(image_info->extract,&geometry);
219 if (((flags & XValue) != 0) || ((flags & YValue) != 0))
221 image->extract_info=geometry;
222 Swap(image->columns,image->extract_info.width);
223 Swap(image->rows,image->extract_info.height);
226 image->compression=image_info->compression;
227 image->quality=image_info->quality;
228 image->endian=image_info->endian;
229 image->interlace=image_info->interlace;
230 image->units=image_info->units;
231 if (image_info->density != (char *) NULL)
236 flags=ParseGeometry(image_info->density,&geometry_info);
237 image->x_resolution=geometry_info.rho;
238 image->y_resolution=geometry_info.sigma;
239 if ((flags & SigmaValue) == 0)
240 image->y_resolution=image->x_resolution;
242 if (image_info->page != (char *) NULL)
247 image->page=image->extract_info;
248 geometry=GetPageGeometry(image_info->page);
249 (void) ParseAbsoluteGeometry(geometry,&image->page);
250 geometry=DestroyString(geometry);
252 if (image_info->depth != 0)
253 image->depth=image_info->depth;
254 image->dither=image_info->dither;
255 image->background_color=image_info->background_color;
256 image->border_color=image_info->border_color;
257 image->matte_color=image_info->matte_color;
258 image->transparent_color=image_info->transparent_color;
259 image->ping=image_info->ping;
260 image->progress_monitor=image_info->progress_monitor;
261 image->client_data=image_info->client_data;
262 if (image_info->cache != (void *) NULL)
263 ClonePixelCacheMethods(image->cache,image_info->cache);
264 (void) SetImageVirtualPixelMethod(image,image_info->virtual_pixel_method);
265 (void) SyncImageSettings(image_info,image);
266 option=GetImageOption(image_info,"delay");
267 if (option != (const char *) NULL)
272 flags=ParseGeometry(option,&geometry_info);
273 if ((flags & GreaterValue) != 0)
275 if (image->delay > (size_t) floor(geometry_info.rho+0.5))
276 image->delay=(size_t) floor(geometry_info.rho+0.5);
279 if ((flags & LessValue) != 0)
281 if (image->delay < (size_t) floor(geometry_info.rho+0.5))
282 image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
285 image->delay=(size_t) floor(geometry_info.rho+0.5);
286 if ((flags & SigmaValue) != 0)
287 image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
289 option=GetImageOption(image_info,"dispose");
290 if (option != (const char *) NULL)
291 image->dispose=(DisposeType) ParseMagickOption(MagickDisposeOptions,
297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301 % A c q u i r e I m a g e I n f o %
305 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
307 % AcquireImageInfo() allocates the ImageInfo structure.
309 % The format of the AcquireImageInfo method is:
311 % ImageInfo *AcquireImageInfo(void)
314 MagickExport ImageInfo *AcquireImageInfo(void)
319 image_info=(ImageInfo *) AcquireMagickMemory(sizeof(*image_info));
320 if (image_info == (ImageInfo *) NULL)
321 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
322 GetImageInfo(image_info);
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331 % A c q u i r e N e x t I m a g e %
335 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
337 % AcquireNextImage() initializes the next image in a sequence to
338 % default values. The next member of image points to the newly allocated
339 % image. If there is a memory shortage, next is assigned NULL.
341 % The format of the AcquireNextImage method is:
343 % void AcquireNextImage(const ImageInfo *image_info,Image *image)
345 % A description of each parameter follows:
347 % o image_info: Many of the image default values are set from this
348 % structure. For example, filename, compression, depth, background color,
351 % o image: the image.
354 MagickExport void AcquireNextImage(const ImageInfo *image_info,Image *image)
357 Allocate image structure.
359 assert(image != (Image *) NULL);
360 assert(image->signature == MagickSignature);
361 if (image->debug != MagickFalse)
362 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
363 image->next=AcquireImage(image_info);
364 if (GetNextImageInList(image) == (Image *) NULL)
366 (void) CopyMagickString(GetNextImageInList(image)->filename,image->filename,
368 if (image_info != (ImageInfo *) NULL)
369 (void) CopyMagickString(GetNextImageInList(image)->filename,
370 image_info->filename,MaxTextExtent);
371 DestroyBlob(GetNextImageInList(image));
372 image->next->blob=ReferenceBlob(image->blob);
373 image->next->endian=image->endian;
374 image->next->scene=image->scene+1;
375 image->next->previous=image;
379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 % A p p e n d I m a g e s %
387 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
389 % AppendImages() takes all images from the current image pointer to the end
390 % of the image list and appends them to each other top-to-bottom if the
391 % stack parameter is true, otherwise left-to-right.
393 % The current gravity setting now effects how the image is justified in the
396 % The format of the AppendImages method is:
398 % Image *AppendImages(const Image *image,const MagickBooleanType stack,
399 % ExceptionInfo *exception)
401 % A description of each parameter follows:
403 % o image: the image sequence.
405 % o stack: A value other than 0 stacks the images top-to-bottom.
407 % o exception: return any errors or warnings in this structure.
410 MagickExport Image *AppendImages(const Image *image,
411 const MagickBooleanType stack,ExceptionInfo *exception)
413 #define AppendImageTag "Append/Image"
447 Ensure the image have the same column width.
449 assert(image != (Image *) NULL);
450 assert(image->signature == MagickSignature);
451 if (image->debug != MagickFalse)
452 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
453 assert(exception != (ExceptionInfo *) NULL);
454 assert(exception->signature == MagickSignature);
457 width=image->columns;
459 next=GetNextImageInList(image);
460 for ( ; next != (Image *) NULL; next=GetNextImageInList(next))
462 if (next->matte != MagickFalse)
465 if (stack != MagickFalse)
467 if (next->columns > width)
472 width+=next->columns;
473 if (next->rows > height)
477 Initialize append next attributes.
479 append_image=CloneImage(image,width,height,MagickTrue,exception);
480 if (append_image == (Image *) NULL)
481 return((Image *) NULL);
482 if (SetImageStorageClass(append_image,DirectClass) == MagickFalse)
484 InheritException(exception,&append_image->exception);
485 append_image=DestroyImage(append_image);
486 return((Image *) NULL);
488 append_image->matte=matte;
489 (void) SetImageBackgroundColor(append_image);
493 append_view=AcquireCacheView(append_image);
494 for (n=0; n < (MagickOffsetType) number_images; n++)
496 SetGeometry(append_image,&geometry);
497 GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
498 if (stack != MagickFalse)
499 x_offset-=geometry.x;
501 y_offset-=geometry.y;
502 image_view=AcquireCacheView(image);
503 #if defined(MAGICKCORE_OPENMP_SUPPORT)
504 #pragma omp parallel for schedule(dynamic,4) shared(status)
506 for (y=0; y < (ssize_t) image->rows; y++)
511 register const IndexPacket
514 register const PixelPacket
518 *restrict append_indexes;
526 if (status == MagickFalse)
528 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
529 q=QueueCacheViewAuthenticPixels(append_view,x_offset,y+y_offset,
530 image->columns,1,exception);
531 if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
536 indexes=GetCacheViewVirtualIndexQueue(image_view);
537 append_indexes=GetCacheViewAuthenticIndexQueue(append_view);
538 for (x=0; x < (ssize_t) image->columns; x++)
540 SetRedPixelComponent(q,GetRedPixelComponent(p));
541 SetGreenPixelComponent(q,GetGreenPixelComponent(p));
542 SetBluePixelComponent(q,GetBluePixelComponent(p));
543 SetOpacityPixelComponent(q,OpaqueOpacity);
544 if (image->matte != MagickFalse)
545 SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
546 if (image->colorspace == CMYKColorspace)
547 append_indexes[x]=indexes[x];
551 sync=SyncCacheViewAuthenticPixels(append_view,exception);
552 if (sync == MagickFalse)
555 image_view=DestroyCacheView(image_view);
556 proceed=SetImageProgress(image,AppendImageTag,n,number_images);
557 if (proceed == MagickFalse)
559 if (stack == MagickFalse)
561 x_offset+=(ssize_t) image->columns;
567 y_offset+=(ssize_t) image->rows;
569 image=GetNextImageInList(image);
571 append_view=DestroyCacheView(append_view);
572 if (status == MagickFalse)
573 append_image=DestroyImage(append_image);
574 return(append_image);
578 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582 % C a t c h I m a g e E x c e p t i o n %
586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
588 % CatchImageException() returns if no exceptions are found in the image
589 % sequence, otherwise it determines the most severe exception and reports
590 % it as a warning or error depending on the severity.
592 % The format of the CatchImageException method is:
594 % ExceptionType CatchImageException(Image *image)
596 % A description of each parameter follows:
598 % o image: An image sequence.
601 MagickExport ExceptionType CatchImageException(Image *image)
609 assert(image != (const Image *) NULL);
610 assert(image->signature == MagickSignature);
611 if (image->debug != MagickFalse)
612 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
613 exception=AcquireExceptionInfo();
614 GetImageException(image,exception);
615 CatchException(exception);
616 severity=exception->severity;
617 exception=DestroyExceptionInfo(exception);
622 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
626 % C l i p I m a g e P a t h %
630 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
632 % ClipImagePath() sets the image clip mask based any clipping path information
635 % The format of the ClipImagePath method is:
637 % MagickBooleanType ClipImagePath(Image *image,const char *pathname,
638 % const MagickBooleanType inside)
640 % A description of each parameter follows:
642 % o image: the image.
644 % o pathname: name of clipping path resource. If name is preceded by #, use
645 % clipping path numbered by name.
647 % o inside: if non-zero, later operations take effect inside clipping path.
648 % Otherwise later operations take effect outside clipping path.
652 MagickExport MagickBooleanType ClipImage(Image *image)
654 return(ClipImagePath(image,"#1",MagickTrue));
657 MagickExport MagickBooleanType ClipImagePath(Image *image,const char *pathname,
658 const MagickBooleanType inside)
660 #define ClipImagePathTag "ClipPath/Image"
674 assert(image != (const Image *) NULL);
675 assert(image->signature == MagickSignature);
676 if (image->debug != MagickFalse)
677 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
678 assert(pathname != NULL);
679 property=AcquireString(pathname);
680 (void) FormatMagickString(property,MaxTextExtent,"8BIM:1999,2998:%s",
682 value=GetImageProperty(image,property);
683 property=DestroyString(property);
684 if (value == (const char *) NULL)
686 ThrowFileException(&image->exception,OptionError,"NoClipPathDefined",
690 image_info=AcquireImageInfo();
691 (void) CopyMagickString(image_info->filename,image->filename,MaxTextExtent);
692 (void) ConcatenateMagickString(image_info->filename,pathname,MaxTextExtent);
693 clip_mask=BlobToImage(image_info,value,strlen(value),&image->exception);
694 image_info=DestroyImageInfo(image_info);
695 if (clip_mask == (Image *) NULL)
697 if (clip_mask->storage_class == PseudoClass)
699 (void) SyncImage(clip_mask);
700 if (SetImageStorageClass(clip_mask,DirectClass) == MagickFalse)
703 if (inside == MagickFalse)
704 (void) NegateImage(clip_mask,MagickFalse);
705 (void) FormatMagickString(clip_mask->magick_filename,MaxTextExtent,
706 "8BIM:1999,2998:%s\nPS",pathname);
707 (void) SetImageClipMask(image,clip_mask);
708 clip_mask=DestroyImage(clip_mask);
713 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
717 % C l o n e I m a g e %
721 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
723 % CloneImage() copies an image and returns the copy as a new image object.
724 % If the specified columns and rows is 0, an exact copy of the image is
725 % returned, otherwise the pixel data is undefined and must be initialized
726 % with the QueueAuthenticPixels() and SyncAuthenticPixels() methods. On
727 % failure, a NULL image is returned and exception describes the reason for the
730 % The format of the CloneImage method is:
732 % Image *CloneImage(const Image *image,const size_t columns,
733 % const size_t rows,const MagickBooleanType orphan,
734 % ExceptionInfo *exception)
736 % A description of each parameter follows:
738 % o image: the image.
740 % o columns: the number of columns in the cloned image.
742 % o rows: the number of rows in the cloned image.
744 % o detach: With a value other than 0, the cloned image is detached from
745 % its parent I/O stream.
747 % o exception: return any errors or warnings in this structure.
750 MagickExport Image *CloneImage(const Image *image,const size_t columns,
751 const size_t rows,const MagickBooleanType detach,
752 ExceptionInfo *exception)
766 assert(image != (const Image *) NULL);
767 assert(image->signature == MagickSignature);
768 if (image->debug != MagickFalse)
769 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
770 assert(exception != (ExceptionInfo *) NULL);
771 assert(exception->signature == MagickSignature);
772 clone_image=(Image *) AcquireMagickMemory(sizeof(*clone_image));
773 if (clone_image == (Image *) NULL)
774 ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
775 (void) ResetMagickMemory(clone_image,0,sizeof(*clone_image));
776 clone_image->signature=MagickSignature;
777 clone_image->storage_class=image->storage_class;
778 clone_image->colorspace=image->colorspace;
779 clone_image->matte=image->matte;
780 clone_image->columns=image->columns;
781 clone_image->rows=image->rows;
782 clone_image->dither=image->dither;
783 if (image->colormap != (PixelPacket *) NULL)
786 Allocate and copy the image colormap.
788 clone_image->colors=image->colors;
789 length=(size_t) image->colors;
790 clone_image->colormap=(PixelPacket *) AcquireQuantumMemory(length,
791 sizeof(*clone_image->colormap));
792 if (clone_image->colormap == (PixelPacket *) NULL)
793 ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
794 (void) CopyMagickMemory(clone_image->colormap,image->colormap,length*
795 sizeof(*clone_image->colormap));
797 (void) CloneImageProfiles(clone_image,image);
798 (void) CloneImageProperties(clone_image,image);
799 (void) CloneImageArtifacts(clone_image,image);
800 GetTimerInfo(&clone_image->timer);
801 GetExceptionInfo(&clone_image->exception);
802 InheritException(&clone_image->exception,&image->exception);
803 if (image->ascii85 != (void *) NULL)
804 Ascii85Initialize(clone_image);
805 clone_image->magick_columns=image->magick_columns;
806 clone_image->magick_rows=image->magick_rows;
807 clone_image->type=image->type;
808 (void) CopyMagickString(clone_image->magick_filename,image->magick_filename,
810 (void) CopyMagickString(clone_image->magick,image->magick,MaxTextExtent);
811 (void) CopyMagickString(clone_image->filename,image->filename,MaxTextExtent);
812 clone_image->progress_monitor=image->progress_monitor;
813 clone_image->client_data=image->client_data;
814 clone_image->reference_count=1;
815 clone_image->next=NewImageList();
816 clone_image->previous=NewImageList();
817 clone_image->list=NewImageList();
818 clone_image->clip_mask=NewImageList();
819 clone_image->mask=NewImageList();
820 if (detach == MagickFalse)
821 clone_image->blob=ReferenceBlob(image->blob);
823 clone_image->blob=CloneBlobInfo((BlobInfo *) NULL);
824 clone_image->ping=image->ping;
825 clone_image->debug=IsEventLogging();
826 clone_image->semaphore=AllocateSemaphoreInfo();
827 if ((columns == 0) && (rows == 0))
829 if (image->montage != (char *) NULL)
830 (void) CloneString(&clone_image->montage,image->montage);
831 if (image->directory != (char *) NULL)
832 (void) CloneString(&clone_image->directory,image->directory);
833 if (image->clip_mask != (Image *) NULL)
834 clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
836 if (image->mask != (Image *) NULL)
837 clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
838 clone_image->cache=ReferencePixelCache(image->cache);
841 scale=(MagickRealType) columns/(MagickRealType) image->columns;
842 clone_image->page.width=(size_t) floor(scale*image->page.width+0.5);
843 clone_image->page.x=(ssize_t) ceil(scale*image->page.x-0.5);
844 clone_image->tile_offset.x=(ssize_t) ceil(scale*image->tile_offset.x-0.5);
845 scale=(MagickRealType) rows/(MagickRealType) image->rows;
846 clone_image->page.height=(size_t) floor(scale*image->page.height+0.5);
847 clone_image->page.y=(ssize_t) ceil(scale*image->page.y-0.5);
848 clone_image->tile_offset.y=(ssize_t) ceil(scale*image->tile_offset.y-0.5);
849 clone_image->columns=columns;
850 clone_image->rows=rows;
851 clone_image->cache=ClonePixelCache(image->cache);
856 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
860 % C l o n e I m a g e I n f o %
864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
866 % CloneImageInfo() makes a copy of the given image info structure. If
867 % NULL is specified, a new image info structure is created initialized to
870 % The format of the CloneImageInfo method is:
872 % ImageInfo *CloneImageInfo(const ImageInfo *image_info)
874 % A description of each parameter follows:
876 % o image_info: the image info.
879 MagickExport ImageInfo *CloneImageInfo(const ImageInfo *image_info)
884 clone_info=AcquireImageInfo();
885 if (image_info == (ImageInfo *) NULL)
887 clone_info->compression=image_info->compression;
888 clone_info->temporary=image_info->temporary;
889 clone_info->adjoin=image_info->adjoin;
890 clone_info->antialias=image_info->antialias;
891 clone_info->scene=image_info->scene;
892 clone_info->number_scenes=image_info->number_scenes;
893 clone_info->depth=image_info->depth;
894 if (image_info->size != (char *) NULL)
895 (void) CloneString(&clone_info->size,image_info->size);
896 if (image_info->extract != (char *) NULL)
897 (void) CloneString(&clone_info->extract,image_info->extract);
898 if (image_info->scenes != (char *) NULL)
899 (void) CloneString(&clone_info->scenes,image_info->scenes);
900 if (image_info->page != (char *) NULL)
901 (void) CloneString(&clone_info->page,image_info->page);
902 clone_info->interlace=image_info->interlace;
903 clone_info->endian=image_info->endian;
904 clone_info->units=image_info->units;
905 clone_info->quality=image_info->quality;
906 if (image_info->sampling_factor != (char *) NULL)
907 (void) CloneString(&clone_info->sampling_factor,
908 image_info->sampling_factor);
909 if (image_info->server_name != (char *) NULL)
910 (void) CloneString(&clone_info->server_name,image_info->server_name);
911 if (image_info->font != (char *) NULL)
912 (void) CloneString(&clone_info->font,image_info->font);
913 if (image_info->texture != (char *) NULL)
914 (void) CloneString(&clone_info->texture,image_info->texture);
915 if (image_info->density != (char *) NULL)
916 (void) CloneString(&clone_info->density,image_info->density);
917 clone_info->pointsize=image_info->pointsize;
918 clone_info->fuzz=image_info->fuzz;
919 clone_info->pen=image_info->pen;
920 clone_info->background_color=image_info->background_color;
921 clone_info->border_color=image_info->border_color;
922 clone_info->matte_color=image_info->matte_color;
923 clone_info->transparent_color=image_info->transparent_color;
924 clone_info->dither=image_info->dither;
925 clone_info->monochrome=image_info->monochrome;
926 clone_info->colors=image_info->colors;
927 clone_info->colorspace=image_info->colorspace;
928 clone_info->type=image_info->type;
929 clone_info->orientation=image_info->orientation;
930 clone_info->preview_type=image_info->preview_type;
931 clone_info->group=image_info->group;
932 clone_info->ping=image_info->ping;
933 clone_info->verbose=image_info->verbose;
934 if (image_info->view != (char *) NULL)
935 (void) CloneString(&clone_info->view,image_info->view);
936 if (image_info->authenticate != (char *) NULL)
937 (void) CloneString(&clone_info->authenticate,image_info->authenticate);
938 (void) CloneImageOptions(clone_info,image_info);
939 clone_info->progress_monitor=image_info->progress_monitor;
940 clone_info->client_data=image_info->client_data;
941 clone_info->cache=image_info->cache;
942 if (image_info->cache != (void *) NULL)
943 clone_info->cache=ReferencePixelCache(image_info->cache);
944 if (image_info->profile != (void *) NULL)
945 clone_info->profile=(void *) CloneStringInfo((StringInfo *)
946 image_info->profile);
947 SetImageInfoFile(clone_info,image_info->file);
948 SetImageInfoBlob(clone_info,image_info->blob,image_info->length);
949 clone_info->stream=image_info->stream;
950 clone_info->virtual_pixel_method=image_info->virtual_pixel_method;
951 (void) CopyMagickString(clone_info->magick,image_info->magick,MaxTextExtent);
952 (void) CopyMagickString(clone_info->unique,image_info->unique,MaxTextExtent);
953 (void) CopyMagickString(clone_info->zero,image_info->zero,MaxTextExtent);
954 (void) CopyMagickString(clone_info->filename,image_info->filename,
956 clone_info->subimage=image_info->scene; /* deprecated */
957 clone_info->subrange=image_info->number_scenes; /* deprecated */
958 clone_info->channel=image_info->channel;
959 clone_info->debug=IsEventLogging();
960 clone_info->signature=image_info->signature;
965 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
969 % C o m b i n e I m a g e s %
973 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
975 % CombineImages() combines one or more images into a single image. The
976 % grayscale value of the pixels of each image in the sequence is assigned in
977 % order to the specified channels of the combined image. The typical
978 % ordering would be image 1 => Red, 2 => Green, 3 => Blue, etc.
980 % The format of the CombineImages method is:
982 % Image *CombineImages(const Image *image,const ChannelType channel,
983 % ExceptionInfo *exception)
985 % A description of each parameter follows:
987 % o image: the image.
989 % o exception: return any errors or warnings in this structure.
992 MagickExport Image *CombineImages(const Image *image,const ChannelType channel,
993 ExceptionInfo *exception)
995 #define CombineImageTag "Combine/Image"
1016 Ensure the image are the same size.
1018 assert(image != (const Image *) NULL);
1019 assert(image->signature == MagickSignature);
1020 if (image->debug != MagickFalse)
1021 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1022 assert(exception != (ExceptionInfo *) NULL);
1023 assert(exception->signature == MagickSignature);
1024 for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
1026 if ((next->columns != image->columns) || (next->rows != image->rows))
1027 ThrowImageException(OptionError,"ImagesAreNotTheSameSize");
1029 combine_image=CloneImage(image,0,0,MagickTrue,exception);
1030 if (combine_image == (Image *) NULL)
1031 return((Image *) NULL);
1032 if (SetImageStorageClass(combine_image,DirectClass) == MagickFalse)
1034 InheritException(exception,&combine_image->exception);
1035 combine_image=DestroyImage(combine_image);
1036 return((Image *) NULL);
1038 if ((channel & OpacityChannel) != 0)
1039 combine_image->matte=MagickTrue;
1040 (void) SetImageBackgroundColor(combine_image);
1046 combine_view=AcquireCacheView(combine_image);
1047 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1048 #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
1050 for (y=0; y < (ssize_t) combine_image->rows; y++)
1061 register const PixelPacket
1064 register PixelPacket
1070 if (status == MagickFalse)
1072 pixels=GetCacheViewAuthenticPixels(combine_view,0,y,combine_image->columns,
1074 if (pixels == (PixelPacket *) NULL)
1080 if (((channel & RedChannel) != 0) && (next != (Image *) NULL))
1082 image_view=AcquireCacheView(next);
1083 p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
1084 if (p == (const PixelPacket *) NULL)
1087 for (x=0; x < (ssize_t) combine_image->columns; x++)
1089 SetRedPixelComponent(q,PixelIntensityToQuantum(p));
1093 image_view=DestroyCacheView(image_view);
1094 next=GetNextImageInList(next);
1096 if (((channel & GreenChannel) != 0) && (next != (Image *) NULL))
1098 image_view=AcquireCacheView(next);
1099 p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
1100 if (p == (const PixelPacket *) NULL)
1103 for (x=0; x < (ssize_t) combine_image->columns; x++)
1105 SetGreenPixelComponent(q,PixelIntensityToQuantum(p));
1109 image_view=DestroyCacheView(image_view);
1110 next=GetNextImageInList(next);
1112 if (((channel & BlueChannel) != 0) && (next != (Image *) NULL))
1114 image_view=AcquireCacheView(next);
1115 p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
1116 if (p == (const PixelPacket *) NULL)
1119 for (x=0; x < (ssize_t) combine_image->columns; x++)
1121 SetBluePixelComponent(q,PixelIntensityToQuantum(p));
1125 image_view=DestroyCacheView(image_view);
1126 next=GetNextImageInList(next);
1128 if (((channel & OpacityChannel) != 0) && (next != (Image *) NULL))
1130 image_view=AcquireCacheView(next);
1131 p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
1132 if (p == (const PixelPacket *) NULL)
1135 for (x=0; x < (ssize_t) combine_image->columns; x++)
1137 SetOpacityPixelComponent(q,PixelIntensityToQuantum(p));
1141 image_view=DestroyCacheView(image_view);
1142 next=GetNextImageInList(next);
1144 if (((channel & IndexChannel) != 0) &&
1145 (image->colorspace == CMYKColorspace) && (next != (Image *) NULL))
1150 image_view=AcquireCacheView(next);
1151 p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
1152 if (p == (const PixelPacket *) NULL)
1154 indexes=GetCacheViewAuthenticIndexQueue(combine_view);
1155 for (x=0; x < (ssize_t) combine_image->columns; x++)
1157 indexes[x]=PixelIntensityToQuantum(p);
1160 image_view=DestroyCacheView(image_view);
1161 next=GetNextImageInList(next);
1163 if (SyncCacheViewAuthenticPixels(combine_view,exception) == MagickFalse)
1165 if (image->progress_monitor != (MagickProgressMonitor) NULL)
1170 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1171 #pragma omp critical (MagickCore_CombineImages)
1173 proceed=SetImageProgress(image,CombineImageTag,progress++,
1174 combine_image->rows);
1175 if (proceed == MagickFalse)
1179 combine_view=DestroyCacheView(combine_view);
1180 if (status == MagickFalse)
1181 combine_image=DestroyImage(combine_image);
1182 return(combine_image);
1186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1190 % D e s t r o y I m a g e %
1194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1196 % DestroyImage() dereferences an image, deallocating memory associated with
1197 % the image if the reference count becomes zero.
1199 % The format of the DestroyImage method is:
1201 % Image *DestroyImage(Image *image)
1203 % A description of each parameter follows:
1205 % o image: the image.
1208 MagickExport Image *DestroyImage(Image *image)
1216 assert(image != (Image *) NULL);
1217 assert(image->signature == MagickSignature);
1218 if (image->debug != MagickFalse)
1219 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1220 destroy=MagickFalse;
1221 LockSemaphoreInfo(image->semaphore);
1222 image->reference_count--;
1223 if (image->reference_count == 0)
1225 UnlockSemaphoreInfo(image->semaphore);
1226 if (destroy == MagickFalse)
1227 return((Image *) NULL);
1231 DestroyImagePixels(image);
1232 if (image->clip_mask != (Image *) NULL)
1233 image->clip_mask=DestroyImage(image->clip_mask);
1234 if (image->mask != (Image *) NULL)
1235 image->mask=DestroyImage(image->mask);
1236 if (image->montage != (char *) NULL)
1237 image->montage=DestroyString(image->montage);
1238 if (image->directory != (char *) NULL)
1239 image->directory=DestroyString(image->directory);
1240 if (image->colormap != (PixelPacket *) NULL)
1241 image->colormap=(PixelPacket *) RelinquishMagickMemory(image->colormap);
1242 if (image->geometry != (char *) NULL)
1243 image->geometry=DestroyString(image->geometry);
1244 DestroyImageProfiles(image);
1245 DestroyImageProperties(image);
1246 DestroyImageArtifacts(image);
1247 if (image->ascii85 != (Ascii85Info*) NULL)
1248 image->ascii85=(Ascii85Info *) RelinquishMagickMemory(image->ascii85);
1250 (void) DestroyExceptionInfo(&image->exception);
1251 if (image->semaphore != (SemaphoreInfo *) NULL)
1252 DestroySemaphoreInfo(&image->semaphore);
1253 image->signature=(~MagickSignature);
1254 image=(Image *) RelinquishMagickMemory(image);
1259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1263 % D e s t r o y I m a g e I n f o %
1267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1269 % DestroyImageInfo() deallocates memory associated with an ImageInfo
1272 % The format of the DestroyImageInfo method is:
1274 % ImageInfo *DestroyImageInfo(ImageInfo *image_info)
1276 % A description of each parameter follows:
1278 % o image_info: the image info.
1281 MagickExport ImageInfo *DestroyImageInfo(ImageInfo *image_info)
1283 assert(image_info != (ImageInfo *) NULL);
1284 assert(image_info->signature == MagickSignature);
1285 if (image_info->debug != MagickFalse)
1286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1287 image_info->filename);
1288 if (image_info->size != (char *) NULL)
1289 image_info->size=DestroyString(image_info->size);
1290 if (image_info->extract != (char *) NULL)
1291 image_info->extract=DestroyString(image_info->extract);
1292 if (image_info->scenes != (char *) NULL)
1293 image_info->scenes=DestroyString(image_info->scenes);
1294 if (image_info->page != (char *) NULL)
1295 image_info->page=DestroyString(image_info->page);
1296 if (image_info->sampling_factor != (char *) NULL)
1297 image_info->sampling_factor=DestroyString(
1298 image_info->sampling_factor);
1299 if (image_info->server_name != (char *) NULL)
1300 image_info->server_name=DestroyString(
1301 image_info->server_name);
1302 if (image_info->font != (char *) NULL)
1303 image_info->font=DestroyString(image_info->font);
1304 if (image_info->texture != (char *) NULL)
1305 image_info->texture=DestroyString(image_info->texture);
1306 if (image_info->density != (char *) NULL)
1307 image_info->density=DestroyString(image_info->density);
1308 if (image_info->view != (char *) NULL)
1309 image_info->view=DestroyString(image_info->view);
1310 if (image_info->authenticate != (char *) NULL)
1311 image_info->authenticate=DestroyString(
1312 image_info->authenticate);
1313 DestroyImageOptions(image_info);
1314 if (image_info->cache != (void *) NULL)
1315 image_info->cache=DestroyPixelCache(image_info->cache);
1316 if (image_info->profile != (StringInfo *) NULL)
1317 image_info->profile=(void *) DestroyStringInfo((StringInfo *)
1318 image_info->profile);
1319 image_info->signature=(~MagickSignature);
1320 image_info=(ImageInfo *) RelinquishMagickMemory(image_info);
1325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1329 + D i s a s s o c i a t e I m a g e S t r e a m %
1333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1335 % DisassociateImageStream() disassociates the image stream.
1337 % The format of the DisassociateImageStream method is:
1339 % MagickBooleanType DisassociateImageStream(const Image *image)
1341 % A description of each parameter follows:
1343 % o image: the image.
1346 MagickExport void DisassociateImageStream(Image *image)
1348 assert(image != (const Image *) NULL);
1349 assert(image->signature == MagickSignature);
1350 if (image->debug != MagickFalse)
1351 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1352 (void) DetachBlob(image->blob);
1356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1360 % G e t I m a g e A l p h a C h a n n e l %
1364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1366 % GetImageAlphaChannel() returns MagickFalse if the image alpha channel is
1367 % not activated. That is, the image is RGB rather than RGBA or CMYK rather
1370 % The format of the GetImageAlphaChannel method is:
1372 % MagickBooleanType GetImageAlphaChannel(const Image *image)
1374 % A description of each parameter follows:
1376 % o image: the image.
1379 MagickExport MagickBooleanType GetImageAlphaChannel(const Image *image)
1381 assert(image != (const Image *) NULL);
1382 if (image->debug != MagickFalse)
1383 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1384 assert(image->signature == MagickSignature);
1385 return(image->matte);
1389 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1393 % G e t I m a g e C l i p M a s k %
1397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1399 % GetImageClipMask() returns the clip path associated with the image.
1401 % The format of the GetImageClipMask method is:
1403 % Image *GetImageClipMask(const Image *image,ExceptionInfo *exception)
1405 % A description of each parameter follows:
1407 % o image: the image.
1410 MagickExport Image *GetImageClipMask(const Image *image,
1411 ExceptionInfo *exception)
1413 assert(image != (const Image *) NULL);
1414 if (image->debug != MagickFalse)
1415 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1416 assert(image->signature == MagickSignature);
1417 if (image->clip_mask == (Image *) NULL)
1418 return((Image *) NULL);
1419 return(CloneImage(image->clip_mask,0,0,MagickTrue,exception));
1423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1427 % G e t I m a g e E x c e p t i o n %
1431 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1433 % GetImageException() traverses an image sequence and returns any
1434 % error more severe than noted by the exception parameter.
1436 % The format of the GetImageException method is:
1438 % void GetImageException(Image *image,ExceptionInfo *exception)
1440 % A description of each parameter follows:
1442 % o image: Specifies a pointer to a list of one or more images.
1444 % o exception: return the highest severity exception.
1447 MagickExport void GetImageException(Image *image,ExceptionInfo *exception)
1452 assert(image != (Image *) NULL);
1453 assert(image->signature == MagickSignature);
1454 if (image->debug != MagickFalse)
1455 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1456 assert(exception != (ExceptionInfo *) NULL);
1457 assert(exception->signature == MagickSignature);
1458 for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
1460 if (next->exception.severity == UndefinedException)
1462 if (next->exception.severity > exception->severity)
1463 InheritException(exception,&next->exception);
1464 next->exception.severity=UndefinedException;
1469 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1473 % G e t I m a g e I n f o %
1477 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1479 % GetImageInfo() initializes image_info to default values.
1481 % The format of the GetImageInfo method is:
1483 % void GetImageInfo(ImageInfo *image_info)
1485 % A description of each parameter follows:
1487 % o image_info: the image info.
1490 MagickExport void GetImageInfo(ImageInfo *image_info)
1496 File and image dimension members.
1498 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1499 assert(image_info != (ImageInfo *) NULL);
1500 (void) ResetMagickMemory(image_info,0,sizeof(*image_info));
1501 image_info->adjoin=MagickTrue;
1502 image_info->interlace=NoInterlace;
1503 image_info->channel=DefaultChannels;
1504 image_info->quality=UndefinedCompressionQuality;
1505 image_info->antialias=MagickTrue;
1506 image_info->dither=MagickTrue;
1507 exception=AcquireExceptionInfo();
1508 (void) QueryColorDatabase(BackgroundColor,&image_info->background_color,
1510 (void) QueryColorDatabase(BorderColor,&image_info->border_color,exception);
1511 (void) QueryColorDatabase(MatteColor,&image_info->matte_color,exception);
1512 (void) QueryColorDatabase(TransparentColor,&image_info->transparent_color,
1514 exception=DestroyExceptionInfo(exception);
1515 image_info->debug=IsEventLogging();
1516 image_info->signature=MagickSignature;
1520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1524 % G e t I m a g e I n f o F i l e %
1528 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1530 % GetImageInfoFile() returns the image info file member.
1532 % The format of the GetImageInfoFile method is:
1534 % FILE *GetImageInfoFile(const ImageInfo *image_info)
1536 % A description of each parameter follows:
1538 % o image_info: the image info.
1541 MagickExport FILE *GetImageInfoFile(const ImageInfo *image_info)
1543 return(image_info->file);
1547 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1551 % G e t I m a g e M a s k %
1555 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1557 % GetImageMask() returns the mask associated with the image.
1559 % The format of the GetImageMask method is:
1561 % Image *GetImageMask(const Image *image,ExceptionInfo *exception)
1563 % A description of each parameter follows:
1565 % o image: the image.
1568 MagickExport Image *GetImageMask(const Image *image,ExceptionInfo *exception)
1570 assert(image != (const Image *) NULL);
1571 if (image->debug != MagickFalse)
1572 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1573 assert(image->signature == MagickSignature);
1574 if (image->mask == (Image *) NULL)
1575 return((Image *) NULL);
1576 return(CloneImage(image->mask,0,0,MagickTrue,exception));
1580 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1584 + G e t I m a g e R e f e r e n c e C o u n t %
1588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1590 % GetImageReferenceCount() returns the image reference count.
1592 % The format of the GetReferenceCount method is:
1594 % ssize_t GetImageReferenceCount(Image *image)
1596 % A description of each parameter follows:
1598 % o image: the image.
1601 MagickExport ssize_t GetImageReferenceCount(Image *image)
1606 assert(image != (Image *) NULL);
1607 assert(image->signature == MagickSignature);
1608 if (image->debug != MagickFalse)
1609 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1610 LockSemaphoreInfo(image->semaphore);
1611 reference_count=image->reference_count;
1612 UnlockSemaphoreInfo(image->semaphore);
1613 return(reference_count);
1617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1621 % G e t I m a g e V i r t u a l P i x e l M e t h o d %
1625 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1627 % GetImageVirtualPixelMethod() gets the "virtual pixels" method for the
1628 % image. A virtual pixel is any pixel access that is outside the boundaries
1629 % of the image cache.
1631 % The format of the GetImageVirtualPixelMethod() method is:
1633 % VirtualPixelMethod GetImageVirtualPixelMethod(const Image *image)
1635 % A description of each parameter follows:
1637 % o image: the image.
1640 MagickExport VirtualPixelMethod GetImageVirtualPixelMethod(const Image *image)
1642 assert(image != (Image *) NULL);
1643 assert(image->signature == MagickSignature);
1644 if (image->debug != MagickFalse)
1645 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1646 return(GetPixelCacheVirtualMethod(image));
1650 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1654 % I n t e r p r e t I m a g e F i l e n a m e %
1658 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1660 % InterpretImageFilename() interprets embedded characters in an image filename.
1661 % The filename length is returned.
1663 % The format of the InterpretImageFilename method is:
1665 % size_t InterpretImageFilename(const ImageInfo *image_info,
1666 % Image *image,const char *format,int value,char *filename)
1668 % A description of each parameter follows.
1670 % o image_info: the image info..
1672 % o image: the image.
1674 % o format: A filename describing the format to use to write the numeric
1675 % argument. Only the first numeric format identifier is replaced.
1677 % o value: Numeric value to substitute into format filename.
1679 % o filename: return the formatted filename in this character buffer.
1682 MagickExport size_t InterpretImageFilename(const ImageInfo *image_info,
1683 Image *image,const char *format,int value,char *filename)
1697 canonical=MagickFalse;
1698 (void) CopyMagickString(filename,format,MaxTextExtent);
1699 for (p=strchr(format,'%'); p != (char *) NULL; p=strchr(p+1,'%'))
1712 value=(ssize_t) strtol(q,&q,10);
1723 (void) FormatMagickString(filename+(p-format),(size_t) (MaxTextExtent-
1724 (p-format)),p,value);
1726 (void) ConcatenateMagickString(filename,q,MaxTextExtent);
1727 canonical=MagickTrue;
1736 pattern[MaxTextExtent];
1753 if (strchr(p,']') == (char *) NULL)
1757 for (i=0; (i < (MaxTextExtent-1L)) && (*r != '\0'); i++)
1768 if (LocaleNCompare(pattern,"filename:",9) != 0)
1770 value=(const char *) NULL;
1771 if ((image_info != (const ImageInfo *) NULL) &&
1772 (image != (const Image *) NULL))
1773 value=GetMagickProperty(image_info,image,pattern);
1775 if (image != (Image *) NULL)
1776 value=GetImageProperty(image,pattern);
1778 if (image_info != (ImageInfo *) NULL)
1779 value=GetImageOption(image_info,pattern);
1780 if (value == (const char *) NULL)
1785 (void) CopyMagickString(filename+(p-format),value,(size_t)
1786 (MaxTextExtent-(p-format)));
1788 (void) ConcatenateMagickString(filename,r+1,MaxTextExtent);
1789 canonical=MagickTrue;
1799 for (q=filename; *q != '\0'; q++)
1800 if ((*q == '%') && (*(q+1) == '%'))
1801 (void) CopyMagickString(q,q+1,(size_t) (MaxTextExtent-(q-filename)));
1802 if (canonical == MagickFalse)
1803 (void) CopyMagickString(filename,format,MaxTextExtent);
1804 return(strlen(filename));
1808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1812 % I s H i g h D y n a m i c R a n g e I m a g e %
1816 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1818 % IsHighDynamicRangeImage() returns MagickTrue if any pixel component is
1819 % non-integer or exceeds the bounds of the quantum depth (e.g. for Q16
1822 % The format of the IsHighDynamicRangeImage method is:
1824 % MagickBooleanType IsHighDynamicRangeImage(const Image *image,
1825 % ExceptionInfo *exception)
1827 % A description of each parameter follows:
1829 % o image: the image.
1831 % o exception: return any errors or warnings in this structure.
1834 MagickExport MagickBooleanType IsHighDynamicRangeImage(const Image *image,
1835 ExceptionInfo *exception)
1837 #if !defined(MAGICKCORE_HDRI_SUPPORT)
1840 return(MagickFalse);
1854 assert(image != (Image *) NULL);
1855 assert(image->signature == MagickSignature);
1856 if (image->debug != MagickFalse)
1857 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1859 GetMagickPixelPacket(image,&zero);
1860 image_view=AcquireCacheView(image);
1861 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1862 #pragma omp parallel for schedule(dynamic,4) shared(status)
1864 for (y=0; y < (ssize_t) image->rows; y++)
1869 register const IndexPacket
1872 register const PixelPacket
1878 if (status == MagickFalse)
1880 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
1881 if (p == (const PixelPacket *) NULL)
1886 indexes=GetCacheViewVirtualIndexQueue(image_view);
1888 for (x=0; x < (ssize_t) image->columns; x++)
1890 SetMagickPixelPacket(image,p,indexes+x,&pixel);
1891 if ((pixel.red < 0.0) || (pixel.red > QuantumRange) ||
1892 (pixel.red != (QuantumAny) pixel.red))
1894 if ((pixel.green < 0.0) || (pixel.green > QuantumRange) ||
1895 (pixel.green != (QuantumAny) pixel.green))
1897 if ((pixel.blue < 0.0) || (pixel.blue > QuantumRange) ||
1898 (pixel.blue != (QuantumAny) pixel.blue))
1900 if (pixel.matte != MagickFalse)
1902 if ((pixel.opacity < 0.0) || (pixel.opacity > QuantumRange) ||
1903 (pixel.opacity != (QuantumAny) pixel.opacity))
1906 if (pixel.colorspace == CMYKColorspace)
1908 if ((pixel.index < 0.0) || (pixel.index > QuantumRange) ||
1909 (pixel.index != (QuantumAny) pixel.index))
1914 if (x < (ssize_t) image->columns)
1917 image_view=DestroyCacheView(image_view);
1918 return(status != MagickFalse ? MagickFalse : MagickTrue);
1923 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1927 % I s I m a g e O b j e c t %
1931 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1933 % IsImageObject() returns MagickTrue if the image sequence contains a valid
1934 % set of image objects.
1936 % The format of the IsImageObject method is:
1938 % MagickBooleanType IsImageObject(const Image *image)
1940 % A description of each parameter follows:
1942 % o image: the image.
1945 MagickExport MagickBooleanType IsImageObject(const Image *image)
1947 register const Image
1950 assert(image != (Image *) NULL);
1951 if (image->debug != MagickFalse)
1952 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1953 for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1954 if (p->signature != MagickSignature)
1955 return(MagickFalse);
1960 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1964 % I s T a i n t I m a g e %
1968 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1970 % IsTaintImage() returns MagickTrue any pixel in the image has been altered
1971 % since it was first constituted.
1973 % The format of the IsTaintImage method is:
1975 % MagickBooleanType IsTaintImage(const Image *image)
1977 % A description of each parameter follows:
1979 % o image: the image.
1982 MagickExport MagickBooleanType IsTaintImage(const Image *image)
1985 magick[MaxTextExtent],
1986 filename[MaxTextExtent];
1988 register const Image
1991 assert(image != (Image *) NULL);
1992 if (image->debug != MagickFalse)
1993 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1994 assert(image->signature == MagickSignature);
1995 (void) CopyMagickString(magick,image->magick,MaxTextExtent);
1996 (void) CopyMagickString(filename,image->filename,MaxTextExtent);
1997 for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1999 if (p->taint != MagickFalse)
2001 if (LocaleCompare(p->magick,magick) != 0)
2003 if (LocaleCompare(p->filename,filename) != 0)
2006 return(MagickFalse);
2010 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2014 % M o d i f y I m a g e %
2018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2020 % ModifyImage() ensures that there is only a single reference to the image
2021 % to be modified, updating the provided image pointer to point to a clone of
2022 % the original image if necessary.
2024 % The format of the ModifyImage method is:
2026 % MagickBooleanType ModifyImage(Image *image,ExceptionInfo *exception)
2028 % A description of each parameter follows:
2030 % o image: the image.
2032 % o exception: return any errors or warnings in this structure.
2035 MagickExport MagickBooleanType ModifyImage(Image **image,
2036 ExceptionInfo *exception)
2041 assert(image != (Image **) NULL);
2042 assert(*image != (Image *) NULL);
2043 assert((*image)->signature == MagickSignature);
2044 if ((*image)->debug != MagickFalse)
2045 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
2046 if (GetImageReferenceCount(*image) <= 1)
2048 clone_image=CloneImage(*image,0,0,MagickTrue,exception);
2049 LockSemaphoreInfo((*image)->semaphore);
2050 (*image)->reference_count--;
2051 UnlockSemaphoreInfo((*image)->semaphore);
2057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2061 % N e w M a g i c k I m a g e %
2065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2067 % NewMagickImage() creates a blank image canvas of the specified size and
2070 % The format of the NewMagickImage method is:
2072 % Image *NewMagickImage(const ImageInfo *image_info,
2073 % const size_t width,const size_t height,
2074 % const MagickPixelPacket *background)
2076 % A description of each parameter follows:
2078 % o image: the image.
2080 % o width: the image width.
2082 % o height: the image height.
2084 % o background: the image color.
2087 MagickExport Image *NewMagickImage(const ImageInfo *image_info,
2088 const size_t width,const size_t height,
2089 const MagickPixelPacket *background)
2106 assert(image_info != (const ImageInfo *) NULL);
2107 if (image_info->debug != MagickFalse)
2108 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2109 assert(image_info->signature == MagickSignature);
2110 assert(background != (const MagickPixelPacket *) NULL);
2111 image=AcquireImage(image_info);
2112 image->columns=width;
2114 image->colorspace=background->colorspace;
2115 image->matte=background->matte;
2116 image->fuzz=background->fuzz;
2117 image->depth=background->depth;
2119 exception=(&image->exception);
2120 image_view=AcquireCacheView(image);
2121 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2122 #pragma omp parallel for schedule(dynamic,4) shared(status)
2124 for (y=0; y < (ssize_t) image->rows; y++)
2126 register IndexPacket
2129 register PixelPacket
2135 if (status == MagickFalse)
2137 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2138 if (q == (PixelPacket *) NULL)
2143 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2144 for (x=0; x < (ssize_t) image->columns; x++)
2146 SetPixelPacket(image,background,q,indexes+x);
2149 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2152 image_view=DestroyCacheView(image_view);
2153 if (status == MagickFalse)
2154 image=DestroyImage(image);
2159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2163 % R e f e r e n c e I m a g e %
2167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2169 % ReferenceImage() increments the reference count associated with an image
2170 % returning a pointer to the image.
2172 % The format of the ReferenceImage method is:
2174 % Image *ReferenceImage(Image *image)
2176 % A description of each parameter follows:
2178 % o image: the image.
2181 MagickExport Image *ReferenceImage(Image *image)
2183 assert(image != (Image *) NULL);
2184 if (image->debug != MagickFalse)
2185 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2186 assert(image->signature == MagickSignature);
2187 LockSemaphoreInfo(image->semaphore);
2188 image->reference_count++;
2189 UnlockSemaphoreInfo(image->semaphore);
2194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2198 % R e s e t I m a g e P a g e %
2202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2204 % ResetImagePage() resets the image page canvas and position.
2206 % The format of the ResetImagePage method is:
2208 % MagickBooleanType ResetImagePage(Image *image,const char *page)
2210 % A description of each parameter follows:
2212 % o image: the image.
2214 % o page: the relative page specification.
2217 MagickExport MagickBooleanType ResetImagePage(Image *image,const char *page)
2225 assert(image != (Image *) NULL);
2226 assert(image->signature == MagickSignature);
2227 if (image->debug != MagickFalse)
2228 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2229 flags=ParseAbsoluteGeometry(page,&geometry);
2230 if ((flags & WidthValue) != 0)
2232 if ((flags & HeightValue) == 0)
2233 geometry.height=geometry.width;
2234 image->page.width=geometry.width;
2235 image->page.height=geometry.height;
2237 if ((flags & AspectValue) != 0)
2239 if ((flags & XValue) != 0)
2240 image->page.x+=geometry.x;
2241 if ((flags & YValue) != 0)
2242 image->page.y+=geometry.y;
2246 if ((flags & XValue) != 0)
2248 image->page.x=geometry.x;
2249 if ((image->page.width == 0) && (geometry.x > 0))
2250 image->page.width=image->columns+geometry.x;
2252 if ((flags & YValue) != 0)
2254 image->page.y=geometry.y;
2255 if ((image->page.height == 0) && (geometry.y > 0))
2256 image->page.height=image->rows+geometry.y;
2263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2267 % S e p a r a t e I m a g e C h a n n e l %
2271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2273 % SeparateImageChannel() separates a channel from the image and returns it as
2274 % a grayscale image. A channel is a particular color component of each pixel
2277 % The format of the SeparateImageChannel method is:
2279 % MagickBooleanType SeparateImageChannel(Image *image,
2280 % const ChannelType channel)
2282 % A description of each parameter follows:
2284 % o image: the image.
2286 % o channel: Identify which channel to extract: RedChannel, GreenChannel,
2287 % BlueChannel, OpacityChannel, CyanChannel, MagentaChannel,
2288 % YellowChannel, or BlackChannel.
2291 MagickExport MagickBooleanType SeparateImageChannel(Image *image,
2292 const ChannelType channel)
2294 #define SeparateImageTag "Separate/Image"
2311 assert(image != (Image *) NULL);
2312 assert(image->signature == MagickSignature);
2313 if (image->debug != MagickFalse)
2314 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2315 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2316 return(MagickFalse);
2318 Separate image channels.
2321 if (channel == GrayChannels)
2322 image->matte=MagickTrue;
2324 exception=(&image->exception);
2325 image_view=AcquireCacheView(image);
2326 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2327 #pragma omp parallel for schedule(dynamic,4) shared(progress,status)
2329 for (y=0; y < (ssize_t) image->rows; y++)
2331 register IndexPacket
2334 register PixelPacket
2340 if (status == MagickFalse)
2342 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2343 if (q == (PixelPacket *) NULL)
2348 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2353 for (x=0; x < (ssize_t) image->columns; x++)
2363 for (x=0; x < (ssize_t) image->columns; x++)
2373 for (x=0; x < (ssize_t) image->columns; x++)
2381 case OpacityChannel:
2383 for (x=0; x < (ssize_t) image->columns; x++)
2386 q->green=q->opacity;
2394 if ((image->storage_class != PseudoClass) &&
2395 (image->colorspace != CMYKColorspace))
2397 for (x=0; x < (ssize_t) image->columns; x++)
2400 q->green=indexes[x];
2406 case TrueAlphaChannel:
2408 for (x=0; x < (ssize_t) image->columns; x++)
2410 q->red=(Quantum) GetAlphaPixelComponent(q);
2411 q->green=(Quantum) GetAlphaPixelComponent(q);
2412 q->blue=(Quantum) GetAlphaPixelComponent(q);
2419 for (x=0; x < (ssize_t) image->columns; x++)
2421 q->opacity=(Quantum) (QuantumRange-PixelIntensityToQuantum(q));
2429 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2431 if (image->progress_monitor != (MagickProgressMonitor) NULL)
2436 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2437 #pragma omp critical (MagickCore_SeparateImageChannel)
2439 proceed=SetImageProgress(image,SeparateImageTag,progress++,image->rows);
2440 if (proceed == MagickFalse)
2444 image_view=DestroyCacheView(image_view);
2445 if (channel != GrayChannels)
2446 image->matte=MagickFalse;
2447 (void) SetImageColorspace(image,RGBColorspace);
2452 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2456 % S e p a r a t e I m a g e s %
2460 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2462 % SeparateImages() returns a separate grayscale image for each channel
2465 % The format of the SeparateImages method is:
2467 % MagickBooleanType SeparateImages(const Image *image,
2468 % const ChannelType channel,ExceptionInfo *exception)
2470 % A description of each parameter follows:
2472 % o image: the image.
2474 % o channel: Identify which channels to extract: RedChannel, GreenChannel,
2475 % BlueChannel, OpacityChannel, CyanChannel, MagentaChannel,
2476 % YellowChannel, or BlackChannel.
2478 % o exception: return any errors or warnings in this structure.
2481 MagickExport Image *SeparateImages(const Image *image,const ChannelType channel,
2482 ExceptionInfo *exception)
2488 assert(image != (Image *) NULL);
2489 assert(image->signature == MagickSignature);
2490 if (image->debug != MagickFalse)
2491 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2492 images=NewImageList();
2493 if ((channel & RedChannel) != 0)
2495 separate_image=CloneImage(image,0,0,MagickTrue,exception);
2496 (void) SeparateImageChannel(separate_image,RedChannel);
2497 AppendImageToList(&images,separate_image);
2499 if ((channel & GreenChannel) != 0)
2501 separate_image=CloneImage(image,0,0,MagickTrue,exception);
2502 (void) SeparateImageChannel(separate_image,GreenChannel);
2503 AppendImageToList(&images,separate_image);
2505 if ((channel & BlueChannel) != 0)
2507 separate_image=CloneImage(image,0,0,MagickTrue,exception);
2508 (void) SeparateImageChannel(separate_image,BlueChannel);
2509 AppendImageToList(&images,separate_image);
2511 if (((channel & BlackChannel) != 0) && (image->colorspace == CMYKColorspace))
2513 separate_image=CloneImage(image,0,0,MagickTrue,exception);
2514 (void) SeparateImageChannel(separate_image,BlackChannel);
2515 AppendImageToList(&images,separate_image);
2517 if ((channel & OpacityChannel) != 0)
2519 separate_image=CloneImage(image,0,0,MagickTrue,exception);
2520 (void) SeparateImageChannel(separate_image,OpacityChannel);
2521 AppendImageToList(&images,separate_image);
2527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2531 % S e t I m a g e A l p h a C h a n n e l %
2535 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2537 % SetImageAlphaChannel() activates, deactivates, resets, or sets the alpha
2540 % The format of the SetImageAlphaChannel method is:
2542 % MagickBooleanType SetImageAlphaChannel(Image *image,
2543 % const AlphaChannelType alpha_type)
2545 % A description of each parameter follows:
2547 % o image: the image.
2549 % o alpha_type: The alpha channel type: ActivateAlphaChannel,
2550 % CopyAlphaChannel, DeactivateAlphaChannel, ExtractAlphaChannel,
2551 % OpaqueAlphaChannel, ResetAlphaChannel, SetAlphaChannel,
2552 % ShapeAlphaChannel, and TransparentAlphaChannel.
2555 MagickExport MagickBooleanType SetImageAlphaChannel(Image *image,
2556 const AlphaChannelType alpha_type)
2561 assert(image != (Image *) NULL);
2562 if (image->debug != MagickFalse)
2563 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2564 assert(image->signature == MagickSignature);
2568 case ActivateAlphaChannel:
2570 image->matte=MagickTrue;
2573 case BackgroundAlphaChannel:
2597 Set transparent pixels to background color.
2599 if (image->matte == MagickFalse)
2601 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2603 GetMagickPixelPacket(image,&background);
2604 SetMagickPixelPacket(image,&image->background_color,(const IndexPacket *)
2606 if (image->colorspace == CMYKColorspace)
2607 ConvertRGBToCMYK(&background);
2609 SetPixelPacket(image,&background,&pixel,&index);
2611 exception=(&image->exception);
2612 image_view=AcquireCacheView(image);
2613 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2614 #pragma omp parallel for schedule(dynamic,4) shared(status)
2616 for (y=0; y < (ssize_t) image->rows; y++)
2618 register IndexPacket
2621 register PixelPacket
2627 if (status == MagickFalse)
2629 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
2631 if (q == (PixelPacket *) NULL)
2636 for (x=0; x < (ssize_t) image->columns; x++)
2638 if (q->opacity == TransparentOpacity)
2641 q->green=pixel.green;
2646 if (image->colorspace == CMYKColorspace)
2648 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2649 for (x=0; x < (ssize_t) image->columns; x++)
2652 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2655 image_view=DestroyCacheView(image_view);
2658 case DeactivateAlphaChannel:
2660 image->matte=MagickFalse;
2663 case ShapeAlphaChannel:
2664 case CopyAlphaChannel:
2667 Special usage case for SeparateImageChannel(): copy grayscale color to
2670 status=SeparateImageChannel(image,GrayChannels);
2671 image->matte=MagickTrue; /* make sure transparency is now on! */
2672 if (alpha_type == ShapeAlphaChannel)
2678 Reset all color channels to background color.
2680 GetMagickPixelPacket(image,&background);
2681 SetMagickPixelPacket(image,&(image->background_color),(IndexPacket *)
2683 (void) LevelColorsImage(image,&background,&background,MagickTrue);
2687 case ExtractAlphaChannel:
2689 status=SeparateImageChannel(image,TrueAlphaChannel);
2690 image->matte=MagickFalse;
2693 case ResetAlphaChannel: /* deprecated */
2694 case OpaqueAlphaChannel:
2696 status=SetImageOpacity(image,OpaqueOpacity);
2697 image->matte=MagickTrue;
2700 case TransparentAlphaChannel:
2702 status=SetImageOpacity(image,TransparentOpacity);
2703 image->matte=MagickTrue;
2706 case SetAlphaChannel:
2708 if (image->matte == MagickFalse)
2710 status=SetImageOpacity(image,OpaqueOpacity);
2711 image->matte=MagickTrue;
2715 case UndefinedAlphaChannel:
2722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2726 % S e t I m a g e B a c k g r o u n d C o l o r %
2730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2732 % SetImageBackgroundColor() initializes the image pixels to the image
2733 % background color. The background color is defined by the background_color
2734 % member of the image structure.
2736 % The format of the SetImage method is:
2738 % MagickBooleanType SetImageBackgroundColor(Image *image)
2740 % A description of each parameter follows:
2742 % o image: the image.
2745 MagickExport MagickBooleanType SetImageBackgroundColor(Image *image)
2768 assert(image != (Image *) NULL);
2769 if (image->debug != MagickFalse)
2770 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2771 assert(image->signature == MagickSignature);
2772 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2773 return(MagickFalse);
2774 if (image->background_color.opacity != OpaqueOpacity)
2775 image->matte=MagickTrue;
2776 GetMagickPixelPacket(image,&background);
2777 SetMagickPixelPacket(image,&image->background_color,(const IndexPacket *)
2779 if (image->colorspace == CMYKColorspace)
2780 ConvertRGBToCMYK(&background);
2782 SetPixelPacket(image,&background,&pixel,&index);
2784 Set image background color.
2787 exception=(&image->exception);
2788 image_view=AcquireCacheView(image);
2789 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2790 #pragma omp parallel for schedule(dynamic,4) shared(status)
2792 for (y=0; y < (ssize_t) image->rows; y++)
2794 register IndexPacket
2797 register PixelPacket
2803 if (status == MagickFalse)
2805 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2806 if (q == (PixelPacket *) NULL)
2811 for (x=0; x < (ssize_t) image->columns; x++)
2813 if (image->colorspace == CMYKColorspace)
2815 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2816 for (x=0; x < (ssize_t) image->columns; x++)
2819 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2822 image_view=DestroyCacheView(image_view);
2827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2831 % S e t I m a g e C o l o r %
2835 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2837 % SetImageColor() set the entire image canvas to the specified color.
2839 % The format of the SetImageColor method is:
2841 % MagickBooleanType SetImageColor(Image *image,
2842 % const MagickPixelPacket *color)
2844 % A description of each parameter follows:
2846 % o image: the image.
2848 % o background: the image color.
2851 MagickExport MagickBooleanType SetImageColor(Image *image,
2852 const MagickPixelPacket *color)
2866 assert(image != (Image *) NULL);
2867 if (image->debug != MagickFalse)
2868 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2869 assert(image->signature == MagickSignature);
2870 assert(color != (const MagickPixelPacket *) NULL);
2871 image->colorspace=color->colorspace;
2872 image->matte=color->matte;
2873 image->fuzz=color->fuzz;
2874 image->depth=color->depth;
2876 exception=(&image->exception);
2877 image_view=AcquireCacheView(image);
2878 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2879 #pragma omp parallel for schedule(dynamic,4) shared(status)
2881 for (y=0; y < (ssize_t) image->rows; y++)
2883 register IndexPacket
2886 register PixelPacket
2892 if (status == MagickFalse)
2894 q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2895 if (q == (PixelPacket *) NULL)
2900 indexes=GetCacheViewAuthenticIndexQueue(image_view);
2901 for (x=0; x < (ssize_t) image->columns; x++)
2903 SetPixelPacket(image,color,q,indexes+x);
2906 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2909 image_view=DestroyCacheView(image_view);
2914 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2918 % S e t I m a g e S t o r a g e C l a s s %
2922 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2924 % SetImageStorageClass() sets the image class: DirectClass for true color
2925 % images or PseudoClass for colormapped images.
2927 % The format of the SetImageStorageClass method is:
2929 % MagickBooleanType SetImageStorageClass(Image *image,
2930 % const ClassType storage_class)
2932 % A description of each parameter follows:
2934 % o image: the image.
2936 % o storage_class: The image class.
2939 MagickExport MagickBooleanType SetImageStorageClass(Image *image,
2940 const ClassType storage_class)
2942 image->storage_class=storage_class;
2947 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2951 % S e t I m a g e C l i p M a s k %
2955 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2957 % SetImageClipMask() associates a clip path with the image. The clip path
2958 % must be the same dimensions as the image. Set any pixel component of
2959 % the clip path to TransparentOpacity to prevent that corresponding image
2960 % pixel component from being updated when SyncAuthenticPixels() is applied.
2962 % The format of the SetImageClipMask method is:
2964 % MagickBooleanType SetImageClipMask(Image *image,const Image *clip_mask)
2966 % A description of each parameter follows:
2968 % o image: the image.
2970 % o clip_mask: the image clip path.
2973 MagickExport MagickBooleanType SetImageClipMask(Image *image,
2974 const Image *clip_mask)
2976 assert(image != (Image *) NULL);
2977 if (image->debug != MagickFalse)
2978 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2979 assert(image->signature == MagickSignature);
2980 if (clip_mask != (const Image *) NULL)
2981 if ((clip_mask->columns != image->columns) ||
2982 (clip_mask->rows != image->rows))
2983 ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
2984 if (image->clip_mask != (Image *) NULL)
2985 image->clip_mask=DestroyImage(image->clip_mask);
2986 image->clip_mask=NewImageList();
2987 if (clip_mask == (Image *) NULL)
2989 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
2990 return(MagickFalse);
2991 image->clip_mask=CloneImage(clip_mask,0,0,MagickTrue,&image->exception);
2992 if (image->clip_mask == (Image *) NULL)
2993 return(MagickFalse);
2998 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3002 % S e t I m a g e E x t e n t %
3006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3008 % SetImageExtent() sets the image size (i.e. columns & rows).
3010 % The format of the SetImageExtent method is:
3012 % MagickBooleanType SetImageExtent(Image *image,
3013 % const size_t columns,const size_t rows)
3015 % A description of each parameter follows:
3017 % o image: the image.
3019 % o columns: The image width in pixels.
3021 % o rows: The image height in pixels.
3024 MagickExport MagickBooleanType SetImageExtent(Image *image,
3025 const size_t columns,const size_t rows)
3027 if ((columns == 0) || (rows == 0))
3028 return(MagickFalse);
3029 image->columns=columns;
3035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3039 + S e t I m a g e I n f o %
3043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3045 % SetImageInfo() initializes the `magick' field of the ImageInfo structure.
3046 % It is set to a type of image format based on the prefix or suffix of the
3047 % filename. For example, `ps:image' returns PS indicating a Postscript image.
3048 % JPEG is returned for this filename: `image.jpg'. The filename prefix has
3049 % precendence over the suffix. Use an optional index enclosed in brackets
3050 % after a file name to specify a desired scene of a multi-resolution image
3051 % format like Photo CD (e.g. img0001.pcd[4]). A True (non-zero) return value
3052 % indicates success.
3054 % The format of the SetImageInfo method is:
3056 % MagickBooleanType SetImageInfo(ImageInfo *image_info,
3057 % const unsigned int frames,ExceptionInfo *exception)
3059 % A description of each parameter follows:
3061 % o image_info: the image info.
3063 % o frames: the number of images you intend to write.
3065 % o exception: return any errors or warnings in this structure.
3068 MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info,
3069 const unsigned int frames,ExceptionInfo *exception)
3072 extension[MaxTextExtent],
3073 filename[MaxTextExtent],
3074 magic[MaxTextExtent],
3076 subimage[MaxTextExtent];
3100 magick[2*MaxTextExtent];
3103 Look for 'image.format' in filename.
3105 assert(image_info != (ImageInfo *) NULL);
3106 assert(image_info->signature == MagickSignature);
3107 if (image_info->debug != MagickFalse)
3108 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3109 image_info->filename);
3113 GetPathComponent(image_info->filename,SubimagePath,subimage);
3114 if (*subimage != '\0')
3117 Look for scene specification (e.g. img0001.pcd[4]).
3119 if (IsSceneGeometry(subimage,MagickFalse) == MagickFalse)
3121 if (IsGeometry(subimage) != MagickFalse)
3122 (void) CloneString(&image_info->extract,subimage);
3130 (void) CloneString(&image_info->scenes,subimage);
3131 image_info->scene=StringToUnsignedLong(image_info->scenes);
3132 image_info->number_scenes=image_info->scene;
3133 p=image_info->scenes;
3134 for (q=(char *) image_info->scenes; *q != '\0'; p++)
3136 while ((isspace((int) ((unsigned char) *p)) != 0) ||
3139 first=(size_t) strtol(p,&q,10);
3141 while (isspace((int) ((unsigned char) *q)) != 0)
3144 last=(size_t) strtol(q+1,&q,10);
3147 if (first < image_info->scene)
3148 image_info->scene=first;
3149 if (last > image_info->number_scenes)
3150 image_info->number_scenes=last;
3153 image_info->number_scenes-=image_info->scene-1;
3154 image_info->subimage=image_info->scene;
3155 image_info->subrange=image_info->number_scenes;
3160 GetPathComponent(image_info->filename,ExtensionPath,extension);
3161 #if defined(MAGICKCORE_ZLIB_DELEGATE)
3162 if (*extension != '\0')
3163 if ((LocaleCompare(extension,"gz") == 0) ||
3164 (LocaleCompare(extension,"Z") == 0) ||
3165 (LocaleCompare(extension,"wmz") == 0))
3168 path[MaxTextExtent];
3170 (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
3171 path[strlen(path)-strlen(extension)-1]='\0';
3172 GetPathComponent(path,ExtensionPath,extension);
3175 #if defined(MAGICKCORE_BZLIB_DELEGATE)
3176 if (*extension != '\0')
3177 if (LocaleCompare(extension,"bz2") == 0)
3180 path[MaxTextExtent];
3182 (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
3183 path[strlen(path)-strlen(extension)-1]='\0';
3184 GetPathComponent(path,ExtensionPath,extension);
3187 image_info->affirm=MagickFalse;
3188 sans_exception=AcquireExceptionInfo();
3189 if (*extension != '\0')
3198 *format_type_formats[] =
3221 User specified image format.
3223 (void) CopyMagickString(magic,extension,MaxTextExtent);
3226 Look for explicit image formats.
3228 format_type=UndefinedFormatType;
3230 while ((format_type == UndefinedFormatType) &&
3231 (format_type_formats[i] != (char *) NULL))
3233 if ((*magic == *format_type_formats[i]) &&
3234 (LocaleCompare(magic,format_type_formats[i]) == 0))
3235 format_type=ExplicitFormatType;
3238 magick_info=GetMagickInfo(magic,sans_exception);
3239 if ((magick_info != (const MagickInfo *) NULL) &&
3240 (magick_info->format_type != UndefinedFormatType))
3241 format_type=magick_info->format_type;
3242 if (format_type == UndefinedFormatType)
3243 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
3245 if (format_type == ExplicitFormatType)
3247 image_info->affirm=MagickTrue;
3248 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
3250 if (LocaleCompare(magic,"RGB") == 0)
3251 image_info->affirm=MagickFalse; /* maybe SGI disguised as RGB */
3254 Look for explicit 'format:image' in filename.
3257 GetPathComponent(image_info->filename,MagickPath,magic);
3259 (void) CopyMagickString(magic,image_info->magick,MaxTextExtent);
3263 User specified image format.
3266 if (IsMagickConflict(magic) == MagickFalse)
3268 (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
3269 if (LocaleCompare(magic,"EPHEMERAL") != 0)
3270 image_info->affirm=MagickTrue;
3272 image_info->temporary=MagickTrue;
3275 magick_info=GetMagickInfo(magic,sans_exception);
3276 sans_exception=DestroyExceptionInfo(sans_exception);
3277 if ((magick_info == (const MagickInfo *) NULL) ||
3278 (GetMagickEndianSupport(magick_info) == MagickFalse))
3279 image_info->endian=UndefinedEndian;
3280 GetPathComponent(image_info->filename,CanonicalPath,filename);
3281 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3282 if ((image_info->adjoin != MagickFalse) && (frames > 1))
3285 Test for multiple image support (e.g. image%02d.png).
3287 (void) InterpretImageFilename(image_info,(Image *) NULL,
3288 image_info->filename,(int) image_info->scene,filename);
3289 if ((LocaleCompare(filename,image_info->filename) != 0) &&
3290 (strchr(filename,'%') == (char *) NULL))
3291 image_info->adjoin=MagickFalse;
3293 if ((image_info->adjoin != MagickFalse) && (frames > 0))
3296 Some image formats do not support multiple frames per file.
3298 magick_info=GetMagickInfo(magic,exception);
3299 if (magick_info != (const MagickInfo *) NULL)
3300 if (GetMagickAdjoin(magick_info) == MagickFalse)
3301 image_info->adjoin=MagickFalse;
3303 if (image_info->affirm != MagickFalse)
3308 Determine the image format from the first few bytes of the file.
3310 image=AcquireImage(image_info);
3311 (void) CopyMagickString(image->filename,image_info->filename,
3313 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
3314 if (status == MagickFalse)
3316 image=DestroyImage(image);
3317 return(MagickFalse);
3319 if ((IsBlobSeekable(image) == MagickFalse) ||
3320 (IsBlobExempt(image) != MagickFalse))
3323 Copy standard input or pipe to temporary file.
3326 status=ImageToFile(image,filename,exception);
3327 (void) CloseBlob(image);
3328 if (status == MagickFalse)
3330 image=DestroyImage(image);
3331 return(MagickFalse);
3333 SetImageInfoFile(image_info,(FILE *) NULL);
3334 (void) CopyMagickString(image->filename,filename,MaxTextExtent);
3335 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
3336 if (status == MagickFalse)
3338 image=DestroyImage(image);
3339 return(MagickFalse);
3341 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
3342 image_info->temporary=MagickTrue;
3344 (void) ResetMagickMemory(magick,0,sizeof(magick));
3345 count=ReadBlob(image,2*MaxTextExtent,magick);
3346 (void) CloseBlob(image);
3347 image=DestroyImage(image);
3349 Check magic.xml configuration file.
3351 sans_exception=AcquireExceptionInfo();
3352 magic_info=GetMagicInfo(magick,(size_t) count,sans_exception);
3353 if ((magic_info != (const MagicInfo *) NULL) &&
3354 (GetMagicName(magic_info) != (char *) NULL))
3356 (void) CopyMagickString(image_info->magick,GetMagicName(magic_info),
3358 magick_info=GetMagickInfo(image_info->magick,sans_exception);
3359 if ((magick_info == (const MagickInfo *) NULL) ||
3360 (GetMagickEndianSupport(magick_info) == MagickFalse))
3361 image_info->endian=UndefinedEndian;
3362 sans_exception=DestroyExceptionInfo(sans_exception);
3365 magick_info=GetMagickInfo(image_info->magick,sans_exception);
3366 if ((magick_info == (const MagickInfo *) NULL) ||
3367 (GetMagickEndianSupport(magick_info) == MagickFalse))
3368 image_info->endian=UndefinedEndian;
3369 sans_exception=DestroyExceptionInfo(sans_exception);
3375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3379 % S e t I m a g e I n f o B l o b %
3383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3385 % SetImageInfoBlob() sets the image info blob member.
3387 % The format of the SetImageInfoBlob method is:
3389 % void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
3390 % const size_t length)
3392 % A description of each parameter follows:
3394 % o image_info: the image info.
3398 % o length: the blob length.
3401 MagickExport void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
3402 const size_t length)
3404 assert(image_info != (ImageInfo *) NULL);
3405 assert(image_info->signature == MagickSignature);
3406 if (image_info->debug != MagickFalse)
3407 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3408 image_info->filename);
3409 image_info->blob=(void *) blob;
3410 image_info->length=length;
3414 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3418 % S e t I m a g e I n f o F i l e %
3422 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3424 % SetImageInfoFile() sets the image info file member.
3426 % The format of the SetImageInfoFile method is:
3428 % void SetImageInfoFile(ImageInfo *image_info,FILE *file)
3430 % A description of each parameter follows:
3432 % o image_info: the image info.
3437 MagickExport void SetImageInfoFile(ImageInfo *image_info,FILE *file)
3439 assert(image_info != (ImageInfo *) NULL);
3440 assert(image_info->signature == MagickSignature);
3441 if (image_info->debug != MagickFalse)
3442 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3443 image_info->filename);
3444 image_info->file=file;
3448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3452 % S e t I m a g e M a s k %
3456 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3458 % SetImageMask() associates a mask with the image. The mask must be the same
3459 % dimensions as the image.
3461 % The format of the SetImageMask method is:
3463 % MagickBooleanType SetImageMask(Image *image,const Image *mask)
3465 % A description of each parameter follows:
3467 % o image: the image.
3469 % o mask: the image mask.
3472 MagickExport MagickBooleanType SetImageMask(Image *image,
3475 assert(image != (Image *) NULL);
3476 if (image->debug != MagickFalse)
3477 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3478 assert(image->signature == MagickSignature);
3479 if (mask != (const Image *) NULL)
3480 if ((mask->columns != image->columns) || (mask->rows != image->rows))
3481 ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
3482 if (image->mask != (Image *) NULL)
3483 image->mask=DestroyImage(image->mask);
3484 image->mask=NewImageList();
3485 if (mask == (Image *) NULL)
3487 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
3488 return(MagickFalse);
3489 image->mask=CloneImage(mask,0,0,MagickTrue,&image->exception);
3490 if (image->mask == (Image *) NULL)
3491 return(MagickFalse);
3496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3500 % S e t I m a g e O p a c i t y %
3504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3506 % SetImageOpacity() sets the opacity levels of the image.
3508 % The format of the SetImageOpacity method is:
3510 % MagickBooleanType SetImageOpacity(Image *image,const Quantum opacity)
3512 % A description of each parameter follows:
3514 % o image: the image.
3516 % o opacity: the level of transparency: 0 is fully opaque and QuantumRange is
3517 % fully transparent.
3520 MagickExport MagickBooleanType SetImageOpacity(Image *image,
3521 const Quantum opacity)
3535 assert(image != (Image *) NULL);
3536 if (image->debug != MagickFalse)
3537 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3538 assert(image->signature == MagickSignature);
3539 image->matte=opacity != OpaqueOpacity ? MagickTrue : MagickFalse;
3541 exception=(&image->exception);
3542 image_view=AcquireCacheView(image);
3543 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3544 #pragma omp parallel for schedule(dynamic,4) shared(status)
3546 for (y=0; y < (ssize_t) image->rows; y++)
3548 register PixelPacket
3554 if (status == MagickFalse)
3556 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3557 if (q == (PixelPacket *) NULL)
3562 for (x=0; x < (ssize_t) image->columns; x++)
3564 SetOpacityPixelComponent(q,opacity);
3567 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3570 image_view=DestroyCacheView(image_view);
3575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3579 % S e t I m a g e T y p e %
3583 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3585 % SetImageType() sets the type of image. Choose from these types:
3587 % Bilevel Grayscale GrayscaleMatte
3588 % Palette PaletteMatte TrueColor
3589 % TrueColorMatte ColorSeparation ColorSeparationMatte
3592 % The format of the SetImageType method is:
3594 % MagickBooleanType SetImageType(Image *image,const ImageType type)
3596 % A description of each parameter follows:
3598 % o image: the image.
3600 % o type: Image type.
3603 MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type)
3617 assert(image != (Image *) NULL);
3618 if (image->debug != MagickFalse)
3619 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3620 assert(image->signature == MagickSignature);
3622 image_info=AcquireImageInfo();
3623 image_info->dither=image->dither;
3624 artifact=GetImageArtifact(image,"dither");
3625 if (artifact != (const char *) NULL)
3626 (void) SetImageOption(image_info,"dither",artifact);
3631 if (IsGrayImage(image,&image->exception) == MagickFalse)
3632 status=TransformImageColorspace(image,GRAYColorspace);
3633 if (IsMonochromeImage(image,&image->exception) == MagickFalse)
3635 quantize_info=AcquireQuantizeInfo(image_info);
3636 quantize_info->number_colors=2;
3637 quantize_info->colorspace=GRAYColorspace;
3638 status=QuantizeImage(quantize_info,image);
3639 quantize_info=DestroyQuantizeInfo(quantize_info);
3641 image->matte=MagickFalse;
3646 if (IsGrayImage(image,&image->exception) == MagickFalse)
3647 status=TransformImageColorspace(image,GRAYColorspace);
3648 image->matte=MagickFalse;
3651 case GrayscaleMatteType:
3653 if (IsGrayImage(image,&image->exception) == MagickFalse)
3654 status=TransformImageColorspace(image,GRAYColorspace);
3655 if (image->matte == MagickFalse)
3656 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
3661 if (image->colorspace != RGBColorspace)
3662 status=TransformImageColorspace(image,RGBColorspace);
3663 if ((image->storage_class == DirectClass) || (image->colors > 256))
3665 quantize_info=AcquireQuantizeInfo(image_info);
3666 quantize_info->number_colors=256;
3667 status=QuantizeImage(quantize_info,image);
3668 quantize_info=DestroyQuantizeInfo(quantize_info);
3670 image->matte=MagickFalse;
3673 case PaletteBilevelMatteType:
3675 if (image->colorspace != RGBColorspace)
3676 status=TransformImageColorspace(image,RGBColorspace);
3677 if (image->matte == MagickFalse)
3678 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
3679 (void) BilevelImageChannel(image,AlphaChannel,(double) QuantumRange/2.0);
3680 quantize_info=AcquireQuantizeInfo(image_info);
3681 status=QuantizeImage(quantize_info,image);
3682 quantize_info=DestroyQuantizeInfo(quantize_info);
3685 case PaletteMatteType:
3687 if (image->colorspace != RGBColorspace)
3688 status=TransformImageColorspace(image,RGBColorspace);
3689 if (image->matte == MagickFalse)
3690 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
3691 quantize_info=AcquireQuantizeInfo(image_info);
3692 quantize_info->colorspace=TransparentColorspace;
3693 status=QuantizeImage(quantize_info,image);
3694 quantize_info=DestroyQuantizeInfo(quantize_info);
3699 if (image->colorspace != RGBColorspace)
3700 status=TransformImageColorspace(image,RGBColorspace);
3701 if (image->storage_class != DirectClass)
3702 status=SetImageStorageClass(image,DirectClass);
3703 image->matte=MagickFalse;
3706 case TrueColorMatteType:
3708 if (image->colorspace != RGBColorspace)
3709 status=TransformImageColorspace(image,RGBColorspace);
3710 if (image->storage_class != DirectClass)
3711 status=SetImageStorageClass(image,DirectClass);
3712 if (image->matte == MagickFalse)
3713 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
3716 case ColorSeparationType:
3718 if (image->colorspace != CMYKColorspace)
3720 if (image->colorspace != RGBColorspace)
3721 status=TransformImageColorspace(image,RGBColorspace);
3722 status=TransformImageColorspace(image,CMYKColorspace);
3724 if (image->storage_class != DirectClass)
3725 status=SetImageStorageClass(image,DirectClass);
3726 image->matte=MagickFalse;
3729 case ColorSeparationMatteType:
3731 if (image->colorspace != CMYKColorspace)
3733 if (image->colorspace != RGBColorspace)
3734 status=TransformImageColorspace(image,RGBColorspace);
3735 status=TransformImageColorspace(image,CMYKColorspace);
3737 if (image->storage_class != DirectClass)
3738 status=SetImageStorageClass(image,DirectClass);
3739 if (image->matte == MagickFalse)
3740 (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
3748 image_info=DestroyImageInfo(image_info);
3753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3757 % S e t I m a g e V i r t u a l P i x e l M e t h o d %
3761 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3763 % SetImageVirtualPixelMethod() sets the "virtual pixels" method for the
3764 % image and returns the previous setting. A virtual pixel is any pixel access
3765 % that is outside the boundaries of the image cache.
3767 % The format of the SetImageVirtualPixelMethod() method is:
3769 % VirtualPixelMethod SetImageVirtualPixelMethod(const Image *image,
3770 % const VirtualPixelMethod virtual_pixel_method)
3772 % A description of each parameter follows:
3774 % o image: the image.
3776 % o virtual_pixel_method: choose the type of virtual pixel.
3779 MagickExport VirtualPixelMethod SetImageVirtualPixelMethod(const Image *image,
3780 const VirtualPixelMethod virtual_pixel_method)
3782 assert(image != (const Image *) NULL);
3783 assert(image->signature == MagickSignature);
3784 if (image->debug != MagickFalse)
3785 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3786 return(SetPixelCacheVirtualMethod(image,virtual_pixel_method));
3790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3794 % S t r i p I m a g e %
3798 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3800 % StripImage() strips an image of all profiles and comments.
3802 % The format of the StripImage method is:
3804 % MagickBooleanType StripImage(Image *image)
3806 % A description of each parameter follows:
3808 % o image: the image.
3811 MagickExport MagickBooleanType StripImage(Image *image)
3813 assert(image != (Image *) NULL);
3814 if (image->debug != MagickFalse)
3815 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3816 DestroyImageProfiles(image);
3817 (void) DeleteImageProperty(image,"comment");
3818 (void) DeleteImageProperty(image,"date:create");
3819 (void) DeleteImageProperty(image,"date:modify");
3824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3828 + S y n c I m a g e %
3832 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3834 % SyncImage() initializes the red, green, and blue intensities of each pixel
3835 % as defined by the colormap index.
3837 % The format of the SyncImage method is:
3839 % MagickBooleanType SyncImage(Image *image)
3841 % A description of each parameter follows:
3843 % o image: the image.
3847 static inline IndexPacket PushColormapIndex(Image *image,
3848 const size_t index,MagickBooleanType *range_exception)
3850 if (index < image->colors)
3851 return((IndexPacket) index);
3852 *range_exception=MagickTrue;
3853 return((IndexPacket) 0);
3856 MagickExport MagickBooleanType SyncImage(Image *image)
3871 assert(image != (Image *) NULL);
3872 if (image->debug != MagickFalse)
3873 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3874 assert(image->signature == MagickSignature);
3875 if (image->storage_class == DirectClass)
3876 return(MagickFalse);
3877 range_exception=MagickFalse;
3879 exception=(&image->exception);
3880 image_view=AcquireCacheView(image);
3881 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3882 #pragma omp parallel for schedule(dynamic,4) shared(status)
3884 for (y=0; y < (ssize_t) image->rows; y++)
3892 register IndexPacket
3895 register PixelPacket
3901 if (status == MagickFalse)
3903 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3904 if (q == (PixelPacket *) NULL)
3909 indexes=GetCacheViewAuthenticIndexQueue(image_view);
3910 for (x=0; x < (ssize_t) image->columns; x++)
3912 index=PushColormapIndex(image,(size_t) indexes[x],
3914 pixel=image->colormap[(ssize_t) index];
3916 q->green=pixel.green;
3918 if (image->matte != MagickFalse)
3919 q->opacity=pixel.opacity;
3922 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3925 image_view=DestroyCacheView(image_view);
3926 if (range_exception != MagickFalse)
3927 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3928 CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
3933 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3937 % S y n c I m a g e S e t t i n g s %
3941 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3943 % SyncImageSettings() sync the image info options to the image.
3945 % The format of the SyncImageSettings method is:
3947 % MagickBooleanType SyncImageSettings(const ImageInfo *image_info,
3949 % MagickBooleanType SyncImagesSettings(const ImageInfo *image_info,
3952 % A description of each parameter follows:
3954 % o image_info: the image info.
3956 % o image: the image.
3960 MagickExport MagickBooleanType SyncImagesSettings(ImageInfo *image_info,
3966 assert(image_info != (const ImageInfo *) NULL);
3967 assert(image_info->signature == MagickSignature);
3968 assert(images != (Image *) NULL);
3969 assert(images->signature == MagickSignature);
3970 if (images->debug != MagickFalse)
3971 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3973 for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
3974 (void) SyncImageSettings(image_info,image);
3975 (void) DeleteImageOption(image_info,"page");
3979 MagickExport MagickBooleanType SyncImageSettings(const ImageInfo *image_info,
3983 property[MaxTextExtent];
4001 assert(image_info != (const ImageInfo *) NULL);
4002 assert(image_info->signature == MagickSignature);
4003 assert(image != (Image *) NULL);
4004 assert(image->signature == MagickSignature);
4005 if (image->debug != MagickFalse)
4006 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4007 option=GetImageOption(image_info,"background");
4008 if (option != (const char *) NULL)
4009 (void) QueryColorDatabase(option,&image->background_color,
4011 option=GetImageOption(image_info,"bias");
4012 if (option != (const char *) NULL)
4013 image->bias=SiPrefixToDouble(option,QuantumRange);
4014 option=GetImageOption(image_info,"black-point-compensation");
4015 if (option != (const char *) NULL)
4016 image->black_point_compensation=(MagickBooleanType) ParseMagickOption(
4017 MagickBooleanOptions,MagickFalse,option);
4018 option=GetImageOption(image_info,"blue-primary");
4019 if (option != (const char *) NULL)
4021 flags=ParseGeometry(option,&geometry_info);
4022 image->chromaticity.blue_primary.x=geometry_info.rho;
4023 image->chromaticity.blue_primary.y=geometry_info.sigma;
4024 if ((flags & SigmaValue) == 0)
4025 image->chromaticity.blue_primary.y=image->chromaticity.blue_primary.x;
4027 option=GetImageOption(image_info,"bordercolor");
4028 if (option != (const char *) NULL)
4029 (void) QueryColorDatabase(option,&image->border_color,&image->exception);
4030 option=GetImageOption(image_info,"colors");
4031 if (option != (const char *) NULL)
4032 image->colors=StringToUnsignedLong(option);
4033 option=GetImageOption(image_info,"compose");
4034 if (option != (const char *) NULL)
4035 image->compose=(CompositeOperator) ParseMagickOption(MagickComposeOptions,
4036 MagickFalse,option);
4037 option=GetImageOption(image_info,"compress");
4038 if (option != (const char *) NULL)
4039 image->compression=(CompressionType) ParseMagickOption(
4040 MagickCompressOptions,MagickFalse,option);
4041 option=GetImageOption(image_info,"debug");
4042 if (option != (const char *) NULL)
4043 image->debug=(MagickBooleanType) ParseMagickOption(MagickBooleanOptions,
4044 MagickFalse,option);
4045 option=GetImageOption(image_info,"density");
4046 if (option != (const char *) NULL)
4054 flags=ParseGeometry(option,&geometry_info);
4055 image->x_resolution=geometry_info.rho;
4056 image->y_resolution=geometry_info.sigma;
4057 if ((flags & SigmaValue) == 0)
4058 image->y_resolution=image->x_resolution;
4060 option=GetImageOption(image_info,"depth");
4061 if (option != (const char *) NULL)
4062 image->depth=StringToUnsignedLong(option);
4063 option=GetImageOption(image_info,"endian");
4064 if (option != (const char *) NULL)
4065 image->endian=(EndianType) ParseMagickOption(MagickEndianOptions,
4066 MagickFalse,option);
4067 if (image_info->extract != (char *) NULL)
4068 (void) ParseAbsoluteGeometry(image_info->extract,&image->extract_info);
4069 option=GetImageOption(image_info,"filter");
4070 if (option != (const char *) NULL)
4071 image->filter=(FilterTypes) ParseMagickOption(MagickFilterOptions,
4072 MagickFalse,option);
4073 option=GetImageOption(image_info,"fuzz");
4074 if (option != (const char *) NULL)
4075 image->fuzz=SiPrefixToDouble(option,QuantumRange);
4076 option=GetImageOption(image_info,"gravity");
4077 if (option != (const char *) NULL)
4078 image->gravity=(GravityType) ParseMagickOption(MagickGravityOptions,
4079 MagickFalse,option);
4080 option=GetImageOption(image_info,"green-primary");
4081 if (option != (const char *) NULL)
4083 flags=ParseGeometry(option,&geometry_info);
4084 image->chromaticity.green_primary.x=geometry_info.rho;
4085 image->chromaticity.green_primary.y=geometry_info.sigma;
4086 if ((flags & SigmaValue) == 0)
4087 image->chromaticity.green_primary.y=image->chromaticity.green_primary.x;
4089 option=GetImageOption(image_info,"intent");
4090 if (option != (const char *) NULL)
4091 image->rendering_intent=(RenderingIntent) ParseMagickOption(
4092 MagickIntentOptions,MagickFalse,option);
4093 option=GetImageOption(image_info,"interlace");
4094 if (option != (const char *) NULL)
4095 image->interlace=(InterlaceType) ParseMagickOption(MagickInterlaceOptions,
4096 MagickFalse,option);
4097 option=GetImageOption(image_info,"interpolate");
4098 if (option != (const char *) NULL)
4099 image->interpolate=(InterpolatePixelMethod) ParseMagickOption(
4100 MagickInterpolateOptions,MagickFalse,option);
4101 option=GetImageOption(image_info,"loop");
4102 if (option != (const char *) NULL)
4103 image->iterations=StringToUnsignedLong(option);
4104 option=GetImageOption(image_info,"mattecolor");
4105 if (option != (const char *) NULL)
4106 (void) QueryColorDatabase(option,&image->matte_color,&image->exception);
4107 option=GetImageOption(image_info,"orient");
4108 if (option != (const char *) NULL)
4109 image->orientation=(OrientationType) ParseMagickOption(
4110 MagickOrientationOptions,MagickFalse,option);
4111 option=GetImageOption(image_info,"page");
4112 if (option != (const char *) NULL)
4117 geometry=GetPageGeometry(option);
4118 flags=ParseAbsoluteGeometry(geometry,&image->page);
4119 geometry=DestroyString(geometry);
4121 option=GetImageOption(image_info,"quality");
4122 if (option != (const char *) NULL)
4123 image->quality=StringToUnsignedLong(option);
4124 option=GetImageOption(image_info,"red-primary");
4125 if (option != (const char *) NULL)
4127 flags=ParseGeometry(option,&geometry_info);
4128 image->chromaticity.red_primary.x=geometry_info.rho;
4129 image->chromaticity.red_primary.y=geometry_info.sigma;
4130 if ((flags & SigmaValue) == 0)
4131 image->chromaticity.red_primary.y=image->chromaticity.red_primary.x;
4133 if (image_info->quality != UndefinedCompressionQuality)
4134 image->quality=image_info->quality;
4135 option=GetImageOption(image_info,"scene");
4136 if (option != (const char *) NULL)
4137 image->scene=StringToUnsignedLong(option);
4138 option=GetImageOption(image_info,"taint");
4139 if (option != (const char *) NULL)
4140 image->taint=(MagickBooleanType) ParseMagickOption(MagickBooleanOptions,
4141 MagickFalse,option);
4142 option=GetImageOption(image_info,"tile-offset");
4143 if (option != (const char *) NULL)
4148 geometry=GetPageGeometry(option);
4149 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4150 geometry=DestroyString(geometry);
4152 option=GetImageOption(image_info,"transparent-color");
4153 if (option != (const char *) NULL)
4154 (void) QueryColorDatabase(option,&image->transparent_color,
4156 option=GetImageOption(image_info,"type");
4157 if (option != (const char *) NULL)
4158 image->type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse,
4160 option=GetImageOption(image_info,"units");
4161 if (option != (const char *) NULL)
4162 units=(ResolutionType) ParseMagickOption(MagickResolutionOptions,
4163 MagickFalse,option);
4165 units = image_info->units;
4166 if (units != UndefinedResolution)
4168 if (image->units != units)
4169 switch (image->units)
4171 case PixelsPerInchResolution:
4173 if (units == PixelsPerCentimeterResolution)
4175 image->x_resolution/=2.54;
4176 image->y_resolution/=2.54;
4180 case PixelsPerCentimeterResolution:
4182 if (units == PixelsPerInchResolution)
4184 image->x_resolution=(double) ((size_t) (100.0*2.54*
4185 image->x_resolution+0.5))/100.0;
4186 image->y_resolution=(double) ((size_t) (100.0*2.54*
4187 image->y_resolution+0.5))/100.0;
4196 option=GetImageOption(image_info,"white-point");
4197 if (option != (const char *) NULL)
4199 flags=ParseGeometry(option,&geometry_info);
4200 image->chromaticity.white_point.x=geometry_info.rho;
4201 image->chromaticity.white_point.y=geometry_info.sigma;
4202 if ((flags & SigmaValue) == 0)
4203 image->chromaticity.white_point.y=image->chromaticity.white_point.x;
4205 ResetImageOptionIterator(image_info);
4206 for (option=GetNextImageOption(image_info); option != (const char *) NULL; )
4208 value=GetImageOption(image_info,option);
4209 if (value != (const char *) NULL)
4211 (void) FormatMagickString(property,MaxTextExtent,"%s",option);
4212 (void) SetImageArtifact(image,property,value);
4214 option=GetNextImageOption(image_info);