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