MagickCore  6.8.9
image.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % IIIII M M AAA GGGG EEEEE %
7 % I MM MM A A G E %
8 % I M M M AAAAA G GG EEE %
9 % I M M A A G G E %
10 % IIIII M M A A GGGG EEEEE %
11 % %
12 % %
13 % MagickCore Image Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % July 1992 %
18 % %
19 % %
20 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
22 % %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
25 % %
26 % http://www.imagemagick.org/script/license.php %
27 % %
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. %
33 % %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 %
38 */
39 
40 /*
41  Include declarations.
42 */
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/channel.h"
52 #include "magick/client.h"
53 #include "magick/color.h"
54 #include "magick/color-private.h"
55 #include "magick/colormap.h"
56 #include "magick/colorspace.h"
58 #include "magick/composite.h"
60 #include "magick/compress.h"
61 #include "magick/constitute.h"
62 #include "magick/deprecate.h"
63 #include "magick/display.h"
64 #include "magick/draw.h"
65 #include "magick/enhance.h"
66 #include "magick/exception.h"
68 #include "magick/gem.h"
69 #include "magick/geometry.h"
70 #include "magick/histogram.h"
71 #include "magick/image-private.h"
72 #include "magick/list.h"
73 #include "magick/magic.h"
74 #include "magick/magick.h"
75 #include "magick/memory_.h"
76 #include "magick/module.h"
77 #include "magick/monitor.h"
78 #include "magick/monitor-private.h"
79 #include "magick/option.h"
80 #include "magick/paint.h"
81 #include "magick/pixel-accessor.h"
82 #include "magick/pixel-private.h"
83 #include "magick/profile.h"
84 #include "magick/property.h"
85 #include "magick/quantize.h"
86 #include "magick/random_.h"
87 #include "magick/resource_.h"
88 #include "magick/segment.h"
89 #include "magick/semaphore.h"
91 #include "magick/statistic.h"
92 #include "magick/string_.h"
93 #include "magick/string-private.h"
94 #include "magick/thread-private.h"
95 #include "magick/threshold.h"
96 #include "magick/timer.h"
97 #include "magick/token.h"
98 #include "magick/utility.h"
99 #include "magick/version.h"
100 #include "magick/xwindow-private.h"
101 
102 /*
103  Constant declaration.
104 */
105 const char
106  BackgroundColor[] = "#ffffff", /* white */
107  BorderColor[] = "#dfdfdf", /* gray */
108  DefaultTileFrame[] = "15x15+3+3",
109  DefaultTileGeometry[] = "120x120+4+3>",
110  DefaultTileLabel[] = "%f\n%G\n%b",
111  ForegroundColor[] = "#000", /* black */
112  LoadImageTag[] = "Load/Image",
113  LoadImagesTag[] = "Load/Images",
114  MatteColor[] = "#bdbdbd", /* gray */
115  PSDensityGeometry[] = "72.0x72.0",
116  PSPageGeometry[] = "612x792",
117  SaveImageTag[] = "Save/Image",
118  SaveImagesTag[] = "Save/Images",
119  TransparentColor[] = "#00000000"; /* transparent black */
120 
121 const double
123 
124 /*
125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126 % %
127 % %
128 % %
129 % A c q u i r e I m a g e %
130 % %
131 % %
132 % %
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 %
135 % AcquireImage() returns a pointer to an image structure initialized to
136 % default values.
137 %
138 % The format of the AcquireImage method is:
139 %
140 % Image *AcquireImage(const ImageInfo *image_info)
141 %
142 % A description of each parameter follows:
143 %
144 % o image_info: Many of the image default values are set from this
145 % structure. For example, filename, compression, depth, background color,
146 % and others.
147 %
148 */
150 {
151  const char
152  *option;
153 
154  Image
155  *image;
156 
158  flags;
159 
160  /*
161  Allocate image structure.
162  */
163  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
164  image=(Image *) AcquireMagickMemory(sizeof(*image));
165  if (image == (Image *) NULL)
166  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
167  (void) ResetMagickMemory(image,0,sizeof(*image));
168  /*
169  Initialize Image structure.
170  */
171  (void) CopyMagickString(image->magick,"MIFF",MaxTextExtent);
172  image->storage_class=DirectClass;
174  image->colorspace=sRGBColorspace;
176  image->gamma=1.000f/2.200f;
177  image->chromaticity.red_primary.x=0.6400f;
178  image->chromaticity.red_primary.y=0.3300f;
179  image->chromaticity.red_primary.z=0.0300f;
180  image->chromaticity.green_primary.x=0.3000f;
181  image->chromaticity.green_primary.y=0.6000f;
182  image->chromaticity.green_primary.z=0.1000f;
183  image->chromaticity.blue_primary.x=0.1500f;
184  image->chromaticity.blue_primary.y=0.0600f;
185  image->chromaticity.blue_primary.z=0.7900f;
186  image->chromaticity.white_point.x=0.3127f;
187  image->chromaticity.white_point.y=0.3290f;
188  image->chromaticity.white_point.z=0.3583f;
189  image->interlace=NoInterlace;
191  image->compose=OverCompositeOp;
192  image->blur=1.0;
193  GetExceptionInfo(&image->exception);
195  &image->exception);
196  (void) QueryColorDatabase(BorderColor,&image->border_color,&image->exception);
197  (void) QueryColorDatabase(MatteColor,&image->matte_color,&image->exception);
199  &image->exception);
200  GetTimerInfo(&image->timer);
201  image->ping=MagickFalse;
202  image->cache=AcquirePixelCache(0);
203  image->blob=CloneBlobInfo((BlobInfo *) NULL);
204  image->timestamp=time((time_t *) NULL);
205  image->debug=IsEventLogging();
206  image->reference_count=1;
208  image->signature=MagickSignature;
209  if (image_info == (ImageInfo *) NULL)
210  return(image);
211  /*
212  Transfer image info.
213  */
214  SetBlobExempt(image,image_info->file != (FILE *) NULL ? MagickTrue :
215  MagickFalse);
216  (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
217  (void) CopyMagickString(image->magick_filename,image_info->filename,
218  MaxTextExtent);
219  (void) CopyMagickString(image->magick,image_info->magick,MaxTextExtent);
220  if (image_info->size != (char *) NULL)
221  {
222  (void) ParseAbsoluteGeometry(image_info->size,&image->extract_info);
223  image->columns=image->extract_info.width;
224  image->rows=image->extract_info.height;
225  image->offset=image->extract_info.x;
226  image->extract_info.x=0;
227  image->extract_info.y=0;
228  }
229  if (image_info->extract != (char *) NULL)
230  {
232  geometry;
233 
234  flags=ParseAbsoluteGeometry(image_info->extract,&geometry);
235  if (((flags & XValue) != 0) || ((flags & YValue) != 0))
236  {
237  image->extract_info=geometry;
238  Swap(image->columns,image->extract_info.width);
239  Swap(image->rows,image->extract_info.height);
240  }
241  }
242  image->compression=image_info->compression;
243  image->quality=image_info->quality;
244  image->endian=image_info->endian;
245  image->interlace=image_info->interlace;
246  image->units=image_info->units;
247  if (image_info->density != (char *) NULL)
248  {
250  geometry_info;
251 
252  flags=ParseGeometry(image_info->density,&geometry_info);
253  image->x_resolution=geometry_info.rho;
254  image->y_resolution=geometry_info.sigma;
255  if ((flags & SigmaValue) == 0)
256  image->y_resolution=image->x_resolution;
257  }
258  if (image_info->page != (char *) NULL)
259  {
260  char
261  *geometry;
262 
263  image->page=image->extract_info;
264  geometry=GetPageGeometry(image_info->page);
265  (void) ParseAbsoluteGeometry(geometry,&image->page);
266  geometry=DestroyString(geometry);
267  }
268  if (image_info->depth != 0)
269  image->depth=image_info->depth;
270  image->dither=image_info->dither;
271  image->background_color=image_info->background_color;
272  image->border_color=image_info->border_color;
273  image->matte_color=image_info->matte_color;
274  image->transparent_color=image_info->transparent_color;
275  image->ping=image_info->ping;
276  image->progress_monitor=image_info->progress_monitor;
277  image->client_data=image_info->client_data;
278  if (image_info->cache != (void *) NULL)
279  ClonePixelCacheMethods(image->cache,image_info->cache);
280  (void) SyncImageSettings(image_info,image);
281  option=GetImageOption(image_info,"delay");
282  if (option != (const char *) NULL)
283  {
285  geometry_info;
286 
287  flags=ParseGeometry(option,&geometry_info);
288  if ((flags & GreaterValue) != 0)
289  {
290  if (image->delay > (size_t) floor(geometry_info.rho+0.5))
291  image->delay=(size_t) floor(geometry_info.rho+0.5);
292  }
293  else
294  if ((flags & LessValue) != 0)
295  {
296  if (image->delay < (size_t) floor(geometry_info.rho+0.5))
297  image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
298  }
299  else
300  image->delay=(size_t) floor(geometry_info.rho+0.5);
301  if ((flags & SigmaValue) != 0)
302  image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
303  }
304  option=GetImageOption(image_info,"dispose");
305  if (option != (const char *) NULL)
307  MagickFalse,option);
308  return(image);
309 }
310 
311 /*
312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
313 % %
314 % %
315 % %
316 % A c q u i r e I m a g e I n f o %
317 % %
318 % %
319 % %
320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
321 %
322 % AcquireImageInfo() allocates the ImageInfo structure.
323 %
324 % The format of the AcquireImageInfo method is:
325 %
326 % ImageInfo *AcquireImageInfo(void)
327 %
328 */
330 {
331  ImageInfo
332  *image_info;
333 
334  image_info=(ImageInfo *) AcquireMagickMemory(sizeof(*image_info));
335  if (image_info == (ImageInfo *) NULL)
336  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
337  GetImageInfo(image_info);
338  return(image_info);
339 }
340 
341 /*
342 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
343 % %
344 % %
345 % %
346 % A c q u i r e N e x t I m a g e %
347 % %
348 % %
349 % %
350 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
351 %
352 % AcquireNextImage() initializes the next image in a sequence to
353 % default values. The next member of image points to the newly allocated
354 % image. If there is a memory shortage, next is assigned NULL.
355 %
356 % The format of the AcquireNextImage method is:
357 %
358 % void AcquireNextImage(const ImageInfo *image_info,Image *image)
359 %
360 % A description of each parameter follows:
361 %
362 % o image_info: Many of the image default values are set from this
363 % structure. For example, filename, compression, depth, background color,
364 % and others.
365 %
366 % o image: the image.
367 %
368 */
370 {
371  /*
372  Allocate image structure.
373  */
374  assert(image != (Image *) NULL);
375  assert(image->signature == MagickSignature);
376  if (image->debug != MagickFalse)
377  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
378  image->next=AcquireImage(image_info);
379  if (GetNextImageInList(image) == (Image *) NULL)
380  return;
382  MaxTextExtent);
383  if (image_info != (ImageInfo *) NULL)
384  (void) CopyMagickString(GetNextImageInList(image)->filename,
385  image_info->filename,MaxTextExtent);
387  image->next->blob=ReferenceBlob(image->blob);
388  image->next->endian=image->endian;
389  image->next->scene=image->scene+1;
390  image->next->previous=image;
391 }
392 
393 /*
394 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
395 % %
396 % %
397 % %
398 % A p p e n d I m a g e s %
399 % %
400 % %
401 % %
402 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
403 %
404 % AppendImages() takes all images from the current image pointer to the end
405 % of the image list and appends them to each other top-to-bottom if the
406 % stack parameter is true, otherwise left-to-right.
407 %
408 % The current gravity setting now effects how the image is justified in the
409 % final image.
410 %
411 % The format of the AppendImages method is:
412 %
413 % Image *AppendImages(const Image *images,const MagickBooleanType stack,
414 % ExceptionInfo *exception)
415 %
416 % A description of each parameter follows:
417 %
418 % o images: the image sequence.
419 %
420 % o stack: A value other than 0 stacks the images top-to-bottom.
421 %
422 % o exception: return any errors or warnings in this structure.
423 %
424 */
427 {
428 #define AppendImageTag "Append/Image"
429 
430  CacheView
431  *append_view;
432 
433  Image
434  *append_image;
435 
437  matte,
438  status;
439 
441  n;
442 
444  geometry;
445 
446  register const Image
447  *next;
448 
449  size_t
450  height,
451  number_images,
452  width;
453 
454  ssize_t
455  x_offset,
456  y,
457  y_offset;
458 
459  /*
460  Compute maximum area of appended area.
461  */
462  assert(images != (Image *) NULL);
463  assert(images->signature == MagickSignature);
464  if (images->debug != MagickFalse)
465  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
466  assert(exception != (ExceptionInfo *) NULL);
467  assert(exception->signature == MagickSignature);
468  matte=images->matte;
469  number_images=1;
470  width=images->columns;
471  height=images->rows;
472  next=GetNextImageInList(images);
473  for ( ; next != (Image *) NULL; next=GetNextImageInList(next))
474  {
475  if (next->matte != MagickFalse)
476  matte=MagickTrue;
477  number_images++;
478  if (stack != MagickFalse)
479  {
480  if (next->columns > width)
481  width=next->columns;
482  height+=next->rows;
483  continue;
484  }
485  width+=next->columns;
486  if (next->rows > height)
487  height=next->rows;
488  }
489  /*
490  Append images.
491  */
492  append_image=CloneImage(images,width,height,MagickTrue,exception);
493  if (append_image == (Image *) NULL)
494  return((Image *) NULL);
495  if (SetImageStorageClass(append_image,DirectClass) == MagickFalse)
496  {
497  InheritException(exception,&append_image->exception);
498  append_image=DestroyImage(append_image);
499  return((Image *) NULL);
500  }
501  append_image->matte=matte;
502  (void) SetImageBackgroundColor(append_image);
503  status=MagickTrue;
504  x_offset=0;
505  y_offset=0;
506  next=images;
507  append_view=AcquireAuthenticCacheView(append_image,exception);
508  for (n=0; n < (MagickOffsetType) number_images; n++)
509  {
510  CacheView
511  *image_view;
512 
513  Image
514  *image;
515 
517  proceed;
518 
519  image=CloneImage(next,0,0,MagickTrue,exception);
520  if (image == (Image *) NULL)
521  break;
522  status=TransformImageColorspace(image,append_image->colorspace);
523  if (status == MagickFalse)
524  break;
525  SetGeometry(append_image,&geometry);
526  GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
527  if (stack != MagickFalse)
528  x_offset-=geometry.x;
529  else
530  y_offset-=geometry.y;
531  image_view=AcquireVirtualCacheView(image,exception);
532 #if defined(MAGICKCORE_OPENMP_SUPPORT)
533  #pragma omp parallel for schedule(static,4) shared(status) \
534  magick_threads(image,image,image->rows,1)
535 #endif
536  for (y=0; y < (ssize_t) image->rows; y++)
537  {
539  sync;
540 
541  register const IndexPacket
542  *restrict indexes;
543 
544  register const PixelPacket
545  *restrict p;
546 
547  register IndexPacket
548  *restrict append_indexes;
549 
550  register PixelPacket
551  *restrict q;
552 
553  register ssize_t
554  x;
555 
556  if (status == MagickFalse)
557  continue;
558  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
559  q=QueueCacheViewAuthenticPixels(append_view,x_offset,y+y_offset,
560  image->columns,1,exception);
561  if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
562  {
563  status=MagickFalse;
564  continue;
565  }
566  indexes=GetCacheViewVirtualIndexQueue(image_view);
567  append_indexes=GetCacheViewAuthenticIndexQueue(append_view);
568  for (x=0; x < (ssize_t) image->columns; x++)
569  {
570  SetPixelRed(q,GetPixelRed(p));
574  if (image->matte != MagickFalse)
576  if ((image->colorspace == CMYKColorspace) &&
577  (append_image->colorspace == CMYKColorspace))
578  SetPixelIndex(append_indexes+x,GetPixelIndex(indexes+x));
579  p++;
580  q++;
581  }
582  sync=SyncCacheViewAuthenticPixels(append_view,exception);
583  if (sync == MagickFalse)
584  status=MagickFalse;
585  }
586  image_view=DestroyCacheView(image_view);
587  if (stack == MagickFalse)
588  {
589  x_offset+=(ssize_t) image->columns;
590  y_offset=0;
591  }
592  else
593  {
594  x_offset=0;
595  y_offset+=(ssize_t) image->rows;
596  }
597  image=DestroyImage(image);
598  proceed=SetImageProgress(append_image,AppendImageTag,n,number_images);
599  if (proceed == MagickFalse)
600  break;
601  next=GetNextImageInList(next);
602  }
603  append_view=DestroyCacheView(append_view);
604  if (status == MagickFalse)
605  append_image=DestroyImage(append_image);
606  return(append_image);
607 }
608 
609 /*
610 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
611 % %
612 % %
613 % %
614 % C a t c h I m a g e E x c e p t i o n %
615 % %
616 % %
617 % %
618 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 %
620 % CatchImageException() returns if no exceptions are found in the image
621 % sequence, otherwise it determines the most severe exception and reports
622 % it as a warning or error depending on the severity.
623 %
624 % The format of the CatchImageException method is:
625 %
626 % ExceptionType CatchImageException(Image *image)
627 %
628 % A description of each parameter follows:
629 %
630 % o image: An image sequence.
631 %
632 */
634 {
636  *exception;
637 
639  severity;
640 
641  assert(image != (const Image *) NULL);
642  assert(image->signature == MagickSignature);
643  if (image->debug != MagickFalse)
644  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
645  exception=AcquireExceptionInfo();
646  GetImageException(image,exception);
647  CatchException(exception);
648  severity=exception->severity;
649  exception=DestroyExceptionInfo(exception);
650  return(severity);
651 }
652 
653 /*
654 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
655 % %
656 % %
657 % %
658 % C l i p I m a g e P a t h %
659 % %
660 % %
661 % %
662 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
663 %
664 % ClipImagePath() sets the image clip mask based any clipping path information
665 % if it exists.
666 %
667 % The format of the ClipImagePath method is:
668 %
669 % MagickBooleanType ClipImagePath(Image *image,const char *pathname,
670 % const MagickBooleanType inside)
671 %
672 % A description of each parameter follows:
673 %
674 % o image: the image.
675 %
676 % o pathname: name of clipping path resource. If name is preceded by #, use
677 % clipping path numbered by name.
678 %
679 % o inside: if non-zero, later operations take effect inside clipping path.
680 % Otherwise later operations take effect outside clipping path.
681 %
682 */
683 
685 {
686  return(ClipImagePath(image,"#1",MagickTrue));
687 }
688 
690  const MagickBooleanType inside)
691 {
692 #define ClipImagePathTag "ClipPath/Image"
693 
694  char
695  *property;
696 
697  const char
698  *value;
699 
700  Image
701  *clip_mask;
702 
703  ImageInfo
704  *image_info;
705 
706  assert(image != (const Image *) NULL);
707  assert(image->signature == MagickSignature);
708  if (image->debug != MagickFalse)
709  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
710  assert(pathname != NULL);
711  property=AcquireString(pathname);
712  (void) FormatLocaleString(property,MaxTextExtent,"8BIM:1999,2998:%s",
713  pathname);
714  value=GetImageProperty(image,property);
715  property=DestroyString(property);
716  if (value == (const char *) NULL)
717  {
718  ThrowFileException(&image->exception,OptionError,"NoClipPathDefined",
719  image->filename);
720  return(MagickFalse);
721  }
722  image_info=AcquireImageInfo();
723  (void) CopyMagickString(image_info->filename,image->filename,MaxTextExtent);
724  (void) ConcatenateMagickString(image_info->filename,pathname,MaxTextExtent);
725  clip_mask=BlobToImage(image_info,value,strlen(value),&image->exception);
726  image_info=DestroyImageInfo(image_info);
727  if (clip_mask == (Image *) NULL)
728  return(MagickFalse);
729  if (clip_mask->storage_class == PseudoClass)
730  {
731  (void) SyncImage(clip_mask);
732  if (SetImageStorageClass(clip_mask,DirectClass) == MagickFalse)
733  return(MagickFalse);
734  }
735  if (inside == MagickFalse)
736  (void) NegateImage(clip_mask,MagickFalse);
738  "8BIM:1999,2998:%s\nPS",pathname);
739  (void) SetImageClipMask(image,clip_mask);
740  clip_mask=DestroyImage(clip_mask);
741  return(MagickTrue);
742 }
743 
744 /*
745 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
746 % %
747 % %
748 % %
749 % C l o n e I m a g e %
750 % %
751 % %
752 % %
753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
754 %
755 % CloneImage() copies an image and returns the copy as a new image object.
756 %
757 % If the specified columns and rows is 0, an exact copy of the image is
758 % returned, otherwise the pixel data is undefined and must be initialized
759 % with the QueueAuthenticPixels() and SyncAuthenticPixels() methods. On
760 % failure, a NULL image is returned and exception describes the reason for the
761 % failure.
762 %
763 % The format of the CloneImage method is:
764 %
765 % Image *CloneImage(const Image *image,const size_t columns,
766 % const size_t rows,const MagickBooleanType orphan,
767 % ExceptionInfo *exception)
768 %
769 % A description of each parameter follows:
770 %
771 % o image: the image.
772 %
773 % o columns: the number of columns in the cloned image.
774 %
775 % o rows: the number of rows in the cloned image.
776 %
777 % o detach: With a value other than 0, the cloned image is detached from
778 % its parent I/O stream.
779 %
780 % o exception: return any errors or warnings in this structure.
781 %
782 */
783 MagickExport Image *CloneImage(const Image *image,const size_t columns,
784  const size_t rows,const MagickBooleanType detach,ExceptionInfo *exception)
785 {
786  double
787  scale;
788 
789  Image
790  *clone_image;
791 
792  size_t
793  length;
794 
795  /*
796  Clone the image.
797  */
798  assert(image != (const Image *) NULL);
799  assert(image->signature == MagickSignature);
800  if (image->debug != MagickFalse)
801  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
802  assert(exception != (ExceptionInfo *) NULL);
803  assert(exception->signature == MagickSignature);
804  clone_image=(Image *) AcquireMagickMemory(sizeof(*clone_image));
805  if (clone_image == (Image *) NULL)
806  ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
807  (void) ResetMagickMemory(clone_image,0,sizeof(*clone_image));
808  clone_image->signature=MagickSignature;
809  clone_image->storage_class=image->storage_class;
810  clone_image->channels=image->channels;
811  clone_image->colorspace=image->colorspace;
812  clone_image->matte=image->matte;
813  clone_image->columns=image->columns;
814  clone_image->rows=image->rows;
815  clone_image->dither=image->dither;
816  if (image->colormap != (PixelPacket *) NULL)
817  {
818  /*
819  Allocate and copy the image colormap.
820  */
821  clone_image->colors=image->colors;
822  length=(size_t) image->colors;
823  clone_image->colormap=(PixelPacket *) AcquireQuantumMemory(length,
824  sizeof(*clone_image->colormap));
825  if (clone_image->colormap == (PixelPacket *) NULL)
826  ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
827  (void) CopyMagickMemory(clone_image->colormap,image->colormap,length*
828  sizeof(*clone_image->colormap));
829  }
830  (void) CloneImageProfiles(clone_image,image);
831  (void) CloneImageProperties(clone_image,image);
832  (void) CloneImageArtifacts(clone_image,image);
833  GetTimerInfo(&clone_image->timer);
834  GetExceptionInfo(&clone_image->exception);
835  InheritException(&clone_image->exception,&image->exception);
836  if (image->ascii85 != (void *) NULL)
837  Ascii85Initialize(clone_image);
838  clone_image->magick_columns=image->magick_columns;
839  clone_image->magick_rows=image->magick_rows;
840  clone_image->type=image->type;
841  (void) CopyMagickString(clone_image->magick_filename,image->magick_filename,
842  MaxTextExtent);
843  (void) CopyMagickString(clone_image->magick,image->magick,MaxTextExtent);
844  (void) CopyMagickString(clone_image->filename,image->filename,MaxTextExtent);
845  clone_image->progress_monitor=image->progress_monitor;
846  clone_image->client_data=image->client_data;
847  clone_image->reference_count=1;
848  clone_image->next=image->next;
849  clone_image->previous=image->previous;
850  clone_image->list=NewImageList();
851  clone_image->clip_mask=NewImageList();
852  clone_image->mask=NewImageList();
853  if (detach == MagickFalse)
854  clone_image->blob=ReferenceBlob(image->blob);
855  else
856  {
857  clone_image->next=NewImageList();
858  clone_image->previous=NewImageList();
859  clone_image->blob=CloneBlobInfo((BlobInfo *) NULL);
860  }
861  clone_image->ping=image->ping;
862  clone_image->debug=IsEventLogging();
863  clone_image->semaphore=AllocateSemaphoreInfo();
864  if ((columns == 0) && (rows == 0))
865  {
866  if (image->montage != (char *) NULL)
867  (void) CloneString(&clone_image->montage,image->montage);
868  if (image->directory != (char *) NULL)
869  (void) CloneString(&clone_image->directory,image->directory);
870  if (image->clip_mask != (Image *) NULL)
871  clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
872  exception);
873  if (image->mask != (Image *) NULL)
874  clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
875  clone_image->cache=ReferencePixelCache(image->cache);
876  return(clone_image);
877  }
878  if ((columns == image->columns) && (rows == image->rows))
879  {
880  if (image->clip_mask != (Image *) NULL)
881  clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
882  exception);
883  if (image->mask != (Image *) NULL)
884  clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
885  }
886  scale=(double) columns/(double) image->columns;
887  clone_image->page.width=(size_t) floor(scale*image->page.width+0.5);
888  clone_image->page.x=(ssize_t) ceil(scale*image->page.x-0.5);
889  clone_image->tile_offset.x=(ssize_t) ceil(scale*image->tile_offset.x-0.5);
890  scale=(double) rows/(double) image->rows;
891  clone_image->page.height=(size_t) floor(scale*image->page.height+0.5);
892  clone_image->page.y=(ssize_t) ceil(scale*image->page.y-0.5);
893  clone_image->tile_offset.y=(ssize_t) ceil(scale*image->tile_offset.y-0.5);
894  clone_image->columns=columns;
895  clone_image->rows=rows;
896  clone_image->cache=ClonePixelCache(image->cache);
897  return(clone_image);
898 }
899 
900 /*
901 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
902 % %
903 % %
904 % %
905 % C l o n e I m a g e I n f o %
906 % %
907 % %
908 % %
909 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
910 %
911 % CloneImageInfo() makes a copy of the given image info structure. If
912 % NULL is specified, a new image info structure is created initialized to
913 % default values.
914 %
915 % The format of the CloneImageInfo method is:
916 %
917 % ImageInfo *CloneImageInfo(const ImageInfo *image_info)
918 %
919 % A description of each parameter follows:
920 %
921 % o image_info: the image info.
922 %
923 */
925 {
926  ImageInfo
927  *clone_info;
928 
929  clone_info=AcquireImageInfo();
930  if (image_info == (ImageInfo *) NULL)
931  return(clone_info);
932  clone_info->compression=image_info->compression;
933  clone_info->temporary=image_info->temporary;
934  clone_info->adjoin=image_info->adjoin;
935  clone_info->antialias=image_info->antialias;
936  clone_info->scene=image_info->scene;
937  clone_info->number_scenes=image_info->number_scenes;
938  clone_info->depth=image_info->depth;
939  (void) CloneString(&clone_info->size,image_info->size);
940  (void) CloneString(&clone_info->extract,image_info->extract);
941  (void) CloneString(&clone_info->scenes,image_info->scenes);
942  (void) CloneString(&clone_info->page,image_info->page);
943  clone_info->interlace=image_info->interlace;
944  clone_info->endian=image_info->endian;
945  clone_info->units=image_info->units;
946  clone_info->quality=image_info->quality;
947  (void) CloneString(&clone_info->sampling_factor,image_info->sampling_factor);
948  (void) CloneString(&clone_info->server_name,image_info->server_name);
949  (void) CloneString(&clone_info->font,image_info->font);
950  (void) CloneString(&clone_info->texture,image_info->texture);
951  (void) CloneString(&clone_info->density,image_info->density);
952  clone_info->pointsize=image_info->pointsize;
953  clone_info->fuzz=image_info->fuzz;
954  clone_info->pen=image_info->pen;
955  clone_info->background_color=image_info->background_color;
956  clone_info->border_color=image_info->border_color;
957  clone_info->matte_color=image_info->matte_color;
958  clone_info->transparent_color=image_info->transparent_color;
959  clone_info->dither=image_info->dither;
960  clone_info->monochrome=image_info->monochrome;
961  clone_info->colors=image_info->colors;
962  clone_info->colorspace=image_info->colorspace;
963  clone_info->type=image_info->type;
964  clone_info->orientation=image_info->orientation;
965  clone_info->preview_type=image_info->preview_type;
966  clone_info->group=image_info->group;
967  clone_info->ping=image_info->ping;
968  clone_info->verbose=image_info->verbose;
969  (void) CloneString(&clone_info->view,image_info->view);
970  (void) CloneString(&clone_info->authenticate,image_info->authenticate);
971  (void) CloneImageOptions(clone_info,image_info);
972  clone_info->progress_monitor=image_info->progress_monitor;
973  clone_info->client_data=image_info->client_data;
974  clone_info->cache=image_info->cache;
975  if (image_info->cache != (void *) NULL)
976  clone_info->cache=ReferencePixelCache(image_info->cache);
977  if (image_info->profile != (void *) NULL)
978  clone_info->profile=(void *) CloneStringInfo((StringInfo *)
979  image_info->profile);
980  SetImageInfoFile(clone_info,image_info->file);
981  SetImageInfoBlob(clone_info,image_info->blob,image_info->length);
982  clone_info->stream=image_info->stream;
983  clone_info->virtual_pixel_method=image_info->virtual_pixel_method;
984  (void) CopyMagickString(clone_info->magick,image_info->magick,MaxTextExtent);
985  (void) CopyMagickString(clone_info->unique,image_info->unique,MaxTextExtent);
986  (void) CopyMagickString(clone_info->zero,image_info->zero,MaxTextExtent);
987  (void) CopyMagickString(clone_info->filename,image_info->filename,
988  MaxTextExtent);
989  clone_info->subimage=image_info->scene; /* deprecated */
990  clone_info->subrange=image_info->number_scenes; /* deprecated */
991  clone_info->channel=image_info->channel;
992  clone_info->debug=IsEventLogging();
993  clone_info->signature=image_info->signature;
994  return(clone_info);
995 }
996 
997 /*
998 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
999 % %
1000 % %
1001 % %
1002 % D e s t r o y I m a g e %
1003 % %
1004 % %
1005 % %
1006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007 %
1008 % DestroyImage() dereferences an image, deallocating memory associated with
1009 % the image if the reference count becomes zero.
1010 %
1011 % The format of the DestroyImage method is:
1012 %
1013 % Image *DestroyImage(Image *image)
1014 %
1015 % A description of each parameter follows:
1016 %
1017 % o image: the image.
1018 %
1019 */
1021 {
1023  destroy;
1024 
1025  /*
1026  Dereference image.
1027  */
1028  assert(image != (Image *) NULL);
1029  assert(image->signature == MagickSignature);
1030  if (image->debug != MagickFalse)
1031  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1032  destroy=MagickFalse;
1033  LockSemaphoreInfo(image->semaphore);
1034  image->reference_count--;
1035  if (image->reference_count == 0)
1036  destroy=MagickTrue;
1038  if (destroy == MagickFalse)
1039  return((Image *) NULL);
1040  /*
1041  Destroy image.
1042  */
1043  DestroyImagePixels(image);
1044  if (image->clip_mask != (Image *) NULL)
1045  image->clip_mask=DestroyImage(image->clip_mask);
1046  if (image->mask != (Image *) NULL)
1047  image->mask=DestroyImage(image->mask);
1048  if (image->montage != (char *) NULL)
1049  image->montage=DestroyString(image->montage);
1050  if (image->directory != (char *) NULL)
1051  image->directory=DestroyString(image->directory);
1052  if (image->colormap != (PixelPacket *) NULL)
1054  if (image->geometry != (char *) NULL)
1055  image->geometry=DestroyString(image->geometry);
1056  DestroyImageProfiles(image);
1057  DestroyImageProperties(image);
1058  DestroyImageArtifacts(image);
1059  if (image->ascii85 != (Ascii85Info*) NULL)
1061  DestroyBlob(image);
1062  (void) DestroyExceptionInfo(&image->exception);
1063  if (image->semaphore != (SemaphoreInfo *) NULL)
1065  image->signature=(~MagickSignature);
1066  image=(Image *) RelinquishMagickMemory(image);
1067  return(image);
1068 }
1069 
1070 /*
1071 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1072 % %
1073 % %
1074 % %
1075 % D e s t r o y I m a g e I n f o %
1076 % %
1077 % %
1078 % %
1079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1080 %
1081 % DestroyImageInfo() deallocates memory associated with an ImageInfo
1082 % structure.
1083 %
1084 % The format of the DestroyImageInfo method is:
1085 %
1086 % ImageInfo *DestroyImageInfo(ImageInfo *image_info)
1087 %
1088 % A description of each parameter follows:
1089 %
1090 % o image_info: the image info.
1091 %
1092 */
1094 {
1095  assert(image_info != (ImageInfo *) NULL);
1096  assert(image_info->signature == MagickSignature);
1097  if (image_info->debug != MagickFalse)
1099  image_info->filename);
1100  if (image_info->size != (char *) NULL)
1101  image_info->size=DestroyString(image_info->size);
1102  if (image_info->extract != (char *) NULL)
1103  image_info->extract=DestroyString(image_info->extract);
1104  if (image_info->scenes != (char *) NULL)
1105  image_info->scenes=DestroyString(image_info->scenes);
1106  if (image_info->page != (char *) NULL)
1107  image_info->page=DestroyString(image_info->page);
1108  if (image_info->sampling_factor != (char *) NULL)
1109  image_info->sampling_factor=DestroyString(
1110  image_info->sampling_factor);
1111  if (image_info->server_name != (char *) NULL)
1112  image_info->server_name=DestroyString(
1113  image_info->server_name);
1114  if (image_info->font != (char *) NULL)
1115  image_info->font=DestroyString(image_info->font);
1116  if (image_info->texture != (char *) NULL)
1117  image_info->texture=DestroyString(image_info->texture);
1118  if (image_info->density != (char *) NULL)
1119  image_info->density=DestroyString(image_info->density);
1120  if (image_info->view != (char *) NULL)
1121  image_info->view=DestroyString(image_info->view);
1122  if (image_info->authenticate != (char *) NULL)
1123  image_info->authenticate=DestroyString(
1124  image_info->authenticate);
1125  DestroyImageOptions(image_info);
1126  if (image_info->cache != (void *) NULL)
1127  image_info->cache=DestroyPixelCache(image_info->cache);
1128  if (image_info->profile != (StringInfo *) NULL)
1129  image_info->profile=(void *) DestroyStringInfo((StringInfo *)
1130  image_info->profile);
1131  image_info->signature=(~MagickSignature);
1132  image_info=(ImageInfo *) RelinquishMagickMemory(image_info);
1133  return(image_info);
1134 }
1135 
1136 /*
1137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1138 % %
1139 % %
1140 % %
1141 + D i s a s s o c i a t e I m a g e S t r e a m %
1142 % %
1143 % %
1144 % %
1145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1146 %
1147 % DisassociateImageStream() disassociates the image stream.
1148 %
1149 % The format of the DisassociateImageStream method is:
1150 %
1151 % MagickBooleanType DisassociateImageStream(const Image *image)
1152 %
1153 % A description of each parameter follows:
1154 %
1155 % o image: the image.
1156 %
1157 */
1159 {
1160  assert(image != (const Image *) NULL);
1161  assert(image->signature == MagickSignature);
1162  if (image->debug != MagickFalse)
1163  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1164  (void) DetachBlob(image->blob);
1165 }
1166 
1167 /*
1168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1169 % %
1170 % %
1171 % %
1172 % G e t I m a g e C l i p M a s k %
1173 % %
1174 % %
1175 % %
1176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1177 %
1178 % GetImageClipMask() returns the clip path associated with the image.
1179 %
1180 % The format of the GetImageClipMask method is:
1181 %
1182 % Image *GetImageClipMask(const Image *image,ExceptionInfo *exception)
1183 %
1184 % A description of each parameter follows:
1185 %
1186 % o image: the image.
1187 %
1188 */
1191 {
1192  assert(image != (const Image *) NULL);
1193  if (image->debug != MagickFalse)
1194  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1195  assert(image->signature == MagickSignature);
1196  if (image->clip_mask == (Image *) NULL)
1197  return((Image *) NULL);
1198  return(CloneImage(image->clip_mask,0,0,MagickTrue,exception));
1199 }
1200 
1201 /*
1202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1203 % %
1204 % %
1205 % %
1206 % G e t I m a g e E x c e p t i o n %
1207 % %
1208 % %
1209 % %
1210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1211 %
1212 % GetImageException() traverses an image sequence and returns any
1213 % error more severe than noted by the exception parameter.
1214 %
1215 % The format of the GetImageException method is:
1216 %
1217 % void GetImageException(Image *image,ExceptionInfo *exception)
1218 %
1219 % A description of each parameter follows:
1220 %
1221 % o image: Specifies a pointer to a list of one or more images.
1222 %
1223 % o exception: return the highest severity exception.
1224 %
1225 */
1227 {
1228  register Image
1229  *next;
1230 
1231  assert(image != (Image *) NULL);
1232  assert(image->signature == MagickSignature);
1233  if (image->debug != MagickFalse)
1234  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1235  assert(exception != (ExceptionInfo *) NULL);
1236  assert(exception->signature == MagickSignature);
1237  for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
1238  {
1239  if (next->exception.severity == UndefinedException)
1240  continue;
1241  if (next->exception.severity > exception->severity)
1242  InheritException(exception,&next->exception);
1244  }
1245 }
1246 
1247 /*
1248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1249 % %
1250 % %
1251 % %
1252 % G e t I m a g e I n f o %
1253 % %
1254 % %
1255 % %
1256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1257 %
1258 % GetImageInfo() initializes image_info to default values.
1259 %
1260 % The format of the GetImageInfo method is:
1261 %
1262 % void GetImageInfo(ImageInfo *image_info)
1263 %
1264 % A description of each parameter follows:
1265 %
1266 % o image_info: the image info.
1267 %
1268 */
1270 {
1271  char
1272  *synchronize;
1273 
1275  *exception;
1276 
1277  /*
1278  File and image dimension members.
1279  */
1280  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1281  assert(image_info != (ImageInfo *) NULL);
1282  (void) ResetMagickMemory(image_info,0,sizeof(*image_info));
1283  image_info->adjoin=MagickTrue;
1284  image_info->interlace=NoInterlace;
1285  image_info->channel=DefaultChannels;
1287  image_info->antialias=MagickTrue;
1288  image_info->dither=MagickTrue;
1289  synchronize=GetEnvironmentValue("MAGICK_SYNCHRONIZE");
1290  if (synchronize != (const char *) NULL)
1291  {
1292  image_info->synchronize=IsStringTrue(synchronize);
1293  synchronize=DestroyString(synchronize);
1294  }
1295  exception=AcquireExceptionInfo();
1297  exception);
1298  (void) QueryColorDatabase(BorderColor,&image_info->border_color,exception);
1299  (void) QueryColorDatabase(MatteColor,&image_info->matte_color,exception);
1301  exception);
1302  exception=DestroyExceptionInfo(exception);
1303  image_info->debug=IsEventLogging();
1304  image_info->signature=MagickSignature;
1305 }
1306 
1307 /*
1308 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1309 % %
1310 % %
1311 % %
1312 % G e t I m a g e I n f o F i l e %
1313 % %
1314 % %
1315 % %
1316 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1317 %
1318 % GetImageInfoFile() returns the image info file member.
1319 %
1320 % The format of the GetImageInfoFile method is:
1321 %
1322 % FILE *GetImageInfoFile(const ImageInfo *image_info)
1323 %
1324 % A description of each parameter follows:
1325 %
1326 % o image_info: the image info.
1327 %
1328 */
1329 MagickExport FILE *GetImageInfoFile(const ImageInfo *image_info)
1330 {
1331  return(image_info->file);
1332 }
1333 
1334 /*
1335 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1336 % %
1337 % %
1338 % %
1339 % G e t I m a g e M a s k %
1340 % %
1341 % %
1342 % %
1343 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1344 %
1345 % GetImageMask() returns the mask associated with the image.
1346 %
1347 % The format of the GetImageMask method is:
1348 %
1349 % Image *GetImageMask(const Image *image,ExceptionInfo *exception)
1350 %
1351 % A description of each parameter follows:
1352 %
1353 % o image: the image.
1354 %
1355 */
1357 {
1358  assert(image != (const Image *) NULL);
1359  if (image->debug != MagickFalse)
1360  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1361  assert(image->signature == MagickSignature);
1362  if (image->mask == (Image *) NULL)
1363  return((Image *) NULL);
1364  return(CloneImage(image->mask,0,0,MagickTrue,exception));
1365 }
1366 
1367 /*
1368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1369 % %
1370 % %
1371 % %
1372 % G e t I m a g e C h a n n e l s %
1373 % %
1374 % %
1375 % %
1376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1377 %
1378 % GetImageChannels() returns the number of pixel channels associated with the
1379 % specified image.
1380 %
1381 % The format of the GetChannels method is:
1382 %
1383 % size_t GetImageChannels(Image *image)
1384 %
1385 % A description of each parameter follows:
1386 %
1387 % o image: the image.
1388 %
1389 */
1391 {
1392  assert(image != (Image *) NULL);
1393  assert(image->signature == MagickSignature);
1394  if (image->debug != MagickFalse)
1395  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1396  return(image->channels);
1397 }
1398 
1399 /*
1400 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1401 % %
1402 % %
1403 % %
1404 + G e t I m a g e R e f e r e n c e C o u n t %
1405 % %
1406 % %
1407 % %
1408 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1409 %
1410 % GetImageReferenceCount() returns the image reference count.
1411 %
1412 % The format of the GetReferenceCount method is:
1413 %
1414 % ssize_t GetImageReferenceCount(Image *image)
1415 %
1416 % A description of each parameter follows:
1417 %
1418 % o image: the image.
1419 %
1420 */
1422 {
1423  ssize_t
1424  reference_count;
1425 
1426  assert(image != (Image *) NULL);
1427  assert(image->signature == MagickSignature);
1428  if (image->debug != MagickFalse)
1429  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1430  LockSemaphoreInfo(image->semaphore);
1431  reference_count=image->reference_count;
1433  return(reference_count);
1434 }
1435 
1436 /*
1437 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1438 % %
1439 % %
1440 % %
1441 % 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 %
1442 % %
1443 % %
1444 % %
1445 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1446 %
1447 % GetImageVirtualPixelMethod() gets the "virtual pixels" method for the
1448 % image. A virtual pixel is any pixel access that is outside the boundaries
1449 % of the image cache.
1450 %
1451 % The format of the GetImageVirtualPixelMethod() method is:
1452 %
1453 % VirtualPixelMethod GetImageVirtualPixelMethod(const Image *image)
1454 %
1455 % A description of each parameter follows:
1456 %
1457 % o image: the image.
1458 %
1459 */
1461 {
1462  assert(image != (Image *) NULL);
1463  assert(image->signature == MagickSignature);
1464  if (image->debug != MagickFalse)
1465  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1466  return(GetPixelCacheVirtualMethod(image));
1467 }
1468 
1469 /*
1470 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1471 % %
1472 % %
1473 % %
1474 % I n t e r p r e t I m a g e F i l e n a m e %
1475 % %
1476 % %
1477 % %
1478 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1479 %
1480 % InterpretImageFilename() interprets embedded characters in an image filename.
1481 % The filename length is returned.
1482 %
1483 % The format of the InterpretImageFilename method is:
1484 %
1485 % size_t InterpretImageFilename(const ImageInfo *image_info,Image *image,
1486 % const char *format,int value,char *filename)
1487 %
1488 % A description of each parameter follows.
1489 %
1490 % o image_info: the image info..
1491 %
1492 % o image: the image.
1493 %
1494 % o format: A filename describing the format to use to write the numeric
1495 % argument. Only the first numeric format identifier is replaced.
1496 %
1497 % o value: Numeric value to substitute into format filename.
1498 %
1499 % o filename: return the formatted filename in this character buffer.
1500 %
1501 */
1503  Image *image,const char *format,int value,char *filename)
1504 {
1505  char
1506  *q;
1507 
1508  int
1509  c;
1510 
1512  canonical;
1513 
1514  register const char
1515  *p;
1516 
1517  size_t
1518  length;
1519 
1520  canonical=MagickFalse;
1521  length=0;
1522  (void) CopyMagickString(filename,format,MaxTextExtent);
1523  for (p=strchr(format,'%'); p != (char *) NULL; p=strchr(p+1,'%'))
1524  {
1525  q=(char *) p+1;
1526  if (*q == '%')
1527  {
1528  p=q+1;
1529  continue;
1530  }
1531  if (*q == '0')
1532  {
1533  ssize_t
1534  value;
1535 
1536  value=(ssize_t) strtol(q,&q,10);
1537  (void) value;
1538  }
1539  switch (*q)
1540  {
1541  case 'd':
1542  case 'o':
1543  case 'x':
1544  {
1545  q++;
1546  c=(*q);
1547  *q='\0';
1548  (void) FormatLocaleString(filename+(p-format),(size_t) (MaxTextExtent-
1549  (p-format)),p,value);
1550  *q=c;
1551  (void) ConcatenateMagickString(filename,q,MaxTextExtent);
1552  canonical=MagickTrue;
1553  if (*(q-1) != '%')
1554  break;
1555  p++;
1556  break;
1557  }
1558  case '[':
1559  {
1560  char
1561  pattern[MaxTextExtent];
1562 
1563  const char
1564  *value;
1565 
1566  register char
1567  *r;
1568 
1569  register ssize_t
1570  i;
1571 
1572  ssize_t
1573  depth;
1574 
1575  /*
1576  Image option.
1577  */
1578  if (strchr(p,']') == (char *) NULL)
1579  break;
1580  depth=1;
1581  r=q+1;
1582  for (i=0; (i < (MaxTextExtent-1L)) && (*r != '\0'); i++)
1583  {
1584  if (*r == '[')
1585  depth++;
1586  if (*r == ']')
1587  depth--;
1588  if (depth <= 0)
1589  break;
1590  pattern[i]=(*r++);
1591  }
1592  pattern[i]='\0';
1593  if (LocaleNCompare(pattern,"filename:",9) != 0)
1594  break;
1595  value=(const char *) NULL;
1596 #if 0
1597  /* FUTURE: remove this code. -- Anthony 29 Arpil 2012
1598  Removed as GetMagickProperty() will will never match a "filename:"
1599  string as this is not a 'known' image property.
1600  */
1601  if ((image_info != (const ImageInfo *) NULL) &&
1602  (image != (const Image *) NULL))
1603  value=GetMagickProperty(image_info,image,pattern);
1604  else
1605 #endif
1606  if (image != (Image *) NULL)
1607  value=GetImageProperty(image,pattern);
1608  if ((value == (const char *) NULL) &&
1609  (image != (Image *) NULL))
1610  value=GetImageArtifact(image,pattern);
1611  if ((value == (const char *) NULL) &&
1612  (image_info != (ImageInfo *) NULL))
1613  value=GetImageOption(image_info,pattern);
1614  if (value == (const char *) NULL)
1615  break;
1616  q--;
1617  c=(*q);
1618  *q='\0';
1619  (void) CopyMagickString(filename+(p-format-length),value,(size_t)
1620  (MaxTextExtent-(p-format-length)));
1621  length+=strlen(pattern)-1;
1622  *q=c;
1623  (void) ConcatenateMagickString(filename,r+1,MaxTextExtent);
1624  canonical=MagickTrue;
1625  if (*(q-1) != '%')
1626  break;
1627  p++;
1628  break;
1629  }
1630  default:
1631  break;
1632  }
1633  }
1634  for (q=filename; *q != '\0'; q++)
1635  if ((*q == '%') && (*(q+1) == '%'))
1636  {
1637  (void) CopyMagickString(q,q+1,(size_t) (MaxTextExtent-(q-filename)));
1638  canonical=MagickTrue;
1639  }
1640  if (canonical == MagickFalse)
1641  (void) CopyMagickString(filename,format,MaxTextExtent);
1642  return(strlen(filename));
1643 }
1644 
1645 /*
1646 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1647 % %
1648 % %
1649 % %
1650 % I s H i g h D y n a m i c R a n g e I m a g e %
1651 % %
1652 % %
1653 % %
1654 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1655 %
1656 % IsHighDynamicRangeImage() returns MagickTrue if any pixel component is
1657 % non-integer or exceeds the bounds of the quantum depth (e.g. for Q16
1658 % 0..65535.
1659 %
1660 % The format of the IsHighDynamicRangeImage method is:
1661 %
1662 % MagickBooleanType IsHighDynamicRangeImage(const Image *image,
1663 % ExceptionInfo *exception)
1664 %
1665 % A description of each parameter follows:
1666 %
1667 % o image: the image.
1668 %
1669 % o exception: return any errors or warnings in this structure.
1670 %
1671 */
1674 {
1675 #if !defined(MAGICKCORE_HDRI_SUPPORT)
1676  (void) image;
1677  (void) exception;
1678  return(MagickFalse);
1679 #else
1680  CacheView
1681  *image_view;
1682 
1684  status;
1685 
1687  zero;
1688 
1689  ssize_t
1690  y;
1691 
1692  assert(image != (Image *) NULL);
1693  assert(image->signature == MagickSignature);
1694  if (image->debug != MagickFalse)
1695  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1696  status=MagickTrue;
1697  GetMagickPixelPacket(image,&zero);
1698  image_view=AcquireVirtualCacheView(image,exception);
1699 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1700  #pragma omp parallel for schedule(static,4) shared(status) \
1701  magick_threads(image,image,image->rows,1)
1702 #endif
1703  for (y=0; y < (ssize_t) image->rows; y++)
1704  {
1706  pixel;
1707 
1708  register const IndexPacket
1709  *indexes;
1710 
1711  register const PixelPacket
1712  *p;
1713 
1714  register ssize_t
1715  x;
1716 
1717  if (status == MagickFalse)
1718  continue;
1719  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
1720  if (p == (const PixelPacket *) NULL)
1721  {
1722  status=MagickFalse;
1723  continue;
1724  }
1725  indexes=GetCacheViewVirtualIndexQueue(image_view);
1726  pixel=zero;
1727  for (x=0; x < (ssize_t) image->columns; x++)
1728  {
1729  SetMagickPixelPacket(image,p,indexes+x,&pixel);
1730  if ((pixel.red < 0.0) || (pixel.red > QuantumRange) ||
1731  (pixel.red != (QuantumAny) pixel.red))
1732  break;
1733  if ((pixel.green < 0.0) || (pixel.green > QuantumRange) ||
1734  (pixel.green != (QuantumAny) pixel.green))
1735  break;
1736  if ((pixel.blue < 0.0) || (pixel.blue > QuantumRange) ||
1737  (pixel.blue != (QuantumAny) pixel.blue))
1738  break;
1739  if (pixel.matte != MagickFalse)
1740  {
1741  if ((pixel.opacity < 0.0) || (pixel.opacity > QuantumRange) ||
1742  (pixel.opacity != (QuantumAny) pixel.opacity))
1743  break;
1744  }
1745  if (pixel.colorspace == CMYKColorspace)
1746  {
1747  if ((pixel.index < 0.0) || (pixel.index > QuantumRange) ||
1748  (pixel.index != (QuantumAny) pixel.index))
1749  break;
1750  }
1751  p++;
1752  }
1753  if (x < (ssize_t) image->columns)
1754  status=MagickFalse;
1755  }
1756  image_view=DestroyCacheView(image_view);
1757  return(status != MagickFalse ? MagickFalse : MagickTrue);
1758 #endif
1759 }
1760 
1761 /*
1762 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1763 % %
1764 % %
1765 % %
1766 % I s I m a g e O b j e c t %
1767 % %
1768 % %
1769 % %
1770 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1771 %
1772 % IsImageObject() returns MagickTrue if the image sequence contains a valid
1773 % set of image objects.
1774 %
1775 % The format of the IsImageObject method is:
1776 %
1777 % MagickBooleanType IsImageObject(const Image *image)
1778 %
1779 % A description of each parameter follows:
1780 %
1781 % o image: the image.
1782 %
1783 */
1785 {
1786  register const Image
1787  *p;
1788 
1789  assert(image != (Image *) NULL);
1790  if (image->debug != MagickFalse)
1791  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1792  for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1793  if (p->signature != MagickSignature)
1794  return(MagickFalse);
1795  return(MagickTrue);
1796 }
1797 
1798 /*
1799 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1800 % %
1801 % %
1802 % %
1803 % I s T a i n t I m a g e %
1804 % %
1805 % %
1806 % %
1807 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1808 %
1809 % IsTaintImage() returns MagickTrue any pixel in the image has been altered
1810 % since it was first constituted.
1811 %
1812 % The format of the IsTaintImage method is:
1813 %
1814 % MagickBooleanType IsTaintImage(const Image *image)
1815 %
1816 % A description of each parameter follows:
1817 %
1818 % o image: the image.
1819 %
1820 */
1822 {
1823  char
1824  magick[MaxTextExtent],
1825  filename[MaxTextExtent];
1826 
1827  register const Image
1828  *p;
1829 
1830  assert(image != (Image *) NULL);
1831  if (image->debug != MagickFalse)
1832  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1833  assert(image->signature == MagickSignature);
1834  (void) CopyMagickString(magick,image->magick,MaxTextExtent);
1835  (void) CopyMagickString(filename,image->filename,MaxTextExtent);
1836  for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1837  {
1838  if (p->taint != MagickFalse)
1839  return(MagickTrue);
1840  if (LocaleCompare(p->magick,magick) != 0)
1841  return(MagickTrue);
1842  if (LocaleCompare(p->filename,filename) != 0)
1843  return(MagickTrue);
1844  }
1845  return(MagickFalse);
1846 }
1847 
1848 /*
1849 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1850 % %
1851 % %
1852 % %
1853 % M o d i f y I m a g e %
1854 % %
1855 % %
1856 % %
1857 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1858 %
1859 % ModifyImage() ensures that there is only a single reference to the image
1860 % to be modified, updating the provided image pointer to point to a clone of
1861 % the original image if necessary.
1862 %
1863 % The format of the ModifyImage method is:
1864 %
1865 % MagickBooleanType ModifyImage(Image *image,ExceptionInfo *exception)
1866 %
1867 % A description of each parameter follows:
1868 %
1869 % o image: the image.
1870 %
1871 % o exception: return any errors or warnings in this structure.
1872 %
1873 */
1876 {
1877  Image
1878  *clone_image;
1879 
1880  assert(image != (Image **) NULL);
1881  assert(*image != (Image *) NULL);
1882  assert((*image)->signature == MagickSignature);
1883  if ((*image)->debug != MagickFalse)
1884  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1885  if (GetImageReferenceCount(*image) <= 1)
1886  return(MagickTrue);
1887  clone_image=CloneImage(*image,0,0,MagickTrue,exception);
1888  LockSemaphoreInfo((*image)->semaphore);
1889  (*image)->reference_count--;
1890  UnlockSemaphoreInfo((*image)->semaphore);
1891  *image=clone_image;
1892  return(MagickTrue);
1893 }
1894 
1895 /*
1896 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1897 % %
1898 % %
1899 % %
1900 % N e w M a g i c k I m a g e %
1901 % %
1902 % %
1903 % %
1904 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1905 %
1906 % NewMagickImage() creates a blank image canvas of the specified size and
1907 % background color.
1908 %
1909 % The format of the NewMagickImage method is:
1910 %
1911 % Image *NewMagickImage(const ImageInfo *image_info,
1912 % const size_t width,const size_t height,
1913 % const MagickPixelPacket *background)
1914 %
1915 % A description of each parameter follows:
1916 %
1917 % o image: the image.
1918 %
1919 % o width: the image width.
1920 %
1921 % o height: the image height.
1922 %
1923 % o background: the image color.
1924 %
1925 */
1927  const size_t width,const size_t height,
1928  const MagickPixelPacket *background)
1929 {
1930  CacheView
1931  *image_view;
1932 
1934  *exception;
1935 
1936  Image
1937  *image;
1938 
1939  ssize_t
1940  y;
1941 
1943  status;
1944 
1945  assert(image_info != (const ImageInfo *) NULL);
1946  if (image_info->debug != MagickFalse)
1947  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1948  assert(image_info->signature == MagickSignature);
1949  assert(background != (const MagickPixelPacket *) NULL);
1950  image=AcquireImage(image_info);
1951  image->columns=width;
1952  image->rows=height;
1953  image->colorspace=background->colorspace;
1954  image->matte=background->matte;
1955  image->fuzz=background->fuzz;
1956  image->depth=background->depth;
1957  status=MagickTrue;
1958  exception=(&image->exception);
1959  image_view=AcquireAuthenticCacheView(image,exception);
1960 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1961  #pragma omp parallel for schedule(static,4) shared(status) \
1962  magick_threads(image,image,image->rows,1)
1963 #endif
1964  for (y=0; y < (ssize_t) image->rows; y++)
1965  {
1966  register IndexPacket
1967  *restrict indexes;
1968 
1969  register PixelPacket
1970  *restrict q;
1971 
1972  register ssize_t
1973  x;
1974 
1975  if (status == MagickFalse)
1976  continue;
1977  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
1978  if (q == (PixelPacket *) NULL)
1979  {
1980  status=MagickFalse;
1981  continue;
1982  }
1983  indexes=GetCacheViewAuthenticIndexQueue(image_view);
1984  for (x=0; x < (ssize_t) image->columns; x++)
1985  {
1986  SetPixelPacket(image,background,q,indexes+x);
1987  q++;
1988  }
1989  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1990  status=MagickFalse;
1991  }
1992  image_view=DestroyCacheView(image_view);
1993  if (status == MagickFalse)
1994  image=DestroyImage(image);
1995  return(image);
1996 }
1997 
1998 /*
1999 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2000 % %
2001 % %
2002 % %
2003 % R e f e r e n c e I m a g e %
2004 % %
2005 % %
2006 % %
2007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2008 %
2009 % ReferenceImage() increments the reference count associated with an image
2010 % returning a pointer to the image.
2011 %
2012 % The format of the ReferenceImage method is:
2013 %
2014 % Image *ReferenceImage(Image *image)
2015 %
2016 % A description of each parameter follows:
2017 %
2018 % o image: the image.
2019 %
2020 */
2022 {
2023  assert(image != (Image *) NULL);
2024  if (image->debug != MagickFalse)
2025  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2026  assert(image->signature == MagickSignature);
2027  LockSemaphoreInfo(image->semaphore);
2028  image->reference_count++;
2030  return(image);
2031 }
2032 
2033 /*
2034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2035 % %
2036 % %
2037 % %
2038 % R e s e t I m a g e P a g e %
2039 % %
2040 % %
2041 % %
2042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2043 %
2044 % ResetImagePage() resets the image page canvas and position.
2045 %
2046 % The format of the ResetImagePage method is:
2047 %
2048 % MagickBooleanType ResetImagePage(Image *image,const char *page)
2049 %
2050 % A description of each parameter follows:
2051 %
2052 % o image: the image.
2053 %
2054 % o page: the relative page specification.
2055 %
2056 */
2058 {
2060  flags;
2061 
2063  geometry;
2064 
2065  assert(image != (Image *) NULL);
2066  assert(image->signature == MagickSignature);
2067  if (image->debug != MagickFalse)
2068  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2069  flags=ParseAbsoluteGeometry(page,&geometry);
2070  if ((flags & WidthValue) != 0)
2071  {
2072  if ((flags & HeightValue) == 0)
2073  geometry.height=geometry.width;
2074  image->page.width=geometry.width;
2075  image->page.height=geometry.height;
2076  }
2077  if ((flags & AspectValue) != 0)
2078  {
2079  if ((flags & XValue) != 0)
2080  image->page.x+=geometry.x;
2081  if ((flags & YValue) != 0)
2082  image->page.y+=geometry.y;
2083  }
2084  else
2085  {
2086  if ((flags & XValue) != 0)
2087  {
2088  image->page.x=geometry.x;
2089  if ((image->page.width == 0) && (geometry.x > 0))
2090  image->page.width=image->columns+geometry.x;
2091  }
2092  if ((flags & YValue) != 0)
2093  {
2094  image->page.y=geometry.y;
2095  if ((image->page.height == 0) && (geometry.y > 0))
2096  image->page.height=image->rows+geometry.y;
2097  }
2098  }
2099  return(MagickTrue);
2100 }
2101 
2102 /*
2103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2104 % %
2105 % %
2106 % %
2107 % S e t I m a g e B a c k g r o u n d C o l o r %
2108 % %
2109 % %
2110 % %
2111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2112 %
2113 % SetImageBackgroundColor() initializes the image pixels to the image
2114 % background color. The background color is defined by the background_color
2115 % member of the image structure.
2116 %
2117 % The format of the SetImage method is:
2118 %
2119 % MagickBooleanType SetImageBackgroundColor(Image *image)
2120 %
2121 % A description of each parameter follows:
2122 %
2123 % o image: the image.
2124 %
2125 */
2127 {
2128  CacheView
2129  *image_view;
2130 
2132  *exception;
2133 
2134  IndexPacket
2135  index;
2136 
2138  status;
2139 
2141  background;
2142 
2143  PixelPacket
2144  pixel;
2145 
2146  ssize_t
2147  y;
2148 
2149  assert(image != (Image *) NULL);
2150  if (image->debug != MagickFalse)
2151  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2152  assert(image->signature == MagickSignature);
2154  return(MagickFalse);
2155  if ((IsPixelGray(&image->background_color) == MagickFalse) &&
2158  if ((image->background_color.opacity != OpaqueOpacity) &&
2159  (image->matte == MagickFalse))
2161  GetMagickPixelPacket(image,&background);
2162  SetMagickPixelPacket(image,&image->background_color,(const IndexPacket *)
2163  NULL,&background);
2164  if (image->colorspace == CMYKColorspace)
2165  ConvertRGBToCMYK(&background);
2166  index=0;
2167  SetPixelPacket(image,&background,&pixel,&index);
2168  /*
2169  Set image background color.
2170  */
2171  status=MagickTrue;
2172  exception=(&image->exception);
2173  image_view=AcquireAuthenticCacheView(image,exception);
2174  for (y=0; y < (ssize_t) image->rows; y++)
2175  {
2176  register PixelPacket
2177  *restrict q;
2178 
2179  register ssize_t
2180  x;
2181 
2182  if (status == MagickFalse)
2183  continue;
2184  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2185  if (q == (PixelPacket *) NULL)
2186  {
2187  status=MagickFalse;
2188  continue;
2189  }
2190  for (x=0; x < (ssize_t) image->columns; x++)
2191  *q++=pixel;
2192  if (image->colorspace == CMYKColorspace)
2193  {
2194  register IndexPacket
2195  *restrict indexes;
2196 
2197  indexes=GetCacheViewAuthenticIndexQueue(image_view);
2198  for (x=0; x < (ssize_t) image->columns; x++)
2199  SetPixelIndex(indexes+x,index);
2200  }
2201  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2202  status=MagickFalse;
2203  }
2204  image_view=DestroyCacheView(image_view);
2205  return(status);
2206 }
2207 
2208 /*
2209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2210 % %
2211 % %
2212 % %
2213 % S e t I m a g e C h a n n e l s %
2214 % %
2215 % %
2216 % %
2217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2218 %
2219 % SetImageChannels() sets the number of pixels channels associated with the
2220 % image.
2221 %
2222 % The format of the SetImageChannels method is:
2223 %
2224 % MagickBooleanType SetImageChannels(Image *image,const size_t channels)
2225 %
2226 % A description of each parameter follows:
2227 %
2228 % o image: the image.
2229 %
2230 % o channels: The number of pixel channels.
2231 %
2232 */
2234  const size_t channels)
2235 {
2236  image->channels=channels;
2237  return(MagickTrue);
2238 }
2239 
2240 /*
2241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2242 % %
2243 % %
2244 % %
2245 % S e t I m a g e C o l o r %
2246 % %
2247 % %
2248 % %
2249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2250 %
2251 % SetImageColor() set the entire image canvas to the specified color.
2252 %
2253 % The format of the SetImageColor method is:
2254 %
2255 % MagickBooleanType SetImageColor(Image *image,
2256 % const MagickPixelPacket *color)
2257 %
2258 % A description of each parameter follows:
2259 %
2260 % o image: the image.
2261 %
2262 % o background: the image color.
2263 %
2264 */
2266  const MagickPixelPacket *color)
2267 {
2268  CacheView
2269  *image_view;
2270 
2272  *exception;
2273 
2275  status;
2276 
2277  ssize_t
2278  y;
2279 
2280  assert(image != (Image *) NULL);
2281  if (image->debug != MagickFalse)
2282  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2283  assert(image->signature == MagickSignature);
2284  assert(color != (const MagickPixelPacket *) NULL);
2285  image->colorspace=color->colorspace;
2286  image->matte=color->matte;
2287  image->fuzz=color->fuzz;
2288  image->depth=color->depth;
2289  status=MagickTrue;
2290  exception=(&image->exception);
2291  image_view=AcquireAuthenticCacheView(image,exception);
2292 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2293  #pragma omp parallel for schedule(static,4) shared(status) \
2294  magick_threads(image,image,image->rows,1)
2295 #endif
2296  for (y=0; y < (ssize_t) image->rows; y++)
2297  {
2298  register IndexPacket
2299  *restrict indexes;
2300 
2301  register PixelPacket
2302  *restrict q;
2303 
2304  register ssize_t
2305  x;
2306 
2307  if (status == MagickFalse)
2308  continue;
2309  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2310  if (q == (PixelPacket *) NULL)
2311  {
2312  status=MagickFalse;
2313  continue;
2314  }
2315  indexes=GetCacheViewAuthenticIndexQueue(image_view);
2316  for (x=0; x < (ssize_t) image->columns; x++)
2317  {
2318  SetPixelPacket(image,color,q,indexes+x);
2319  q++;
2320  }
2321  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2322  status=MagickFalse;
2323  }
2324  image_view=DestroyCacheView(image_view);
2325  return(status);
2326 }
2327 
2328 /*
2329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2330 % %
2331 % %
2332 % %
2333 % S e t I m a g e S t o r a g e C l a s s %
2334 % %
2335 % %
2336 % %
2337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2338 %
2339 % SetImageStorageClass() sets the image class: DirectClass for true color
2340 % images or PseudoClass for colormapped images.
2341 %
2342 % The format of the SetImageStorageClass method is:
2343 %
2344 % MagickBooleanType SetImageStorageClass(Image *image,
2345 % const ClassType storage_class)
2346 %
2347 % A description of each parameter follows:
2348 %
2349 % o image: the image.
2350 %
2351 % o storage_class: The image class.
2352 %
2353 */
2355  const ClassType storage_class)
2356 {
2357  image->storage_class=storage_class;
2358  return(SyncImagePixelCache(image,&image->exception));
2359 }
2360 
2361 /*
2362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2363 % %
2364 % %
2365 % %
2366 % S e t I m a g e C l i p M a s k %
2367 % %
2368 % %
2369 % %
2370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2371 %
2372 % SetImageClipMask() associates a clip path with the image. The clip path
2373 % must be the same dimensions as the image. Set any pixel component of
2374 % the clip path to TransparentOpacity to prevent that corresponding image
2375 % pixel component from being updated when SyncAuthenticPixels() is applied.
2376 %
2377 % The format of the SetImageClipMask method is:
2378 %
2379 % MagickBooleanType SetImageClipMask(Image *image,const Image *clip_mask)
2380 %
2381 % A description of each parameter follows:
2382 %
2383 % o image: the image.
2384 %
2385 % o clip_mask: the image clip path.
2386 %
2387 */
2389  const Image *clip_mask)
2390 {
2391  assert(image != (Image *) NULL);
2392  if (image->debug != MagickFalse)
2393  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2394  assert(image->signature == MagickSignature);
2395  if (clip_mask != (const Image *) NULL)
2396  if ((clip_mask->columns != image->columns) ||
2397  (clip_mask->rows != image->rows))
2398  ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
2399  if (image->clip_mask != (Image *) NULL)
2400  image->clip_mask=DestroyImage(image->clip_mask);
2401  image->clip_mask=NewImageList();
2402  if (clip_mask == (Image *) NULL)
2403  return(MagickTrue);
2405  return(MagickFalse);
2406  image->clip_mask=CloneImage(clip_mask,0,0,MagickTrue,&image->exception);
2407  if (image->clip_mask == (Image *) NULL)
2408  return(MagickFalse);
2409  return(MagickTrue);
2410 }
2411 
2412 /*
2413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2414 % %
2415 % %
2416 % %
2417 % S e t I m a g e E x t e n t %
2418 % %
2419 % %
2420 % %
2421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2422 %
2423 % SetImageExtent() sets the image size (i.e. columns & rows).
2424 %
2425 % The format of the SetImageExtent method is:
2426 %
2427 % MagickBooleanType SetImageExtent(Image *image,
2428 % const size_t columns,const size_t rows)
2429 %
2430 % A description of each parameter follows:
2431 %
2432 % o image: the image.
2433 %
2434 % o columns: The image width in pixels.
2435 %
2436 % o rows: The image height in pixels.
2437 %
2438 */
2440  const size_t columns,const size_t rows)
2441 {
2442  if ((columns == 0) || (rows == 0))
2443  return(MagickFalse);
2444  image->columns=columns;
2445  image->rows=rows;
2446  return(SyncImagePixelCache(image,&image->exception));
2447 }
2448 
2449 /*
2450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2451 % %
2452 % %
2453 % %
2454 + S e t I m a g e I n f o %
2455 % %
2456 % %
2457 % %
2458 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2459 %
2460 % SetImageInfo() initializes the `magick' field of the ImageInfo structure.
2461 % It is set to a type of image format based on the prefix or suffix of the
2462 % filename. For example, `ps:image' returns PS indicating a Postscript image.
2463 % JPEG is returned for this filename: `image.jpg'. The filename prefix has
2464 % precendence over the suffix. Use an optional index enclosed in brackets
2465 % after a file name to specify a desired scene of a multi-resolution image
2466 % format like Photo CD (e.g. img0001.pcd[4]). A True (non-zero) return value
2467 % indicates success.
2468 %
2469 % The format of the SetImageInfo method is:
2470 %
2471 % MagickBooleanType SetImageInfo(ImageInfo *image_info,
2472 % const unsigned int frames,ExceptionInfo *exception)
2473 %
2474 % A description of each parameter follows:
2475 %
2476 % o image_info: the image info.
2477 %
2478 % o frames: the number of images you intend to write.
2479 %
2480 % o exception: return any errors or warnings in this structure.
2481 %
2482 */
2484  const unsigned int frames,ExceptionInfo *exception)
2485 {
2486  char
2487  extension[MaxTextExtent],
2488  filename[MaxTextExtent],
2489  magic[MaxTextExtent],
2490  *q,
2491  subimage[MaxTextExtent];
2492 
2493  const MagicInfo
2494  *magic_info;
2495 
2496  const MagickInfo
2497  *magick_info;
2498 
2500  *sans_exception;
2501 
2502  Image
2503  *image;
2504 
2506  status;
2507 
2508  register const char
2509  *p;
2510 
2511  ssize_t
2512  count;
2513 
2514  unsigned char
2515  magick[2*MaxTextExtent];
2516 
2517  /*
2518  Look for 'image.format' in filename.
2519  */
2520  assert(image_info != (ImageInfo *) NULL);
2521  assert(image_info->signature == MagickSignature);
2522  if (image_info->debug != MagickFalse)
2524  image_info->filename);
2525  *subimage='\0';
2526  GetPathComponent(image_info->filename,SubimagePath,subimage);
2527  if (*subimage != '\0')
2528  {
2529  /*
2530  Look for scene specification (e.g. img0001.pcd[4]).
2531  */
2532  if (IsSceneGeometry(subimage,MagickFalse) == MagickFalse)
2533  {
2534  if (IsGeometry(subimage) != MagickFalse)
2535  (void) CloneString(&image_info->extract,subimage);
2536  }
2537  else
2538  {
2539  size_t
2540  first,
2541  last;
2542 
2543  (void) CloneString(&image_info->scenes,subimage);
2544  image_info->scene=StringToUnsignedLong(image_info->scenes);
2545  image_info->number_scenes=image_info->scene;
2546  p=image_info->scenes;
2547  for (q=(char *) image_info->scenes; *q != '\0'; p++)
2548  {
2549  while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
2550  p++;
2551  first=(size_t) strtol(p,&q,10);
2552  last=first;
2553  while (isspace((int) ((unsigned char) *q)) != 0)
2554  q++;
2555  if (*q == '-')
2556  last=(size_t) strtol(q+1,&q,10);
2557  if (first > last)
2558  Swap(first,last);
2559  if (first < image_info->scene)
2560  image_info->scene=first;
2561  if (last > image_info->number_scenes)
2562  image_info->number_scenes=last;
2563  p=q;
2564  }
2565  image_info->number_scenes-=image_info->scene-1;
2566  image_info->subimage=image_info->scene;
2567  image_info->subrange=image_info->number_scenes;
2568  }
2569  }
2570  *extension='\0';
2571  GetPathComponent(image_info->filename,ExtensionPath,extension);
2572 #if defined(MAGICKCORE_ZLIB_DELEGATE)
2573  if (*extension != '\0')
2574  if ((LocaleCompare(extension,"gz") == 0) ||
2575  (LocaleCompare(extension,"Z") == 0) ||
2576  (LocaleCompare(extension,"svgz") == 0) ||
2577  (LocaleCompare(extension,"wmz") == 0))
2578  {
2579  char
2580  path[MaxTextExtent];
2581 
2582  (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
2583  path[strlen(path)-strlen(extension)-1]='\0';
2584  GetPathComponent(path,ExtensionPath,extension);
2585  }
2586 #endif
2587 #if defined(MAGICKCORE_BZLIB_DELEGATE)
2588  if (*extension != '\0')
2589  if (LocaleCompare(extension,"bz2") == 0)
2590  {
2591  char
2592  path[MaxTextExtent];
2593 
2594  (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
2595  path[strlen(path)-strlen(extension)-1]='\0';
2596  GetPathComponent(path,ExtensionPath,extension);
2597  }
2598 #endif
2599  image_info->affirm=MagickFalse;
2600  sans_exception=AcquireExceptionInfo();
2601  if (*extension != '\0')
2602  {
2604  format_type;
2605 
2606  register ssize_t
2607  i;
2608 
2609  static const char
2610  *format_type_formats[] =
2611  {
2612  "AUTOTRACE",
2613  "BROWSE",
2614  "DCRAW",
2615  "EDIT",
2616  "EPHEMERAL",
2617  "LAUNCH",
2618  "MPEG:DECODE",
2619  "MPEG:ENCODE",
2620  "PRINT",
2621  "PS:ALPHA",
2622  "PS:CMYK",
2623  "PS:COLOR",
2624  "PS:GRAY",
2625  "PS:MONO",
2626  "SCAN",
2627  "SHOW",
2628  "WIN",
2629  (char *) NULL
2630  };
2631 
2632  /*
2633  User specified image format.
2634  */
2635  (void) CopyMagickString(magic,extension,MaxTextExtent);
2636  LocaleUpper(magic);
2637  /*
2638  Look for explicit image formats.
2639  */
2640  format_type=UndefinedFormatType;
2641  i=0;
2642  while ((format_type == UndefinedFormatType) &&
2643  (format_type_formats[i] != (char *) NULL))
2644  {
2645  if ((*magic == *format_type_formats[i]) &&
2646  (LocaleCompare(magic,format_type_formats[i]) == 0))
2647  format_type=ExplicitFormatType;
2648  i++;
2649  }
2650  magick_info=GetMagickInfo(magic,sans_exception);
2651  if ((magick_info != (const MagickInfo *) NULL) &&
2652  (magick_info->format_type != UndefinedFormatType))
2653  format_type=magick_info->format_type;
2654  if (format_type == UndefinedFormatType)
2655  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2656  else
2657  if (format_type == ExplicitFormatType)
2658  {
2659  image_info->affirm=MagickTrue;
2660  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2661  }
2662  if (LocaleCompare(magic,"RGB") == 0)
2663  image_info->affirm=MagickFalse; /* maybe SGI disguised as RGB */
2664  }
2665  /*
2666  Look for explicit 'format:image' in filename.
2667  */
2668  *magic='\0';
2669  GetPathComponent(image_info->filename,MagickPath,magic);
2670  if (*magic == '\0')
2671  (void) CopyMagickString(magic,image_info->magick,MaxTextExtent);
2672  else
2673  {
2674  /*
2675  User specified image format.
2676  */
2677  LocaleUpper(magic);
2678  if (IsMagickConflict(magic) == MagickFalse)
2679  {
2680  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2681  if (LocaleCompare(magic,"EPHEMERAL") != 0)
2682  image_info->affirm=MagickTrue;
2683  else
2684  image_info->temporary=MagickTrue;
2685  }
2686  }
2687  magick_info=GetMagickInfo(magic,sans_exception);
2688  sans_exception=DestroyExceptionInfo(sans_exception);
2689  if ((magick_info == (const MagickInfo *) NULL) ||
2690  (GetMagickEndianSupport(magick_info) == MagickFalse))
2691  image_info->endian=UndefinedEndian;
2692  GetPathComponent(image_info->filename,CanonicalPath,filename);
2693  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2694  if ((image_info->adjoin != MagickFalse) && (frames > 1))
2695  {
2696  /*
2697  Test for multiple image support (e.g. image%02d.png).
2698  */
2699  (void) InterpretImageFilename(image_info,(Image *) NULL,
2700  image_info->filename,(int) image_info->scene,filename);
2701  if ((LocaleCompare(filename,image_info->filename) != 0) &&
2702  (strchr(filename,'%') == (char *) NULL))
2703  image_info->adjoin=MagickFalse;
2704  }
2705  if ((image_info->adjoin != MagickFalse) && (frames > 0))
2706  {
2707  /*
2708  Some image formats do not support multiple frames per file.
2709  */
2710  magick_info=GetMagickInfo(magic,exception);
2711  if (magick_info != (const MagickInfo *) NULL)
2712  if (GetMagickAdjoin(magick_info) == MagickFalse)
2713  image_info->adjoin=MagickFalse;
2714  }
2715  if (image_info->affirm != MagickFalse)
2716  return(MagickTrue);
2717  if (frames == 0)
2718  {
2719  /*
2720  Determine the image format from the first few bytes of the file.
2721  */
2722  image=AcquireImage(image_info);
2723  (void) CopyMagickString(image->filename,image_info->filename,
2724  MaxTextExtent);
2725  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2726  if (status == MagickFalse)
2727  {
2728  image=DestroyImage(image);
2729  return(MagickFalse);
2730  }
2731  if ((IsBlobSeekable(image) == MagickFalse) ||
2732  (IsBlobExempt(image) != MagickFalse))
2733  {
2734  /*
2735  Copy standard input or pipe to temporary file.
2736  */
2737  *filename='\0';
2738  status=ImageToFile(image,filename,exception);
2739  (void) CloseBlob(image);
2740  if (status == MagickFalse)
2741  {
2742  image=DestroyImage(image);
2743  return(MagickFalse);
2744  }
2745  SetImageInfoFile(image_info,(FILE *) NULL);
2746  (void) CopyMagickString(image->filename,filename,MaxTextExtent);
2747  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2748  if (status == MagickFalse)
2749  {
2750  image=DestroyImage(image);
2751  return(MagickFalse);
2752  }
2753  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2754  image_info->temporary=MagickTrue;
2755  }
2756  (void) ResetMagickMemory(magick,0,sizeof(magick));
2757  count=ReadBlob(image,2*MaxTextExtent,magick);
2758  (void) SeekBlob(image,-((MagickOffsetType) count),SEEK_CUR);
2759  (void) CloseBlob(image);
2760  image=DestroyImage(image);
2761  /*
2762  Check magic.xml configuration file.
2763  */
2764  sans_exception=AcquireExceptionInfo();
2765  magic_info=GetMagicInfo(magick,(size_t) count,sans_exception);
2766  if ((magic_info != (const MagicInfo *) NULL) &&
2767  (GetMagicName(magic_info) != (char *) NULL))
2768  {
2769  (void) CopyMagickString(image_info->magick,GetMagicName(magic_info),
2770  MaxTextExtent);
2771  magick_info=GetMagickInfo(image_info->magick,sans_exception);
2772  if ((magick_info == (const MagickInfo *) NULL) ||
2773  (GetMagickEndianSupport(magick_info) == MagickFalse))
2774  image_info->endian=UndefinedEndian;
2775  sans_exception=DestroyExceptionInfo(sans_exception);
2776  return(MagickTrue);
2777  }
2778  magick_info=GetMagickInfo(image_info->magick,sans_exception);
2779  if ((magick_info == (const MagickInfo *) NULL) ||
2780  (GetMagickEndianSupport(magick_info) == MagickFalse))
2781  image_info->endian=UndefinedEndian;
2782  sans_exception=DestroyExceptionInfo(sans_exception);
2783  }
2784  return(MagickTrue);
2785 }
2786 
2787 /*
2788 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2789 % %
2790 % %
2791 % %
2792 % S e t I m a g e I n f o B l o b %
2793 % %
2794 % %
2795 % %
2796 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2797 %
2798 % SetImageInfoBlob() sets the image info blob member.
2799 %
2800 % The format of the SetImageInfoBlob method is:
2801 %
2802 % void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
2803 % const size_t length)
2804 %
2805 % A description of each parameter follows:
2806 %
2807 % o image_info: the image info.
2808 %
2809 % o blob: the blob.
2810 %
2811 % o length: the blob length.
2812 %
2813 */
2814 MagickExport void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
2815  const size_t length)
2816 {
2817  assert(image_info != (ImageInfo *) NULL);
2818  assert(image_info->signature == MagickSignature);
2819  if (image_info->debug != MagickFalse)
2821  image_info->filename);
2822  image_info->blob=(void *) blob;
2823  image_info->length=length;
2824 }
2825 
2826 /*
2827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2828 % %
2829 % %
2830 % %
2831 % S e t I m a g e I n f o F i l e %
2832 % %
2833 % %
2834 % %
2835 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2836 %
2837 % SetImageInfoFile() sets the image info file member.
2838 %
2839 % The format of the SetImageInfoFile method is:
2840 %
2841 % void SetImageInfoFile(ImageInfo *image_info,FILE *file)
2842 %
2843 % A description of each parameter follows:
2844 %
2845 % o image_info: the image info.
2846 %
2847 % o file: the file.
2848 %
2849 */
2850 MagickExport void SetImageInfoFile(ImageInfo *image_info,FILE *file)
2851 {
2852  assert(image_info != (ImageInfo *) NULL);
2853  assert(image_info->signature == MagickSignature);
2854  if (image_info->debug != MagickFalse)
2856  image_info->filename);
2857  image_info->file=file;
2858 }
2859 
2860 /*
2861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2862 % %
2863 % %
2864 % %
2865 % S e t I m a g e M a s k %
2866 % %
2867 % %
2868 % %
2869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2870 %
2871 % SetImageMask() associates a mask with the image. The mask must be the same
2872 % dimensions as the image.
2873 %
2874 % The format of the SetImageMask method is:
2875 %
2876 % MagickBooleanType SetImageMask(Image *image,const Image *mask)
2877 %
2878 % A description of each parameter follows:
2879 %
2880 % o image: the image.
2881 %
2882 % o mask: the image mask.
2883 %
2884 */
2886 {
2887  assert(image != (Image *) NULL);
2888  if (image->debug != MagickFalse)
2889  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2890  assert(image->signature == MagickSignature);
2891  if (mask != (const Image *) NULL)
2892  if ((mask->columns != image->columns) || (mask->rows != image->rows))
2893  ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
2894  if (image->mask != (Image *) NULL)
2895  image->mask=DestroyImage(image->mask);
2896  image->mask=NewImageList();
2897  if (mask == (Image *) NULL)
2898  return(MagickTrue);
2900  return(MagickFalse);
2901  image->mask=CloneImage(mask,0,0,MagickTrue,&image->exception);
2902  if (image->mask == (Image *) NULL)
2903  return(MagickFalse);
2904  return(MagickTrue);
2905 }
2906 
2907 /*
2908 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2909 % %
2910 % %
2911 % %
2912 % S e t I m a g e O p a c i t y %
2913 % %
2914 % %
2915 % %
2916 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2917 %
2918 % SetImageOpacity() sets the opacity levels of the image.
2919 %
2920 % The format of the SetImageOpacity method is:
2921 %
2922 % MagickBooleanType SetImageOpacity(Image *image,const Quantum opacity)
2923 %
2924 % A description of each parameter follows:
2925 %
2926 % o image: the image.
2927 %
2928 % o opacity: the level of transparency: 0 is fully opaque and QuantumRange is
2929 % fully transparent.
2930 %
2931 */
2933  const Quantum opacity)
2934 {
2935  CacheView
2936  *image_view;
2937 
2939  *exception;
2940 
2942  status;
2943 
2944  ssize_t
2945  y;
2946 
2947  assert(image != (Image *) NULL);
2948  if (image->debug != MagickFalse)
2949  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2950  assert(image->signature == MagickSignature);
2951  image->matte=MagickTrue;
2952  status=MagickTrue;
2953  exception=(&image->exception);
2954  image_view=AcquireAuthenticCacheView(image,exception);
2955 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2956  #pragma omp parallel for schedule(static,4) shared(status) \
2957  magick_threads(image,image,image->rows,1)
2958 #endif
2959  for (y=0; y < (ssize_t) image->rows; y++)
2960  {
2961  register PixelPacket
2962  *restrict q;
2963 
2964  register ssize_t
2965  x;
2966 
2967  if (status == MagickFalse)
2968  continue;
2969  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2970  if (q == (PixelPacket *) NULL)
2971  {
2972  status=MagickFalse;
2973  continue;
2974  }
2975  for (x=0; x < (ssize_t) image->columns; x++)
2976  {
2977  SetPixelOpacity(q,opacity);
2978  q++;
2979  }
2980  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2981  status=MagickFalse;
2982  }
2983  image_view=DestroyCacheView(image_view);
2984  return(status);
2985 }
2986 
2987 /*
2988 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2989 % %
2990 % %
2991 % %
2992 % 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 %
2993 % %
2994 % %
2995 % %
2996 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2997 %
2998 % SetImageVirtualPixelMethod() sets the "virtual pixels" method for the
2999 % image and returns the previous setting. A virtual pixel is any pixel access
3000 % that is outside the boundaries of the image cache.
3001 %
3002 % The format of the SetImageVirtualPixelMethod() method is:
3003 %
3004 % VirtualPixelMethod SetImageVirtualPixelMethod(const Image *image,
3005 % const VirtualPixelMethod virtual_pixel_method)
3006 %
3007 % A description of each parameter follows:
3008 %
3009 % o image: the image.
3010 %
3011 % o virtual_pixel_method: choose the type of virtual pixel.
3012 %
3013 */
3015  const VirtualPixelMethod virtual_pixel_method)
3016 {
3017  assert(image != (const Image *) NULL);
3018  assert(image->signature == MagickSignature);
3019  if (image->debug != MagickFalse)
3020  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3021  return(SetPixelCacheVirtualMethod(image,virtual_pixel_method));
3022 }
3023 
3024 /*
3025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3026 % %
3027 % %
3028 % %
3029 % S m u s h I m a g e s %
3030 % %
3031 % %
3032 % %
3033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3034 %
3035 % SmushImages() takes all images from the current image pointer to the end
3036 % of the image list and smushes them to each other top-to-bottom if the
3037 % stack parameter is true, otherwise left-to-right.
3038 %
3039 % The current gravity setting now effects how the image is justified in the
3040 % final image.
3041 %
3042 % The format of the SmushImages method is:
3043 %
3044 % Image *SmushImages(const Image *images,const MagickBooleanType stack,
3045 % ExceptionInfo *exception)
3046 %
3047 % A description of each parameter follows:
3048 %
3049 % o images: the image sequence.
3050 %
3051 % o stack: A value other than 0 stacks the images top-to-bottom.
3052 %
3053 % o offset: minimum distance in pixels between images.
3054 %
3055 % o exception: return any errors or warnings in this structure.
3056 %
3057 */
3058 
3059 static ssize_t SmushXGap(const Image *smush_image,const Image *images,
3060  const ssize_t offset,ExceptionInfo *exception)
3061 {
3062  CacheView
3063  *left_view,
3064  *right_view;
3065 
3066  const Image
3067  *left_image,
3068  *right_image;
3069 
3071  left_geometry,
3072  right_geometry;
3073 
3074  register const PixelPacket
3075  *p;
3076 
3077  register ssize_t
3078  i,
3079  y;
3080 
3081  size_t
3082  gap;
3083 
3084  ssize_t
3085  x;
3086 
3087  if (images->previous == (Image *) NULL)
3088  return(0);
3089  right_image=images;
3090  SetGeometry(smush_image,&right_geometry);
3091  GravityAdjustGeometry(right_image->columns,right_image->rows,
3092  right_image->gravity,&right_geometry);
3093  left_image=images->previous;
3094  SetGeometry(smush_image,&left_geometry);
3095  GravityAdjustGeometry(left_image->columns,left_image->rows,
3096  left_image->gravity,&left_geometry);
3097  gap=right_image->columns;
3098  left_view=AcquireVirtualCacheView(left_image,exception);
3099  right_view=AcquireVirtualCacheView(right_image,exception);
3100  for (y=0; y < (ssize_t) smush_image->rows; y++)
3101  {
3102  for (x=(ssize_t) left_image->columns-1; x > 0; x--)
3103  {
3104  p=GetCacheViewVirtualPixels(left_view,x,left_geometry.y+y,1,1,exception);
3105  if ((p == (const PixelPacket *) NULL) ||
3107  ((left_image->columns-x-1) >= gap))
3108  break;
3109  }
3110  i=(ssize_t) left_image->columns-x-1;
3111  for (x=0; x < (ssize_t) right_image->columns; x++)
3112  {
3113  p=GetCacheViewVirtualPixels(right_view,x,right_geometry.y+y,1,1,
3114  exception);
3115  if ((p == (const PixelPacket *) NULL) ||
3117  ((x+i) >= (ssize_t) gap))
3118  break;
3119  }
3120  if ((x+i) < (ssize_t) gap)
3121  gap=(size_t) (x+i);
3122  }
3123  right_view=DestroyCacheView(right_view);
3124  left_view=DestroyCacheView(left_view);
3125  if (y < (ssize_t) smush_image->rows)
3126  return(offset);
3127  return((ssize_t) gap-offset);
3128 }
3129 
3130 static ssize_t SmushYGap(const Image *smush_image,const Image *images,
3131  const ssize_t offset,ExceptionInfo *exception)
3132 {
3133  CacheView
3134  *bottom_view,
3135  *top_view;
3136 
3137  const Image
3138  *bottom_image,
3139  *top_image;
3140 
3142  bottom_geometry,
3143  top_geometry;
3144 
3145  register const PixelPacket
3146  *p;
3147 
3148  register ssize_t
3149  i,
3150  x;
3151 
3152  size_t
3153  gap;
3154 
3155  ssize_t
3156  y;
3157 
3158  if (images->previous == (Image *) NULL)
3159  return(0);
3160  bottom_image=images;
3161  SetGeometry(smush_image,&bottom_geometry);
3162  GravityAdjustGeometry(bottom_image->columns,bottom_image->rows,
3163  bottom_image->gravity,&bottom_geometry);
3164  top_image=images->previous;
3165  SetGeometry(smush_image,&top_geometry);
3166  GravityAdjustGeometry(top_image->columns,top_image->rows,top_image->gravity,
3167  &top_geometry);
3168  gap=bottom_image->rows;
3169  top_view=AcquireVirtualCacheView(top_image,exception);
3170  bottom_view=AcquireVirtualCacheView(bottom_image,exception);
3171  for (x=0; x < (ssize_t) smush_image->columns; x++)
3172  {
3173  for (y=(ssize_t) top_image->rows-1; y > 0; y--)
3174  {
3175  p=GetCacheViewVirtualPixels(top_view,top_geometry.x+x,y,1,1,exception);
3176  if ((p == (const PixelPacket *) NULL) ||
3178  ((top_image->rows-y-1) >= gap))
3179  break;
3180  }
3181  i=(ssize_t) top_image->rows-y-1;
3182  for (y=0; y < (ssize_t) bottom_image->rows; y++)
3183  {
3184  p=GetCacheViewVirtualPixels(bottom_view,bottom_geometry.x+x,y,1,1,
3185  exception);
3186  if ((p == (const PixelPacket *) NULL) ||
3188  ((y+i) >= (ssize_t) gap))
3189  break;
3190  }
3191  if ((y+i) < (ssize_t) gap)
3192  gap=(size_t) (y+i);
3193  }
3194  bottom_view=DestroyCacheView(bottom_view);
3195  top_view=DestroyCacheView(top_view);
3196  if (x < (ssize_t) smush_image->columns)
3197  return(offset);
3198  return((ssize_t) gap-offset);
3199 }
3200 
3202  const MagickBooleanType stack,const ssize_t offset,ExceptionInfo *exception)
3203 {
3204 #define SmushImageTag "Smush/Image"
3205 
3206  CacheView
3207  *smush_view;
3208 
3209  const Image
3210  *image;
3211 
3212  Image
3213  *smush_image;
3214 
3216  matte,
3217  proceed,
3218  status;
3219 
3221  n;
3222 
3224  geometry;
3225 
3226  register const Image
3227  *next;
3228 
3229  size_t
3230  height,
3231  number_images,
3232  width;
3233 
3234  ssize_t
3235  x_offset,
3236  y_offset;
3237 
3238  /*
3239  Compute maximum area of smushed area.
3240  */
3241  assert(images != (Image *) NULL);
3242  assert(images->signature == MagickSignature);
3243  if (images->debug != MagickFalse)
3244  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3245  assert(exception != (ExceptionInfo *) NULL);
3246  assert(exception->signature == MagickSignature);
3247  image=images;
3248  matte=image->matte;
3249  number_images=1;
3250  width=image->columns;
3251  height=image->rows;
3252  next=GetNextImageInList(image);
3253  for ( ; next != (Image *) NULL; next=GetNextImageInList(next))
3254  {
3255  if (next->matte != MagickFalse)
3256  matte=MagickTrue;
3257  number_images++;
3258  if (stack != MagickFalse)
3259  {
3260  if (next->columns > width)
3261  width=next->columns;
3262  height+=next->rows;
3263  if (next->previous != (Image *) NULL)
3264  height+=offset;
3265  continue;
3266  }
3267  width+=next->columns;
3268  if (next->previous != (Image *) NULL)
3269  width+=offset;
3270  if (next->rows > height)
3271  height=next->rows;
3272  }
3273  /*
3274  Smush images.
3275  */
3276  smush_image=CloneImage(image,width,height,MagickTrue,exception);
3277  if (smush_image == (Image *) NULL)
3278  return((Image *) NULL);
3279  if (SetImageStorageClass(smush_image,DirectClass) == MagickFalse)
3280  {
3281  InheritException(exception,&smush_image->exception);
3282  smush_image=DestroyImage(smush_image);
3283  return((Image *) NULL);
3284  }
3285  smush_image->matte=matte;
3286  (void) SetImageBackgroundColor(smush_image);
3287  status=MagickTrue;
3288  x_offset=0;
3289  y_offset=0;
3290  smush_view=AcquireVirtualCacheView(smush_image,exception);
3291  for (n=0; n < (MagickOffsetType) number_images; n++)
3292  {
3293  SetGeometry(smush_image,&geometry);
3294  GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
3295  if (stack != MagickFalse)
3296  {
3297  x_offset-=geometry.x;
3298  y_offset-=SmushYGap(smush_image,image,offset,exception);
3299  }
3300  else
3301  {
3302  x_offset-=SmushXGap(smush_image,image,offset,exception);
3303  y_offset-=geometry.y;
3304  }
3305  status=CompositeImage(smush_image,OverCompositeOp,image,x_offset,y_offset);
3306  proceed=SetImageProgress(image,SmushImageTag,n,number_images);
3307  if (proceed == MagickFalse)
3308  break;
3309  if (stack == MagickFalse)
3310  {
3311  x_offset+=(ssize_t) image->columns;
3312  y_offset=0;
3313  }
3314  else
3315  {
3316  x_offset=0;
3317  y_offset+=(ssize_t) image->rows;
3318  }
3319  image=GetNextImageInList(image);
3320  }
3321  if (stack == MagickFalse)
3322  smush_image->columns=(size_t) x_offset;
3323  else
3324  smush_image->rows=(size_t) y_offset;
3325  smush_view=DestroyCacheView(smush_view);
3326  if (status == MagickFalse)
3327  smush_image=DestroyImage(smush_image);
3328  return(smush_image);
3329 }
3330 
3331 /*
3332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3333 % %
3334 % %
3335 % %
3336 % S t r i p I m a g e %
3337 % %
3338 % %
3339 % %
3340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3341 %
3342 % StripImage() strips an image of all profiles and comments.
3343 %
3344 % The format of the StripImage method is:
3345 %
3346 % MagickBooleanType StripImage(Image *image)
3347 %
3348 % A description of each parameter follows:
3349 %
3350 % o image: the image.
3351 %
3352 */
3354 {
3355  assert(image != (Image *) NULL);
3356  if (image->debug != MagickFalse)
3357  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3358  DestroyImageProfiles(image);
3359  (void) DeleteImageProperty(image,"comment");
3360  (void) DeleteImageProperty(image,"date:create");
3361  (void) DeleteImageProperty(image,"date:modify");
3362  (void) SetImageArtifact(image,"png:include-chunk","none,trns,gama");
3363  return(MagickTrue);
3364 }
3365 
3366 /*
3367 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3368 % %
3369 % %
3370 % %
3371 + S y n c I m a g e %
3372 % %
3373 % %
3374 % %
3375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3376 %
3377 % SyncImage() initializes the red, green, and blue intensities of each pixel
3378 % as defined by the colormap index.
3379 %
3380 % The format of the SyncImage method is:
3381 %
3382 % MagickBooleanType SyncImage(Image *image)
3383 %
3384 % A description of each parameter follows:
3385 %
3386 % o image: the image.
3387 %
3388 */
3389 
3390 static inline IndexPacket PushColormapIndex(Image *image,
3391  const size_t index,MagickBooleanType *range_exception)
3392 {
3393  if (index < image->colors)
3394  return((IndexPacket) index);
3395  *range_exception=MagickTrue;
3396  return((IndexPacket) 0);
3397 }
3398 
3400 {
3401  CacheView
3402  *image_view;
3403 
3405  *exception;
3406 
3408  range_exception,
3409  status;
3410 
3411  ssize_t
3412  y;
3413 
3414  assert(image != (Image *) NULL);
3415  if (image->debug != MagickFalse)
3416  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3417  assert(image->signature == MagickSignature);
3418  if (image->storage_class == DirectClass)
3419  return(MagickFalse);
3420  range_exception=MagickFalse;
3421  status=MagickTrue;
3422  exception=(&image->exception);
3423  image_view=AcquireAuthenticCacheView(image,exception);
3424 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3425  #pragma omp parallel for schedule(static,4) shared(range_exception,status) \
3426  magick_threads(image,image,image->rows,1)
3427 #endif
3428  for (y=0; y < (ssize_t) image->rows; y++)
3429  {
3430  IndexPacket
3431  index;
3432 
3433  register IndexPacket
3434  *restrict indexes;
3435 
3436  register PixelPacket
3437  *restrict q;
3438 
3439  register ssize_t
3440  x;
3441 
3442  if (status == MagickFalse)
3443  continue;
3444  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3445  if (q == (PixelPacket *) NULL)
3446  {
3447  status=MagickFalse;
3448  continue;
3449  }
3450  indexes=GetCacheViewAuthenticIndexQueue(image_view);
3451  for (x=0; x < (ssize_t) image->columns; x++)
3452  {
3453  index=PushColormapIndex(image,(size_t) GetPixelIndex(indexes+x),
3454  &range_exception);
3455  if (image->matte == MagickFalse)
3456  SetPixelRgb(q,image->colormap+(ssize_t) index)
3457  else
3458  SetPixelRGBO(q,image->colormap+(ssize_t) index);
3459  q++;
3460  }
3461  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3462  status=MagickFalse;
3463  }
3464  image_view=DestroyCacheView(image_view);
3465  if ((image->ping == MagickFalse) && (range_exception != MagickFalse))
3467  CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
3468  return(status);
3469 }
3470 
3471 /*
3472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3473 % %
3474 % %
3475 % %
3476 % S y n c I m a g e S e t t i n g s %
3477 % %
3478 % %
3479 % %
3480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3481 %
3482 % SyncImageSettings() syncs image_info options into per-image attributes.
3483 %
3484 % The format of the SyncImageSettings method is:
3485 %
3486 % MagickBooleanType SyncImageSettings(const ImageInfo *image_info,
3487 % Image *image)
3488 % MagickBooleanType SyncImagesSettings(const ImageInfo *image_info,
3489 % Image *image)
3490 %
3491 % A description of each parameter follows:
3492 %
3493 % o image_info: the image info.
3494 %
3495 % o image: the image.
3496 %
3497 */
3498 
3500  Image *images)
3501 {
3502  Image
3503  *image;
3504 
3505  assert(image_info != (const ImageInfo *) NULL);
3506  assert(image_info->signature == MagickSignature);
3507  assert(images != (Image *) NULL);
3508  assert(images->signature == MagickSignature);
3509  if (images->debug != MagickFalse)
3510  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3511  image=images;
3512  for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
3513  (void) SyncImageSettings(image_info,image);
3514  (void) DeleteImageOption(image_info,"page");
3515  return(MagickTrue);
3516 }
3517 
3519  Image *image)
3520 {
3521  char
3522  property[MaxTextExtent];
3523 
3524  const char
3525  *option,
3526  *value;
3527 
3528  GeometryInfo
3529  geometry_info;
3530 
3532  flags;
3533 
3535  units;
3536 
3537  /*
3538  Sync image options.
3539  */
3540  assert(image_info != (const ImageInfo *) NULL);
3541  assert(image_info->signature == MagickSignature);
3542  assert(image != (Image *) NULL);
3543  assert(image->signature == MagickSignature);
3544  if (image->debug != MagickFalse)
3545  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3546  option=GetImageOption(image_info,"background");
3547  if (option != (const char *) NULL)
3548  (void) QueryColorDatabase(option,&image->background_color,
3549  &image->exception);
3550  option=GetImageOption(image_info,"bias");
3551  if (option != (const char *) NULL)
3552  image->bias=StringToDoubleInterval(option,(double) QuantumRange+1.0);
3553  option=GetImageOption(image_info,"black-point-compensation");
3554  if (option != (const char *) NULL)
3557  option=GetImageOption(image_info,"blue-primary");
3558  if (option != (const char *) NULL)
3559  {
3560  flags=ParseGeometry(option,&geometry_info);
3561  image->chromaticity.blue_primary.x=geometry_info.rho;
3562  image->chromaticity.blue_primary.y=geometry_info.sigma;
3563  if ((flags & SigmaValue) == 0)
3565  }
3566  option=GetImageOption(image_info,"bordercolor");
3567  if (option != (const char *) NULL)
3568  (void) QueryColorDatabase(option,&image->border_color,&image->exception);
3569  option=GetImageOption(image_info,"colors");
3570  if (option != (const char *) NULL)
3571  image->colors=StringToUnsignedLong(option);
3572  option=GetImageOption(image_info,"compose");
3573  if (option != (const char *) NULL)
3575  MagickFalse,option);
3576  option=GetImageOption(image_info,"compress");
3577  if (option != (const char *) NULL)
3580  option=GetImageOption(image_info,"debug");
3581  if (option != (const char *) NULL)
3583  MagickFalse,option);
3584  option=GetImageOption(image_info,"density");
3585  if (option != (const char *) NULL)
3586  {
3587  GeometryInfo
3588  geometry_info;
3589 
3590  /*
3591  Set image density.
3592  */
3593  flags=ParseGeometry(option,&geometry_info);
3594  image->x_resolution=geometry_info.rho;
3595  image->y_resolution=geometry_info.sigma;
3596  if ((flags & SigmaValue) == 0)
3597  image->y_resolution=image->x_resolution;
3598  }
3599  option=GetImageOption(image_info,"depth");
3600  if (option != (const char *) NULL)
3601  image->depth=StringToUnsignedLong(option);
3602  option=GetImageOption(image_info,"endian");
3603  if (option != (const char *) NULL)
3605  MagickFalse,option);
3606  option=GetImageOption(image_info,"filter");
3607  if (option != (const char *) NULL)
3609  MagickFalse,option);
3610  option=GetImageOption(image_info,"fuzz");
3611  if (option != (const char *) NULL)
3612  image->fuzz=StringToDoubleInterval(option,(double) QuantumRange+1.0);
3613  option=GetImageOption(image_info,"gravity");
3614  if (option != (const char *) NULL)
3616  MagickFalse,option);
3617  option=GetImageOption(image_info,"green-primary");
3618  if (option != (const char *) NULL)
3619  {
3620  flags=ParseGeometry(option,&geometry_info);
3621  image->chromaticity.green_primary.x=geometry_info.rho;
3622  image->chromaticity.green_primary.y=geometry_info.sigma;
3623  if ((flags & SigmaValue) == 0)
3625  }
3626  option=GetImageOption(image_info,"intensity");
3627  if (option != (const char *) NULL)
3630  option=GetImageOption(image_info,"intent");
3631  if (option != (const char *) NULL)
3634  option=GetImageOption(image_info,"interlace");
3635  if (option != (const char *) NULL)
3637  MagickFalse,option);
3638  option=GetImageOption(image_info,"interpolate");
3639  if (option != (const char *) NULL)
3642  option=GetImageOption(image_info,"loop");
3643  if (option != (const char *) NULL)
3644  image->iterations=StringToUnsignedLong(option);
3645  option=GetImageOption(image_info,"mattecolor");
3646  if (option != (const char *) NULL)
3647  (void) QueryColorDatabase(option,&image->matte_color,&image->exception);
3648  option=GetImageOption(image_info,"orient");
3649  if (option != (const char *) NULL)
3652  option=GetImageOption(image_info,"page");
3653  if (option != (const char *) NULL)
3654  {
3655  char
3656  *geometry;
3657 
3658  geometry=GetPageGeometry(option);
3659  flags=ParseAbsoluteGeometry(geometry,&image->page);
3660  geometry=DestroyString(geometry);
3661  }
3662  option=GetImageOption(image_info,"quality");
3663  if (option != (const char *) NULL)
3664  image->quality=StringToUnsignedLong(option);
3665  option=GetImageOption(image_info,"red-primary");
3666  if (option != (const char *) NULL)
3667  {
3668  flags=ParseGeometry(option,&geometry_info);
3669  image->chromaticity.red_primary.x=geometry_info.rho;
3670  image->chromaticity.red_primary.y=geometry_info.sigma;
3671  if ((flags & SigmaValue) == 0)
3673  }
3674  if (image_info->quality != UndefinedCompressionQuality)
3675  image->quality=image_info->quality;
3676  option=GetImageOption(image_info,"scene");
3677  if (option != (const char *) NULL)
3678  image->scene=StringToUnsignedLong(option);
3679  option=GetImageOption(image_info,"taint");
3680  if (option != (const char *) NULL)
3682  MagickFalse,option);
3683  option=GetImageOption(image_info,"tile-offset");
3684  if (option != (const char *) NULL)
3685  {
3686  char
3687  *geometry;
3688 
3689  geometry=GetPageGeometry(option);
3690  flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3691  geometry=DestroyString(geometry);
3692  }
3693  option=GetImageOption(image_info,"transparent-color");
3694  if (option != (const char *) NULL)
3695  (void) QueryColorDatabase(option,&image->transparent_color,
3696  &image->exception);
3697  option=GetImageOption(image_info,"type");
3698  if (option != (const char *) NULL)
3700  option);
3701  option=GetImageOption(image_info,"units");
3702  if (option != (const char *) NULL)
3704  MagickFalse,option);
3705  else
3706  units = image_info->units;
3707  if (units != UndefinedResolution)
3708  {
3709  if (image->units != units)
3710  switch (image->units)
3711  {
3713  {
3714  if (units == PixelsPerCentimeterResolution)
3715  {
3716  image->x_resolution/=2.54;
3717  image->y_resolution/=2.54;
3718  }
3719  break;
3720  }
3722  {
3723  if (units == PixelsPerInchResolution)
3724  {
3725  image->x_resolution=(double) ((size_t) (100.0*2.54*
3726  image->x_resolution+0.5))/100.0;
3727  image->y_resolution=(double) ((size_t) (100.0*2.54*
3728  image->y_resolution+0.5))/100.0;
3729  }
3730  break;
3731  }
3732  default:
3733  break;
3734  }
3735  image->units=units;
3736  }
3737  option=GetImageOption(image_info,"white-point");
3738  if (option != (const char *) NULL)
3739  {
3740  flags=ParseGeometry(option,&geometry_info);
3741  image->chromaticity.white_point.x=geometry_info.rho;
3742  image->chromaticity.white_point.y=geometry_info.sigma;
3743  if ((flags & SigmaValue) == 0)
3745  }
3746  ResetImageOptionIterator(image_info);
3747  for (option=GetNextImageOption(image_info); option != (const char *) NULL; )
3748  {
3749  value=GetImageOption(image_info,option);
3750  if (value != (const char *) NULL)
3751  {
3752  (void) FormatLocaleString(property,MaxTextExtent,"%s",option);
3753  (void) SetImageArtifact(image,property,value);
3754  }
3755  option=GetNextImageOption(image_info);
3756  }
3757  return(MagickTrue);
3758 }
size_t rows
Definition: image.h:172
MagickExport FILE * GetImageInfoFile(const ImageInfo *image_info)
Definition: image.c:1329
PixelIntensityMethod intensity
Definition: image.h:350
MagickExport CacheView * DestroyCacheView(CacheView *cache_view)
Definition: cache-view.c:254
double y_resolution
Definition: image.h:207
char filename[MaxTextExtent]
Definition: image.h:465
EndianType endian
Definition: image.h:385
MagickRealType opacity
Definition: pixel.h:122
#define GetPixelBlue(pixel)
size_t signature
Definition: image.h:484
struct _Image * list
Definition: image.h:307
static MagickBooleanType SetImageProgress(const Image *image, const char *tag, const MagickOffsetType offset, const MagickSizeType extent)
const char DefaultTileGeometry[]
Definition: image.c:109
MagickExport Image * NewMagickImage(const ImageInfo *image_info, const size_t width, const size_t height, const MagickPixelPacket *background)
Definition: image.c:1926
size_t subimage
Definition: image.h:477
MagickExport ImageInfo * AcquireImageInfo(void)
Definition: image.c:329
InterlaceType interlace
Definition: image.h:224
MagickExport void DestroyImagePixels(Image *image)
Definition: cache.c:827
#define GetPixelOpacity(pixel)
ColorspaceType colorspace
Definition: pixel.h:110
DisposeType dispose
Definition: image.h:236
size_t depth
Definition: pixel.h:119
Ascii85Info * ascii85
Definition: image.h:270
MagickProgressMonitor progress_monitor
Definition: image.h:262
char * scenes
Definition: image.h:371
ImageType type
Definition: image.h:332
size_t iterations
Definition: image.h:249
MagickExport ExceptionType CatchImageException(Image *image)
Definition: image.c:633
ssize_t ticks_per_second
Definition: image.h:246
size_t subrange
Definition: image.h:477
MagickExport SemaphoreInfo * AllocateSemaphoreInfo(void)
Definition: semaphore.c:191
MagickExport Image * ReferenceImage(Image *image)
Definition: image.c:2021
MagickExport MagickBooleanType DeleteImageOption(ImageInfo *image_info, const char *option)
Definition: option.c:1781
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:449
MagickExport void Ascii85Initialize(Image *image)
Definition: compress.c:268
double pointsize
Definition: image.h:401
const char LoadImageTag[]
Definition: image.c:112
MagickExport void DestroySemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:292
InterpolatePixelMethod
Definition: pixel.h:31
const char TransparentColor[]
Definition: image.c:119
MagickExport ssize_t ParseCommandOption(const CommandOption option, const MagickBooleanType list, const char *options)
Definition: option.c:2414
const char SaveImageTag[]
Definition: image.c:117
OrientationType
Definition: image.h:75
MagickBooleanType ping
Definition: image.h:341
char * extract
Definition: image.h:371
MagickExport MagickBooleanType SyncImagesSettings(ImageInfo *image_info, Image *images)
Definition: image.c:3499
#define ThrowFatalException(severity, tag)
double x
Definition: image.h:98
#define GetPixelGreen(pixel)
size_t signature
Definition: exception.h:124
#define SmushImageTag
MagickExport VirtualPixelMethod SetImageVirtualPixelMethod(const Image *image, const VirtualPixelMethod virtual_pixel_method)
Definition: image.c:3014
size_t number_scenes
Definition: image.h:377
char * sampling_factor
Definition: image.h:394
const char ForegroundColor[]
Definition: image.c:111
double rho
Definition: geometry.h:107
MagickExport VirtualPixelMethod SetPixelCacheVirtualMethod(const Image *image, const VirtualPixelMethod virtual_pixel_method)
Definition: cache.c:4904
MagickExport MagickStatusType ParseAbsoluteGeometry(const char *geometry, RectangleInfo *region_info)
Definition: geometry.c:662
MagickExport const char * GetMagicName(const MagicInfo *magic_info)
Definition: magic.c:591
EndianType endian
Definition: image.h:227
MagickBooleanType taint
Definition: image.h:168
MagickExport size_t ConcatenateMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:410
PixelIntensityMethod
Definition: pixel.h:67
MagickBooleanType debug
Definition: image.h:471
char * font
Definition: image.h:394
MagickExport MagickBooleanType SetImageArtifact(Image *image, const char *artifact, const char *value)
Definition: artifact.c:431
MagickExport MagickBooleanType SyncImageSettings(const ImageInfo *image_info, Image *image)
Definition: image.c:3518
MagickExport Cache ReferencePixelCache(Cache)
Definition: cache.c:4527
MagickPrivate MagickBooleanType SyncImagePixelCache(Image *, ExceptionInfo *)
Definition: cache.c:5134
InterlaceType
Definition: image.h:63
VirtualPixelMethod
Definition: cache-view.h:27
const char BorderColor[]
Definition: image.c:107
ColorspaceType colorspace
Definition: image.h:417
MagickExport const char * GetImageArtifact(const Image *image, const char *artifact)
Definition: artifact.c:266
char magick[MaxTextExtent]
Definition: image.h:276
double z
Definition: image.h:98
MagickBooleanType antialias
Definition: image.h:365
const char PSDensityGeometry[]
Definition: image.c:115
size_t colors
Definition: image.h:414
MagickExport MagickBooleanType SetImageBackgroundColor(Image *image)
Definition: image.c:2126
MagickExport ExceptionInfo * AcquireExceptionInfo(void)
Definition: exception.c:101
MagickExport void DestroyImageProfiles(Image *image)
Definition: profile.c:223
MagickExport MagickBooleanType SetImageStorageClass(Image *image, const ClassType storage_class)
Definition: image.c:2354
static MagickBooleanType IsGrayColorspace(const ColorspaceType colorspace)
MagickExport void SetImageInfoBlob(ImageInfo *image_info, const void *blob, const size_t length)
Definition: image.c:2814
ResolutionType units
Definition: image.h:196
MagickExport MagickBooleanType SetImageChannels(Image *image, const size_t channels)
Definition: image.c:2233
size_t delay
Definition: image.h:242
size_t magick_rows
Definition: image.h:281
#define MAGICKCORE_QUANTUM_DEPTH
Definition: magick-type.h:28
MagickExport MagickBooleanType ImageToFile(Image *image, char *filename, ExceptionInfo *exception)
Definition: blob.c:1629
MagickExport MagickBooleanType SyncImage(Image *image)
Definition: image.c:3399
MagickBooleanType verbose
Definition: image.h:429
double bias
Definition: image.h:216
double blur
Definition: image.h:216
MagickExport char * GetPageGeometry(const char *page_geometry)
Definition: geometry.c:342
char magick_filename[MaxTextExtent]
Definition: image.h:276
Image * image
Definition: image-view.c:66
MagickFormatType format_type
Definition: magick.h:83
char * montage
Definition: image.h:199
CompressionType compression
Definition: image.h:159
double sigma
Definition: geometry.h:107
InterlaceType interlace
Definition: image.h:382
ClassType storage_class
Definition: image.h:153
char unique[MaxTextExtent]
Definition: image.h:465
size_t width
Definition: geometry.h:124
MagickExport ssize_t ReadBlob(Image *, const size_t, unsigned char *)
MagickExport BlobInfo * CloneBlobInfo(const BlobInfo *)
RectangleInfo tile_offset
Definition: image.h:325
#define ThrowBinaryException(severity, tag, context)
Definition: log.h:38
ssize_t MagickOffsetType
Definition: magick-type.h:155
#define GetPixelRed(pixel)
MagickExport void DestroyImageOptions(ImageInfo *image_info)
Definition: option.c:1816
EndianType
Definition: quantum.h:30
MagickExport MagickBooleanType ClipImagePath(Image *image, const char *pathname, const MagickBooleanType inside)
Definition: image.c:689
char * size
Definition: image.h:371
MagickExport void SetImageInfoFile(ImageInfo *image_info, FILE *file)
Definition: image.c:2850
Definition: image.h:150
void * cache
Definition: image.h:449
MagickExport VirtualPixelMethod GetImageVirtualPixelMethod(const Image *image)
Definition: image.c:1460
ExceptionType
Definition: exception.h:28
ImageType type
Definition: image.h:420
#define SetPixelGreen(pixel, value)
const char SaveImagesTag[]
Definition: image.c:118
StreamHandler stream
Definition: image.h:453
FilterTypes
Definition: resample.h:32
static IndexPacket PushColormapIndex(Image *image, const size_t index, MagickBooleanType *range_exception)
Definition: image.c:3390
MagickExport MagickBooleanType TransformImageColorspace(Image *image, const ColorspaceType colorspace)
Definition: colorspace.c:1182
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:344
MagickExport Cache DestroyPixelCache(Cache)
MagickExport const IndexPacket * GetCacheViewVirtualIndexQueue(const CacheView *cache_view)
Definition: cache-view.c:636
MagickExport MagickBooleanType CloneImageProperties(Image *image, const Image *clone_image)
Definition: property.c:130
#define UndefinedTicksPerSecond
Definition: image-private.h:33
#define MagickSignature
MagickExport MagickBooleanType IsGeometry(const char *geometry)
Definition: geometry.c:569
MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, const AlphaChannelType alpha_type)
Definition: channel.c:639
char magick[MaxTextExtent]
Definition: image.h:465
MagickExport void GetExceptionInfo(ExceptionInfo *exception)
Definition: exception.c:458
MagickExport Image * GetImageClipMask(const Image *image, ExceptionInfo *exception)
Definition: image.c:1189
MagickExport Image * BlobToImage(const ImageInfo *image_info, const void *blob, const size_t length, ExceptionInfo *exception)
Definition: blob.c:322
const double DefaultResolution
Definition: image.c:122
static ssize_t SmushXGap(const Image *smush_image, const Image *images, const ssize_t offset, ExceptionInfo *exception)
Definition: image.c:3059
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1198
ChannelType channel
Definition: image.h:437
MagickBooleanType
Definition: magick-type.h:211
MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *restrict cache_view, ExceptionInfo *exception)
Definition: cache-view.c:997
MagickExport Cache AcquirePixelCache(const size_t)
char filename[MaxTextExtent]
Definition: image.h:276
MagickExport Image * NewImageList(void)
Definition: list.c:918
PrimaryInfo red_primary
Definition: image.h:124
size_t scene
Definition: image.h:242
unsigned int MagickStatusType
Definition: magick-type.h:147
MagickExport char * AcquireString(const char *source)
Definition: string.c:120
MagickExport MagickBooleanType StripImage(Image *image)
Definition: image.c:3353
ClassType
Definition: magick-type.h:204
MagickExport void GetMagickPixelPacket(const Image *image, MagickPixelPacket *pixel)
Definition: pixel.c:2030
ExceptionInfo * exception
Definition: image-view.c:75
MagickExport const char * GetImageProperty(const Image *image, const char *property)
Definition: property.c:2066
const char PSPageGeometry[]
Definition: image.c:116
MagickBooleanType black_point_compensation
Definition: image.h:316
MagickExport MagickBooleanType IsImageObject(const Image *image)
Definition: image.c:1784
static unsigned long StringToUnsignedLong(const char *restrict value)
MagickExport void * ResetMagickMemory(void *memory, int byte, const size_t size)
Definition: memory.c:1079
PixelPacket transparent_color
Definition: image.h:319
size_t length
Definition: image.h:462
MagickExport MagickBooleanType IsMagickConflict(const char *)
MagickExport StringInfo * DestroyStringInfo(StringInfo *string_info)
Definition: string.c:835
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:529
VirtualPixelMethod virtual_pixel_method
Definition: image.h:487
MagickExport MagickBooleanType CloneImageProfiles(Image *image, const Image *clone_image)
Definition: profile.c:127
MagickExport void AcquireNextImage(const ImageInfo *image_info, Image *image)
Definition: image.c:369
MagickExport Image * AcquireImage(const ImageInfo *image_info)
Definition: image.c:149
void * blob
Definition: image.h:459
const char BackgroundColor[]
Definition: image.c:106
double fuzz
Definition: image.h:401
#define MaxTextExtent
GravityType gravity
Definition: image.h:230
MagickExport MagickBooleanType CloseBlob(Image *)
volatile ssize_t reference_count
Definition: image.h:291
size_t scene
Definition: image.h:377
RectangleInfo page
Definition: image.h:211
size_t channels
Definition: image.h:344
MagickExport void DestroyImageProperties(Image *image)
Definition: property.c:308
size_t magick_columns
Definition: image.h:281
#define UndefinedCompressionQuality
Definition: image-private.h:34
PixelPacket border_color
Definition: image.h:178
ResolutionType units
Definition: image.h:388
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: string.c:1523
const char LoadImagesTag[]
Definition: image.c:113
MagickExport MagickBooleanType IsStringTrue(const char *value)
Definition: string.c:1436
MagickExport MagickBooleanType IsEventLogging(void)
Definition: log.c:660
void * cache
Definition: image.h:265
#define SetPixelRed(pixel, value)
CompressionType compression
Definition: image.h:359
const char DefaultTileLabel[]
Definition: image.c:110
PrimaryInfo blue_primary
Definition: image.h:124
#define ThrowFileException(exception, severity, tag, context)
OrientationType orientation
Definition: image.h:362
MagickExport const PixelPacket * GetCacheViewVirtualPixels(const CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:721
#define SetPixelRgb(pixel, packet)
MagickExport void SetBlobExempt(Image *image, const MagickBooleanType exempt)
Definition: blob.c:3703
Quantum opacity
Definition: pixel.h:143
MagickBooleanType monochrome
Definition: image.h:410
#define TransparentOpacity
Definition: image.h:28
PixelPacket matte_color
Definition: image.h:405
MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1354
MagickExport const char * GetImageOption(const ImageInfo *image_info, const char *key)
Definition: option.c:1852
MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info, const unsigned int frames, ExceptionInfo *exception)
Definition: image.c:2483
GravityType
Definition: geometry.h:77
MagickBooleanType dither
Definition: image.h:335
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
Definition: exception.c:1044
PixelPacket pen
Definition: image.h:481
struct _Image * mask
Definition: image.h:321
MagickExport MagickOffsetType SeekBlob(Image *, const MagickOffsetType, const int)
size_t signature
Definition: image.h:305
MagickExport int LocaleNCompare(const char *p, const char *q, const size_t length)
Definition: string.c:1623
MagickExport VirtualPixelMethod GetPixelCacheVirtualMethod(const Image *image)
Definition: cache.c:2311
size_t columns
Definition: image.h:172
#define SetPixelRGBO(pixel, packet)
PreviewType preview_type
Definition: image.h:423
PixelPacket background_color
Definition: image.h:178
MagickExport size_t InterpretImageFilename(const ImageInfo *image_info, Image *image, const char *format, int value, char *filename)
Definition: image.c:1502
MagickExport const MagickInfo * GetMagickInfo(const char *name, ExceptionInfo *exception)
Definition: magick.c:402
MagickExport Image * SmushImages(const Image *images, const MagickBooleanType stack, const ssize_t offset, ExceptionInfo *exception)
Definition: image.c:3201
MagickExport MagickBooleanType OpenBlob(const ImageInfo *, Image *, const BlobMode, ExceptionInfo *)
MagickExport MagickBooleanType GetMagickAdjoin(const MagickInfo *magick_info)
Definition: magick.c:275
ssize_t x
Definition: geometry.h:128
MagickExport char * GetEnvironmentValue(const char *name)
Definition: string.c:1222
SemaphoreInfo * semaphore
Definition: image.h:294
char zero[MaxTextExtent]
Definition: image.h:465
static void ConvertRGBToCMYK(MagickPixelPacket *pixel)
struct _Image * next
Definition: image.h:307
MagickExport void ResetImageOptionIterator(const ImageInfo *image_info)
Definition: option.c:2600
size_t height
Definition: geometry.h:124
const char DefaultTileFrame[]
Definition: image.c:108
MagickExport void CatchException(ExceptionInfo *exception)
Definition: exception.c:200
#define GetPixelIndex(indexes)
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:738
ssize_t offset
Definition: image.h:204
MagickExport unsigned char * DetachBlob(BlobInfo *)
RectangleInfo extract_info
Definition: image.h:211
MagickExport MagickBooleanType ResetImagePage(Image *image, const char *page)
Definition: image.c:2057
MagickExport MagickBooleanType GetMagickEndianSupport(const MagickInfo *magick_info)
Definition: magick.c:367
MagickExport MagickBooleanType IsBlobSeekable(const Image *image)
Definition: blob.c:2067
char * texture
Definition: image.h:394
PixelPacket border_color
Definition: image.h:405
#define SetPixelOpacity(pixel, value)
RenderingIntent
Definition: profile.h:42
double y
Definition: image.h:98
static MagickBooleanType IsPixelGray(const PixelPacket *pixel)
size_t quality
Definition: image.h:162
size_t colors
Definition: image.h:172
MagickExport MagickBooleanType SetImageExtent(Image *image, const size_t columns, const size_t rows)
Definition: image.c:2439
TimerInfo timer
Definition: image.h:259
static void SetMagickPixelPacket(const Image *image, const PixelPacket *color, const IndexPacket *index, MagickPixelPacket *pixel)
Definition: pixel-private.h:92
MagickBooleanType matte
Definition: image.h:168
MagickRealType red
Definition: pixel.h:122
DisposeType
Definition: layer.h:25
MagickExport ssize_t FormatLocaleString(char *restrict string, const size_t length, const char *restrict format,...)
Definition: locale.c:475
#define GetMagickModule()
Definition: log.h:29
PrimaryInfo green_primary
Definition: image.h:124
MagickFormatType
Definition: magick.h:28
PixelPacket background_color
Definition: image.h:405
MagickExport void GetTimerInfo(TimerInfo *time_info)
Definition: timer.c:265
size_t quality
Definition: image.h:391
MagickBooleanType affirm
Definition: image.h:365
#define ThrowImageException(severity, tag)
MagickExport CacheView * AcquireVirtualCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:154
PrimaryInfo white_point
Definition: image.h:124
void * client_data
Definition: image.h:449
MagickBooleanType matte
Definition: pixel.h:113
char * density
Definition: image.h:394
static double StringToDoubleInterval(const char *string, const double interval)
MagickExport ImageInfo * DestroyImageInfo(ImageInfo *image_info)
Definition: image.c:1093
CompressionType
Definition: compress.h:25
RenderingIntent rendering_intent
Definition: image.h:190
MagickExport Image * AppendImages(const Image *images, const MagickBooleanType stack, ExceptionInfo *exception)
Definition: image.c:425
MagickExport MagickBooleanType IsTaintImage(const Image *image)
Definition: image.c:1821
MagickExport MagickBooleanType CloneImageOptions(ImageInfo *image_info, const ImageInfo *clone_info)
Definition: option.c:1688
const char MatteColor[]
Definition: image.c:114
MagickExport void ClonePixelCacheMethods(Cache, const Cache)
MagickBooleanType synchronize
Definition: image.h:496
unsigned short Quantum
Definition: magick-type.h:93
MagickExport IndexPacket * GetCacheViewAuthenticIndexQueue(CacheView *cache_view)
Definition: cache-view.c:562
MagickExport void LocaleUpper(char *string)
Definition: string.c:1681
#define OpaqueOpacity
Definition: image.h:27
struct _Image * previous
Definition: image.h:307
PixelPacket transparent_color
Definition: image.h:490
char * server_name
Definition: image.h:394
MagickExport void DestroyImageArtifacts(Image *image)
Definition: artifact.c:229
MagickExport Image * GetImageMask(const Image *image, ExceptionInfo *exception)
Definition: image.c:1356
MagickExport MagickBooleanType QueryColorDatabase(const char *name, PixelPacket *color, ExceptionInfo *exception)
Definition: color.c:2438
MagickExport size_t GetImageChannels(Image *image)
Definition: image.c:1390
MagickExport Image * GetNextImageInList(const Image *images)
Definition: list.c:754
MagickExport char * DestroyString(char *string)
Definition: string.c:808
MagickExport void * AcquireMagickMemory(const size_t size)
Definition: memory.c:458
PixelPacket matte_color
Definition: image.h:178
double x_resolution
Definition: image.h:207
char * geometry
Definition: image.h:199
MagickExport MagickBooleanType DeleteImageProperty(Image *image, const char *property)
Definition: property.c:272
MagickExport MagickBooleanType ModifyImage(Image **image, ExceptionInfo *exception)
Definition: image.c:1874
MagickExport MagickBooleanType IsBlobExempt(const Image *image)
Definition: blob.c:2036
MagickExport ImageInfo * CloneImageInfo(const ImageInfo *image_info)
Definition: image.c:924
MagickExport PixelPacket * GetCacheViewAuthenticPixels(CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:471
MagickRealType green
Definition: pixel.h:122
time_t timestamp
Definition: image.h:347
MagickExport MagickStatusType ParseGeometry(const char *geometry, GeometryInfo *geometry_info)
Definition: geometry.c:812
MagickBooleanType dither
Definition: image.h:410
#define SetPixelIndex(indexes, value)
char * directory
Definition: image.h:199
ChromaticityInfo chromaticity
Definition: image.h:187
char * authenticate
Definition: image.h:433
BlobInfo * blob
Definition: image.h:273
FILE * file
Definition: image.h:456
static void SetPixelPacket(const Image *image, const MagickPixelPacket *pixel, PixelPacket *color, IndexPacket *index)
MagickExport void SetGeometry(const Image *image, RectangleInfo *geometry)
Definition: geometry.c:1538
MagickExport MagickBooleanType ClipImage(Image *image)
Definition: image.c:684
MagickExport const MagicInfo * GetMagicInfo(const unsigned char *magic, const size_t length, ExceptionInfo *exception)
Definition: magic.c:346
MagickExport void GetImageInfo(ImageInfo *image_info)
Definition: image.c:1269
MagickExport MagickBooleanType SetImageOpacity(Image *image, const Quantum opacity)
Definition: image.c:2932
MagickExport MagickBooleanType IsHighDynamicRangeImage(const Image *image, ExceptionInfo *exception)
Definition: image.c:1672
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:951
MagickExport void GetImageException(Image *image, ExceptionInfo *exception)
Definition: image.c:1226
MagickExport const char * GetMagickProperty(const ImageInfo *image_info, Image *image, const char *property)
Definition: property.c:2693
MagickExport PixelPacket * QueueCacheViewAuthenticPixels(CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:881
PixelPacket * colormap
Definition: image.h:178
ImageType
Definition: image.h:47
MagickExport void GravityAdjustGeometry(const size_t width, const size_t height, const GravityType gravity, RectangleInfo *region)
Definition: geometry.c:488
MagickExport char * CloneString(char **destination, const char *source)
Definition: string.c:263
#define Swap(x, y)
Definition: studio.h:361
MagickExport BlobInfo * ReferenceBlob(BlobInfo *)
Definition: blob.c:3543
MagickExport MagickBooleanType CloneImageArtifacts(Image *image, const Image *clone_image)
Definition: artifact.c:100
MagickExport MagickBooleanType NegateImage(Image *image, const MagickBooleanType grayscale)
Definition: enhance.c:3975
CompositeOperator compose
Definition: image.h:233
MagickRealType blue
Definition: pixel.h:122
CompositeOperator
Definition: composite.h:25
ResolutionType
Definition: image.h:88
MagickExport Cache ClonePixelCache(const Cache)
#define MagickExport
char * view
Definition: image.h:433
OrientationType orientation
Definition: image.h:165
MagickProgressMonitor progress_monitor
Definition: image.h:446
double fuzz
Definition: image.h:216
ssize_t y
Definition: geometry.h:128
MagickExport CacheView * AcquireAuthenticCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:111
MagickExport void DestroyBlob(Image *image)
Definition: blob.c:628
struct _Image * clip_mask
Definition: image.h:238
static ssize_t SmushYGap(const Image *smush_image, const Image *images, const ssize_t offset, ExceptionInfo *exception)
Definition: image.c:3130
Quantum IndexPacket
Definition: pixel.h:129
MagickExport MagickBooleanType SetImageColor(Image *image, const MagickPixelPacket *color)
Definition: image.c:2265
MagickBooleanType adjoin
Definition: image.h:365
char * page
Definition: image.h:371
MagickBooleanType ping
Definition: image.h:429
MagickExport MagickBooleanType IsSceneGeometry(const char *geometry, const MagickBooleanType pedantic)
Definition: geometry.c:610
MagickExport MagickBooleanType SetImageClipMask(Image *image, const Image *clip_mask)
Definition: image.c:2388
#define AppendImageTag
#define SetPixelBlue(pixel, value)
MagickExport char * GetNextImageOption(const ImageInfo *image_info)
Definition: option.c:2120
ssize_t group
Definition: image.h:426
MagickSizeType QuantumAny
Definition: magick-type.h:170
void * client_data
Definition: image.h:265
MagickExport MagickBooleanType SetImageMask(Image *image, const Image *mask)
Definition: image.c:2885
MagickExport Image * DestroyImage(Image *image)
Definition: image.c:1020
MagickExport Image * CloneImage(const Image *image, const size_t columns, const size_t rows, const MagickBooleanType detach, ExceptionInfo *exception)
Definition: image.c:783
MagickExport void * CopyMagickMemory(void *destination, const void *source, const size_t size)
Definition: memory.c:673
MagickRealType index
Definition: pixel.h:122
MagickExport ssize_t GetImageReferenceCount(Image *image)
Definition: image.c:1421
double gamma
Definition: image.h:184
ColorspaceType colorspace
Definition: image.h:156
MagickExport MagickBooleanType CompositeImage(Image *image, const CompositeOperator compose, const Image *composite_image, const ssize_t x_offset, const ssize_t y_offset)
Definition: composite.c:1607
MagickExport StringInfo * CloneStringInfo(const StringInfo *string_info)
Definition: string.c:315
MagickExport void DisassociateImageStream(Image *image)
Definition: image.c:1158
#define QuantumRange
Definition: magick-type.h:94
MagickBooleanType temporary
Definition: image.h:365
MagickBooleanType debug
Definition: image.h:288
size_t depth
Definition: image.h:377
void * profile
Definition: image.h:493
MagickExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
Definition: exception.c:412
ExceptionInfo exception
Definition: image.h:285
InterpolatePixelMethod interpolate
Definition: image.h:313
MagickExport void InheritException(ExceptionInfo *exception, const ExceptionInfo *relative)
Definition: exception.c:653
size_t depth
Definition: image.h:172
FilterTypes filter
Definition: image.h:221
ExceptionType severity
Definition: exception.h:105