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