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) ResetMagickMemory(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) ResetMagickMemory(&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,4) 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) ResetMagickMemory(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) CopyMagickMemory(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,4) 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) ResetMagickMemory(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  size_t
1642  length;
1643 
1644  canonical=MagickFalse;
1645  length=0;
1646  (void) CopyMagickString(filename,format,MagickPathExtent);
1647  for (p=strchr(format,'%'); p != (char *) NULL; p=strchr(p+1,'%'))
1648  {
1649  q=(char *) p+1;
1650  if (*q == '%')
1651  {
1652  p=q+1;
1653  continue;
1654  }
1655  if (*q == '0')
1656  {
1657  ssize_t
1658  foo;
1659 
1660  foo=(ssize_t) strtol(q,&q,10);
1661  (void) foo;
1662  }
1663  switch (*q)
1664  {
1665  case 'd':
1666  case 'o':
1667  case 'x':
1668  {
1669  q++;
1670  c=(*q);
1671  *q='\0';
1672  (void) FormatLocaleString(filename+(p-format),(size_t)
1673  (MagickPathExtent-(p-format)),p,value);
1674  *q=c;
1675  (void) ConcatenateMagickString(filename,q,MagickPathExtent);
1676  canonical=MagickTrue;
1677  if (*(q-1) != '%')
1678  break;
1679  p++;
1680  break;
1681  }
1682  case '[':
1683  {
1684  char
1685  pattern[MagickPathExtent];
1686 
1687  const char
1688  *option;
1689 
1690  register char
1691  *r;
1692 
1693  register ssize_t
1694  i;
1695 
1696  ssize_t
1697  depth;
1698 
1699  /*
1700  Image option.
1701  */
1702  /* FUTURE: Compare update with code from InterpretImageProperties()
1703  Note that a 'filename:' property should not need depth recursion.
1704  */
1705  if (strchr(p,']') == (char *) NULL)
1706  break;
1707  depth=1;
1708  r=q+1;
1709  for (i=0; (i < (MagickPathExtent-1L)) && (*r != '\0'); i++)
1710  {
1711  if (*r == '[')
1712  depth++;
1713  if (*r == ']')
1714  depth--;
1715  if (depth <= 0)
1716  break;
1717  pattern[i]=(*r++);
1718  }
1719  pattern[i]='\0';
1720  if (LocaleNCompare(pattern,"filename:",9) != 0)
1721  break;
1722  option=(const char *) NULL;
1723  if (image != (Image *) NULL)
1724  option=GetImageProperty(image,pattern,exception);
1725  if ((option == (const char *) NULL) && (image != (Image *) NULL))
1726  option=GetImageArtifact(image,pattern);
1727  if ((option == (const char *) NULL) &&
1728  (image_info != (ImageInfo *) NULL))
1729  option=GetImageOption(image_info,pattern);
1730  if (option == (const char *) NULL)
1731  break;
1732  q--;
1733  c=(*q);
1734  *q='\0';
1735  (void) CopyMagickString(filename+(p-format-length),option,(size_t)
1736  (MagickPathExtent-(p-format-length)));
1737  length+=strlen(pattern)-1;
1738  *q=c;
1739  (void) ConcatenateMagickString(filename,r+1,MagickPathExtent);
1740  canonical=MagickTrue;
1741  if (*(q-1) != '%')
1742  break;
1743  p++;
1744  break;
1745  }
1746  default:
1747  break;
1748  }
1749  }
1750  for (q=filename; *q != '\0'; q++)
1751  if ((*q == '%') && (*(q+1) == '%'))
1752  {
1753  (void) CopyMagickString(q,q+1,(size_t) (MagickPathExtent-(q-filename)));
1754  canonical=MagickTrue;
1755  }
1756  if (canonical == MagickFalse)
1757  (void) CopyMagickString(filename,format,MagickPathExtent);
1758  return(strlen(filename));
1759 }
1760 
1761 /*
1762 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1763 % %
1764 % %
1765 % %
1766 % I s H i g h D y n a m i c R a n g e I m a g e %
1767 % %
1768 % %
1769 % %
1770 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1771 %
1772 % IsHighDynamicRangeImage() returns MagickTrue if any pixel component is
1773 % non-integer or exceeds the bounds of the quantum depth (e.g. for Q16
1774 % 0..65535.
1775 %
1776 % The format of the IsHighDynamicRangeImage method is:
1777 %
1778 % MagickBooleanType IsHighDynamicRangeImage(const Image *image,
1779 % ExceptionInfo *exception)
1780 %
1781 % A description of each parameter follows:
1782 %
1783 % o image: the image.
1784 %
1785 % o exception: return any errors or warnings in this structure.
1786 %
1787 */
1790 {
1791 #if !defined(MAGICKCORE_HDRI_SUPPORT)
1792  (void) image;
1793  (void) exception;
1794  return(MagickFalse);
1795 #else
1796  CacheView
1797  *image_view;
1798 
1800  status;
1801 
1802  ssize_t
1803  y;
1804 
1805  assert(image != (Image *) NULL);
1806  assert(image->signature == MagickCoreSignature);
1807  if (image->debug != MagickFalse)
1808  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1809  status=MagickTrue;
1810  image_view=AcquireVirtualCacheView(image,exception);
1811 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1812  #pragma omp parallel for schedule(static,4) shared(status) \
1813  magick_number_threads(image,image,image->rows,1)
1814 #endif
1815  for (y=0; y < (ssize_t) image->rows; y++)
1816  {
1817  register const Quantum
1818  *p;
1819 
1820  register ssize_t
1821  x;
1822 
1823  if (status == MagickFalse)
1824  continue;
1825  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
1826  if (p == (const Quantum *) NULL)
1827  {
1828  status=MagickFalse;
1829  continue;
1830  }
1831  for (x=0; x < (ssize_t) image->columns; x++)
1832  {
1833  register ssize_t
1834  i;
1835 
1836  if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
1837  {
1838  p+=GetPixelChannels(image);
1839  continue;
1840  }
1841  for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
1842  {
1843  double
1844  pixel;
1845 
1846  PixelTrait
1847  traits;
1848 
1849  traits=GetPixelChannelTraits(image,(PixelChannel) i);
1850  if (traits == UndefinedPixelTrait)
1851  continue;
1852  pixel=(double) p[i];
1853  if ((pixel < 0.0) || (pixel > QuantumRange) ||
1854  (pixel != (double) ((QuantumAny) pixel)))
1855  break;
1856  }
1857  p+=GetPixelChannels(image);
1858  if (i < (ssize_t) GetPixelChannels(image))
1859  status=MagickFalse;
1860  }
1861  if (x < (ssize_t) image->columns)
1862  status=MagickFalse;
1863  }
1864  image_view=DestroyCacheView(image_view);
1865  return(status != MagickFalse ? MagickFalse : MagickTrue);
1866 #endif
1867 }
1868 
1869 /*
1870 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1871 % %
1872 % %
1873 % %
1874 % I s I m a g e O b j e c t %
1875 % %
1876 % %
1877 % %
1878 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1879 %
1880 % IsImageObject() returns MagickTrue if the image sequence contains a valid
1881 % set of image objects.
1882 %
1883 % The format of the IsImageObject method is:
1884 %
1885 % MagickBooleanType IsImageObject(const Image *image)
1886 %
1887 % A description of each parameter follows:
1888 %
1889 % o image: the image.
1890 %
1891 */
1893 {
1894  register const Image
1895  *p;
1896 
1897  assert(image != (Image *) NULL);
1898  if (image->debug != MagickFalse)
1899  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1900  for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1901  if (p->signature != MagickCoreSignature)
1902  return(MagickFalse);
1903  return(MagickTrue);
1904 }
1905 
1906 /*
1907 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1908 % %
1909 % %
1910 % %
1911 % I s T a i n t I m a g e %
1912 % %
1913 % %
1914 % %
1915 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1916 %
1917 % IsTaintImage() returns MagickTrue any pixel in the image has been altered
1918 % since it was first constituted.
1919 %
1920 % The format of the IsTaintImage method is:
1921 %
1922 % MagickBooleanType IsTaintImage(const Image *image)
1923 %
1924 % A description of each parameter follows:
1925 %
1926 % o image: the image.
1927 %
1928 */
1930 {
1931  char
1932  magick[MagickPathExtent],
1933  filename[MagickPathExtent];
1934 
1935  register const Image
1936  *p;
1937 
1938  assert(image != (Image *) NULL);
1939  if (image->debug != MagickFalse)
1940  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1941  assert(image->signature == MagickCoreSignature);
1942  (void) CopyMagickString(magick,image->magick,MagickPathExtent);
1943  (void) CopyMagickString(filename,image->filename,MagickPathExtent);
1944  for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1945  {
1946  if (p->taint != MagickFalse)
1947  return(MagickTrue);
1948  if (LocaleCompare(p->magick,magick) != 0)
1949  return(MagickTrue);
1950  if (LocaleCompare(p->filename,filename) != 0)
1951  return(MagickTrue);
1952  }
1953  return(MagickFalse);
1954 }
1955 
1956 /*
1957 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1958 % %
1959 % %
1960 % %
1961 % M o d i f y I m a g e %
1962 % %
1963 % %
1964 % %
1965 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1966 %
1967 % ModifyImage() ensures that there is only a single reference to the image
1968 % to be modified, updating the provided image pointer to point to a clone of
1969 % the original image if necessary.
1970 %
1971 % The format of the ModifyImage method is:
1972 %
1973 % MagickBooleanType ModifyImage(Image *image,ExceptionInfo *exception)
1974 %
1975 % A description of each parameter follows:
1976 %
1977 % o image: the image.
1978 %
1979 % o exception: return any errors or warnings in this structure.
1980 %
1981 */
1984 {
1985  Image
1986  *clone_image;
1987 
1988  assert(image != (Image **) NULL);
1989  assert(*image != (Image *) NULL);
1990  assert((*image)->signature == MagickCoreSignature);
1991  if ((*image)->debug != MagickFalse)
1992  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1993  if (GetImageReferenceCount(*image) <= 1)
1994  return(MagickTrue);
1995  clone_image=CloneImage(*image,0,0,MagickTrue,exception);
1996  LockSemaphoreInfo((*image)->semaphore);
1997  (*image)->reference_count--;
1998  UnlockSemaphoreInfo((*image)->semaphore);
1999  *image=clone_image;
2000  return(MagickTrue);
2001 }
2002 
2003 /*
2004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2005 % %
2006 % %
2007 % %
2008 % N e w M a g i c k I m a g e %
2009 % %
2010 % %
2011 % %
2012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2013 %
2014 % NewMagickImage() creates a blank image canvas of the specified size and
2015 % background color.
2016 %
2017 % The format of the NewMagickImage method is:
2018 %
2019 % Image *NewMagickImage(const ImageInfo *image_info,const size_t width,
2020 % const size_t height,const PixelInfo *background,
2021 % ExceptionInfo *exception)
2022 %
2023 % A description of each parameter follows:
2024 %
2025 % o image: the image.
2026 %
2027 % o width: the image width.
2028 %
2029 % o height: the image height.
2030 %
2031 % o background: the image color.
2032 %
2033 % o exception: return any errors or warnings in this structure.
2034 %
2035 */
2037  const size_t width,const size_t height,const PixelInfo *background,
2039 {
2040  CacheView
2041  *image_view;
2042 
2043  Image
2044  *image;
2045 
2047  status;
2048 
2049  ssize_t
2050  y;
2051 
2052  assert(image_info != (const ImageInfo *) NULL);
2053  if (image_info->debug != MagickFalse)
2054  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2055  assert(image_info->signature == MagickCoreSignature);
2056  assert(background != (const PixelInfo *) NULL);
2057  image=AcquireImage(image_info,exception);
2058  image->columns=width;
2059  image->rows=height;
2060  image->colorspace=background->colorspace;
2061  image->alpha_trait=background->alpha_trait;
2062  image->fuzz=background->fuzz;
2063  image->depth=background->depth;
2064  status=MagickTrue;
2065  image_view=AcquireAuthenticCacheView(image,exception);
2066 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2067  #pragma omp parallel for schedule(static,4) shared(status) \
2068  magick_number_threads(image,image,image->rows,1)
2069 #endif
2070  for (y=0; y < (ssize_t) image->rows; y++)
2071  {
2072  register Quantum
2073  *magick_restrict q;
2074 
2075  register ssize_t
2076  x;
2077 
2078  if (status == MagickFalse)
2079  continue;
2080  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2081  if (q == (Quantum *) NULL)
2082  {
2083  status=MagickFalse;
2084  continue;
2085  }
2086  for (x=0; x < (ssize_t) image->columns; x++)
2087  {
2088  SetPixelViaPixelInfo(image,background,q);
2089  q+=GetPixelChannels(image);
2090  }
2091  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2092  status=MagickFalse;
2093  }
2094  image_view=DestroyCacheView(image_view);
2095  if (status == MagickFalse)
2096  image=DestroyImage(image);
2097  return(image);
2098 }
2099 
2100 /*
2101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2102 % %
2103 % %
2104 % %
2105 % R e f e r e n c e I m a g e %
2106 % %
2107 % %
2108 % %
2109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2110 %
2111 % ReferenceImage() increments the reference count associated with an image
2112 % returning a pointer to the image.
2113 %
2114 % The format of the ReferenceImage method is:
2115 %
2116 % Image *ReferenceImage(Image *image)
2117 %
2118 % A description of each parameter follows:
2119 %
2120 % o image: the image.
2121 %
2122 */
2124 {
2125  assert(image != (Image *) NULL);
2126  if (image->debug != MagickFalse)
2127  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2128  assert(image->signature == MagickCoreSignature);
2129  LockSemaphoreInfo(image->semaphore);
2130  image->reference_count++;
2132  return(image);
2133 }
2134 
2135 /*
2136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2137 % %
2138 % %
2139 % %
2140 % R e s e t I m a g e P a g e %
2141 % %
2142 % %
2143 % %
2144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2145 %
2146 % ResetImagePage() resets the image page canvas and position.
2147 %
2148 % The format of the ResetImagePage method is:
2149 %
2150 % MagickBooleanType ResetImagePage(Image *image,const char *page)
2151 %
2152 % A description of each parameter follows:
2153 %
2154 % o image: the image.
2155 %
2156 % o page: the relative page specification.
2157 %
2158 */
2160 {
2162  flags;
2163 
2165  geometry;
2166 
2167  assert(image != (Image *) NULL);
2168  assert(image->signature == MagickCoreSignature);
2169  if (image->debug != MagickFalse)
2170  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2171  flags=ParseAbsoluteGeometry(page,&geometry);
2172  if ((flags & WidthValue) != 0)
2173  {
2174  if ((flags & HeightValue) == 0)
2175  geometry.height=geometry.width;
2176  image->page.width=geometry.width;
2177  image->page.height=geometry.height;
2178  }
2179  if ((flags & AspectValue) != 0)
2180  {
2181  if ((flags & XValue) != 0)
2182  image->page.x+=geometry.x;
2183  if ((flags & YValue) != 0)
2184  image->page.y+=geometry.y;
2185  }
2186  else
2187  {
2188  if ((flags & XValue) != 0)
2189  {
2190  image->page.x=geometry.x;
2191  if ((image->page.width == 0) && (geometry.x > 0))
2192  image->page.width=image->columns+geometry.x;
2193  }
2194  if ((flags & YValue) != 0)
2195  {
2196  image->page.y=geometry.y;
2197  if ((image->page.height == 0) && (geometry.y > 0))
2198  image->page.height=image->rows+geometry.y;
2199  }
2200  }
2201  return(MagickTrue);
2202 }
2203 
2204 /*
2205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2206 % %
2207 % %
2208 % %
2209 % R e s e t I m a g e P i x e l s %
2210 % %
2211 % %
2212 % %
2213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2214 %
2215 % ResetImagePixels() reset the image pixels, that is, all the pixel components
2216 % are zereod.
2217 %
2218 % The format of the SetImage method is:
2219 %
2220 % MagickBooleanType ResetImagePixels(Image *image,
2221 % ExceptionInfo *exception)
2222 %
2223 % A description of each parameter follows:
2224 %
2225 % o image: the image.
2226 %
2227 % o exception: return any errors or warnings in this structure.
2228 %
2229 */
2232 {
2233  CacheView
2234  *image_view;
2235 
2237  status;
2238 
2239  ssize_t
2240  y;
2241 
2242  assert(image != (Image *) NULL);
2243  if (image->debug != MagickFalse)
2244  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2245  assert(image->signature == MagickCoreSignature);
2246  /*
2247  Reset image pixels.
2248  */
2249  status=MagickTrue;
2250  image_view=AcquireAuthenticCacheView(image,exception);
2251  for (y=0; y < (ssize_t) image->rows; y++)
2252  {
2253  register Quantum
2254  *magick_restrict q;
2255 
2256  register ssize_t
2257  x;
2258 
2259  if (status == MagickFalse)
2260  continue;
2261  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2262  if (q == (Quantum *) NULL)
2263  {
2264  status=MagickFalse;
2265  continue;
2266  }
2267  for (x=0; x < (ssize_t) image->columns; x++)
2268  {
2269  memset(q,0,GetPixelChannels(image)*sizeof(Quantum));
2270  q+=GetPixelChannels(image);
2271  }
2272  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2273  status=MagickFalse;
2274  }
2275  image_view=DestroyCacheView(image_view);
2276  return(status);
2277 }
2278 
2279 /*
2280 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2281 % %
2282 % %
2283 % %
2284 % S e t I m a g e A l p h a %
2285 % %
2286 % %
2287 % %
2288 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2289 %
2290 % SetImageAlpha() sets the alpha levels of the image.
2291 %
2292 % The format of the SetImageAlpha method is:
2293 %
2294 % MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha,
2295 % ExceptionInfo *exception)
2296 %
2297 % A description of each parameter follows:
2298 %
2299 % o image: the image.
2300 %
2301 % o Alpha: the level of transparency: 0 is fully transparent and QuantumRange
2302 % is fully opaque.
2303 %
2304 */
2307 {
2308  CacheView
2309  *image_view;
2310 
2312  set_opaque,
2313  status;
2314 
2315  ssize_t
2316  y;
2317 
2318  assert(image != (Image *) NULL);
2319  if (image->debug != MagickFalse)
2320  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2321  assert(image->signature == MagickCoreSignature);
2322  set_opaque=(image->alpha_trait == UndefinedPixelTrait) ? MagickTrue :
2323  MagickFalse;
2325  status=MagickTrue;
2326  image_view=AcquireAuthenticCacheView(image,exception);
2327 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2328  #pragma omp parallel for schedule(static,4) shared(status) \
2329  magick_number_threads(image,image,image->rows,1)
2330 #endif
2331  for (y=0; y < (ssize_t) image->rows; y++)
2332  {
2333  register Quantum
2334  *magick_restrict q;
2335 
2336  register ssize_t
2337  x;
2338 
2339  if (status == MagickFalse)
2340  continue;
2341  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2342  if (q == (Quantum *) NULL)
2343  {
2344  status=MagickFalse;
2345  continue;
2346  }
2347  for (x=0; x < (ssize_t) image->columns; x++)
2348  {
2349  if (GetPixelWriteMask(image,q) > (QuantumRange/2))
2350  SetPixelAlpha(image,alpha,q);
2351  else if (set_opaque != MagickFalse)
2352  SetPixelAlpha(image,OpaqueAlpha,q);
2353  q+=GetPixelChannels(image);
2354  }
2355  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2356  status=MagickFalse;
2357  }
2358  image_view=DestroyCacheView(image_view);
2359  return(status);
2360 }
2361 
2362 /*
2363 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2364 % %
2365 % %
2366 % %
2367 % S e t I m a g e B a c k g r o u n d C o l o r %
2368 % %
2369 % %
2370 % %
2371 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2372 %
2373 % SetImageBackgroundColor() initializes the image pixels to the image
2374 % background color. The background color is defined by the background_color
2375 % member of the image structure.
2376 %
2377 % The format of the SetImage method is:
2378 %
2379 % MagickBooleanType SetImageBackgroundColor(Image *image,
2380 % ExceptionInfo *exception)
2381 %
2382 % A description of each parameter follows:
2383 %
2384 % o image: the image.
2385 %
2386 % o exception: return any errors or warnings in this structure.
2387 %
2388 */
2391 {
2392  CacheView
2393  *image_view;
2394 
2396  status;
2397 
2398  PixelInfo
2399  background;
2400 
2401  ssize_t
2402  y;
2403 
2404  assert(image != (Image *) NULL);
2405  if (image->debug != MagickFalse)
2406  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2407  assert(image->signature == MagickCoreSignature);
2408  if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
2409  return(MagickFalse);
2410  if ((image->background_color.alpha != OpaqueAlpha) &&
2411  (image->alpha_trait == UndefinedPixelTrait))
2412  (void) SetImageAlphaChannel(image,OnAlphaChannel,exception);
2413  ConformPixelInfo(image,&image->background_color,&background,exception);
2414  /*
2415  Set image background color.
2416  */
2417  status=MagickTrue;
2418  image_view=AcquireAuthenticCacheView(image,exception);
2419  for (y=0; y < (ssize_t) image->rows; y++)
2420  {
2421  register Quantum
2422  *magick_restrict q;
2423 
2424  register ssize_t
2425  x;
2426 
2427  if (status == MagickFalse)
2428  continue;
2429  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2430  if (q == (Quantum *) NULL)
2431  {
2432  status=MagickFalse;
2433  continue;
2434  }
2435  for (x=0; x < (ssize_t) image->columns; x++)
2436  {
2437  SetPixelViaPixelInfo(image,&background,q);
2438  q+=GetPixelChannels(image);
2439  }
2440  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2441  status=MagickFalse;
2442  }
2443  image_view=DestroyCacheView(image_view);
2444  return(status);
2445 }
2446 
2447 /*
2448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2449 % %
2450 % %
2451 % %
2452 % S e t I m a g e C h a n n e l M a s k %
2453 % %
2454 % %
2455 % %
2456 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2457 %
2458 % SetImageChannelMask() sets the image channel mask from the specified channel
2459 % mask.
2460 %
2461 % The format of the SetImageChannelMask method is:
2462 %
2463 % ChannelType SetImageChannelMask(Image *image,
2464 % const ChannelType channel_mask)
2465 %
2466 % A description of each parameter follows:
2467 %
2468 % o image: the image.
2469 %
2470 % o channel_mask: the channel mask.
2471 %
2472 */
2474  const ChannelType channel_mask)
2475 {
2476  return(SetPixelChannelMask(image,channel_mask));
2477 }
2478 
2479 /*
2480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2481 % %
2482 % %
2483 % %
2484 % S e t I m a g e C o l o r %
2485 % %
2486 % %
2487 % %
2488 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2489 %
2490 % SetImageColor() set the entire image canvas to the specified color.
2491 %
2492 % The format of the SetImageColor method is:
2493 %
2494 % MagickBooleanType SetImageColor(Image *image,const PixelInfo *color,
2495 % ExeptionInfo *exception)
2496 %
2497 % A description of each parameter follows:
2498 %
2499 % o image: the image.
2500 %
2501 % o background: the image color.
2502 %
2503 % o exception: return any errors or warnings in this structure.
2504 %
2505 */
2507  const PixelInfo *color,ExceptionInfo *exception)
2508 {
2509  CacheView
2510  *image_view;
2511 
2513  status;
2514 
2515  ssize_t
2516  y;
2517 
2518  assert(image != (Image *) NULL);
2519  if (image->debug != MagickFalse)
2520  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2521  assert(image->signature == MagickCoreSignature);
2522  assert(color != (const PixelInfo *) NULL);
2523  image->colorspace=color->colorspace;
2524  image->alpha_trait=color->alpha_trait;
2525  image->fuzz=color->fuzz;
2526  image->depth=color->depth;
2527  status=MagickTrue;
2528  image_view=AcquireAuthenticCacheView(image,exception);
2529 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2530  #pragma omp parallel for schedule(static,4) shared(status) \
2531  magick_number_threads(image,image,image->rows,1)
2532 #endif
2533  for (y=0; y < (ssize_t) image->rows; y++)
2534  {
2535  register Quantum
2536  *magick_restrict q;
2537 
2538  register ssize_t
2539  x;
2540 
2541  if (status == MagickFalse)
2542  continue;
2543  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2544  if (q == (Quantum *) NULL)
2545  {
2546  status=MagickFalse;
2547  continue;
2548  }
2549  for (x=0; x < (ssize_t) image->columns; x++)
2550  {
2551  SetPixelViaPixelInfo(image,color,q);
2552  q+=GetPixelChannels(image);
2553  }
2554  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2555  status=MagickFalse;
2556  }
2557  image_view=DestroyCacheView(image_view);
2558  return(status);
2559 }
2560 
2561 /*
2562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2563 % %
2564 % %
2565 % %
2566 % S e t I m a g e S t o r a g e C l a s s %
2567 % %
2568 % %
2569 % %
2570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2571 %
2572 % SetImageStorageClass() sets the image class: DirectClass for true color
2573 % images or PseudoClass for colormapped images.
2574 %
2575 % The format of the SetImageStorageClass method is:
2576 %
2577 % MagickBooleanType SetImageStorageClass(Image *image,
2578 % const ClassType storage_class,ExceptionInfo *exception)
2579 %
2580 % A description of each parameter follows:
2581 %
2582 % o image: the image.
2583 %
2584 % o storage_class: The image class.
2585 %
2586 % o exception: return any errors or warnings in this structure.
2587 %
2588 */
2590  const ClassType storage_class,ExceptionInfo *exception)
2591 {
2592  assert(image != (Image *) NULL);
2593  assert(image->signature == MagickCoreSignature);
2594  if (image->debug != MagickFalse)
2595  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2596  assert(exception != (ExceptionInfo *) NULL);
2597  assert(exception->signature == MagickCoreSignature);
2598  image->storage_class=storage_class;
2599  return(SyncImagePixelCache(image,exception));
2600 }
2601 
2602 /*
2603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2604 % %
2605 % %
2606 % %
2607 % S e t I m a g e E x t e n t %
2608 % %
2609 % %
2610 % %
2611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2612 %
2613 % SetImageExtent() sets the image size (i.e. columns & rows).
2614 %
2615 % The format of the SetImageExtent method is:
2616 %
2617 % MagickBooleanType SetImageExtent(Image *image,const size_t columns,
2618 % const size_t rows,ExceptionInfo *exception)
2619 %
2620 % A description of each parameter follows:
2621 %
2622 % o image: the image.
2623 %
2624 % o columns: The image width in pixels.
2625 %
2626 % o rows: The image height in pixels.
2627 %
2628 % o exception: return any errors or warnings in this structure.
2629 %
2630 */
2632  const size_t rows,ExceptionInfo *exception)
2633 {
2634  if ((columns == 0) || (rows == 0))
2635  ThrowBinaryException(ImageError,"NegativeOrZeroImageSize",image->filename);
2636  image->columns=columns;
2637  image->rows=rows;
2638  if ((image->depth == 0) || (image->depth > (8*sizeof(MagickSizeType))))
2639  ThrowBinaryException(ImageError,"ImageDepthNotSupported",image->filename);
2640  return(SyncImagePixelCache(image,exception));
2641 }
2642 
2643 /*
2644 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2645 % %
2646 % %
2647 % %
2648 + S e t I m a g e I n f o %
2649 % %
2650 % %
2651 % %
2652 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2653 %
2654 % SetImageInfo() initializes the 'magick' field of the ImageInfo structure.
2655 % It is set to a type of image format based on the prefix or suffix of the
2656 % filename. For example, 'ps:image' returns PS indicating a Postscript image.
2657 % JPEG is returned for this filename: 'image.jpg'. The filename prefix has
2658 % precendence over the suffix. Use an optional index enclosed in brackets
2659 % after a file name to specify a desired scene of a multi-resolution image
2660 % format like Photo CD (e.g. img0001.pcd[4]). A True (non-zero) return value
2661 % indicates success.
2662 %
2663 % The format of the SetImageInfo method is:
2664 %
2665 % MagickBooleanType SetImageInfo(ImageInfo *image_info,
2666 % const unsigned int frames,ExceptionInfo *exception)
2667 %
2668 % A description of each parameter follows:
2669 %
2670 % o image_info: the image info.
2671 %
2672 % o frames: the number of images you intend to write.
2673 %
2674 % o exception: return any errors or warnings in this structure.
2675 %
2676 */
2678  const unsigned int frames,ExceptionInfo *exception)
2679 {
2680  char
2681  component[MagickPathExtent],
2682  magic[MagickPathExtent],
2683  *q;
2684 
2685  const MagicInfo
2686  *magic_info;
2687 
2688  const MagickInfo
2689  *magick_info;
2690 
2692  *sans_exception;
2693 
2694  Image
2695  *image;
2696 
2698  status;
2699 
2700  register const char
2701  *p;
2702 
2703  ssize_t
2704  count;
2705 
2706  /*
2707  Look for 'image.format' in filename.
2708  */
2709  assert(image_info != (ImageInfo *) NULL);
2710  assert(image_info->signature == MagickCoreSignature);
2711  if (image_info->debug != MagickFalse)
2713  image_info->filename);
2714  *component='\0';
2715  GetPathComponent(image_info->filename,SubimagePath,component);
2716  if (*component != '\0')
2717  {
2718  /*
2719  Look for scene specification (e.g. img0001.pcd[4]).
2720  */
2721  if (IsSceneGeometry(component,MagickFalse) == MagickFalse)
2722  {
2723  if (IsGeometry(component) != MagickFalse)
2724  (void) CloneString(&image_info->extract,component);
2725  }
2726  else
2727  {
2728  size_t
2729  first,
2730  last;
2731 
2732  (void) CloneString(&image_info->scenes,component);
2733  image_info->scene=StringToUnsignedLong(image_info->scenes);
2734  image_info->number_scenes=image_info->scene;
2735  p=image_info->scenes;
2736  for (q=(char *) image_info->scenes; *q != '\0'; p++)
2737  {
2738  while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
2739  p++;
2740  first=(size_t) strtol(p,&q,10);
2741  last=first;
2742  while (isspace((int) ((unsigned char) *q)) != 0)
2743  q++;
2744  if (*q == '-')
2745  last=(size_t) strtol(q+1,&q,10);
2746  if (first > last)
2747  Swap(first,last);
2748  if (first < image_info->scene)
2749  image_info->scene=first;
2750  if (last > image_info->number_scenes)
2751  image_info->number_scenes=last;
2752  p=q;
2753  }
2754  image_info->number_scenes-=image_info->scene-1;
2755  }
2756  }
2757  *component='\0';
2758  if (*image_info->magick == '\0')
2759  GetPathComponent(image_info->filename,ExtensionPath,component);
2760 #if defined(MAGICKCORE_ZLIB_DELEGATE)
2761  if (*component != '\0')
2762  if ((LocaleCompare(component,"gz") == 0) ||
2763  (LocaleCompare(component,"Z") == 0) ||
2764  (LocaleCompare(component,"svgz") == 0) ||
2765  (LocaleCompare(component,"wmz") == 0))
2766  {
2767  char
2768  path[MagickPathExtent];
2769 
2770  (void) CopyMagickString(path,image_info->filename,MagickPathExtent);
2771  path[strlen(path)-strlen(component)-1]='\0';
2772  GetPathComponent(path,ExtensionPath,component);
2773  }
2774 #endif
2775 #if defined(MAGICKCORE_BZLIB_DELEGATE)
2776  if (*component != '\0')
2777  if (LocaleCompare(component,"bz2") == 0)
2778  {
2779  char
2780  path[MagickPathExtent];
2781 
2782  (void) CopyMagickString(path,image_info->filename,MagickPathExtent);
2783  path[strlen(path)-strlen(component)-1]='\0';
2784  GetPathComponent(path,ExtensionPath,component);
2785  }
2786 #endif
2787  image_info->affirm=MagickFalse;
2788  sans_exception=AcquireExceptionInfo();
2789  if (*component != '\0')
2790  {
2792  format_type;
2793 
2794  register ssize_t
2795  i;
2796 
2797  static const char
2798  *format_type_formats[] =
2799  {
2800  "AUTOTRACE",
2801  "BROWSE",
2802  "DCRAW",
2803  "EDIT",
2804  "LAUNCH",
2805  "MPEG:DECODE",
2806  "MPEG:ENCODE",
2807  "PRINT",
2808  "PS:ALPHA",
2809  "PS:CMYK",
2810  "PS:COLOR",
2811  "PS:GRAY",
2812  "PS:MONO",
2813  "SCAN",
2814  "SHOW",
2815  "WIN",
2816  (char *) NULL
2817  };
2818 
2819  /*
2820  User specified image format.
2821  */
2822  (void) CopyMagickString(magic,component,MagickPathExtent);
2823  LocaleUpper(magic);
2824  /*
2825  Look for explicit image formats.
2826  */
2827  format_type=UndefinedFormatType;
2828  magick_info=GetMagickInfo(magic,sans_exception);
2829  if ((magick_info != (const MagickInfo *) NULL) &&
2830  (magick_info->format_type != UndefinedFormatType))
2831  format_type=magick_info->format_type;
2832  i=0;
2833  while ((format_type == UndefinedFormatType) &&
2834  (format_type_formats[i] != (char *) NULL))
2835  {
2836  if ((*magic == *format_type_formats[i]) &&
2837  (LocaleCompare(magic,format_type_formats[i]) == 0))
2838  format_type=ExplicitFormatType;
2839  i++;
2840  }
2841  if (format_type == UndefinedFormatType)
2842  (void) CopyMagickString(image_info->magick,magic,MagickPathExtent);
2843  else
2844  if (format_type == ExplicitFormatType)
2845  {
2846  image_info->affirm=MagickTrue;
2847  (void) CopyMagickString(image_info->magick,magic,MagickPathExtent);
2848  }
2849  if (LocaleCompare(magic,"RGB") == 0)
2850  image_info->affirm=MagickFalse; /* maybe SGI disguised as RGB */
2851  }
2852  /*
2853  Look for explicit 'format:image' in filename.
2854  */
2855  *magic='\0';
2856  GetPathComponent(image_info->filename,MagickPath,magic);
2857  if (*magic == '\0')
2858  {
2859  (void) CopyMagickString(magic,image_info->magick,MagickPathExtent);
2860  magick_info=GetMagickInfo(magic,sans_exception);
2861  GetPathComponent(image_info->filename,CanonicalPath,component);
2862  (void) CopyMagickString(image_info->filename,component,MagickPathExtent);
2863  }
2864  else
2865  {
2866  const DelegateInfo
2867  *delegate_info;
2868 
2869  /*
2870  User specified image format.
2871  */
2872  LocaleUpper(magic);
2873  magick_info=GetMagickInfo(magic,sans_exception);
2874  delegate_info=GetDelegateInfo(magic,"*",sans_exception);
2875  if (delegate_info == (const DelegateInfo *) NULL)
2876  delegate_info=GetDelegateInfo("*",magic,sans_exception);
2877  if (((magick_info != (const MagickInfo *) NULL) ||
2878  (delegate_info != (const DelegateInfo *) NULL)) &&
2879  (IsMagickConflict(magic) == MagickFalse))
2880  {
2881  image_info->affirm=MagickTrue;
2882  (void) CopyMagickString(image_info->magick,magic,MagickPathExtent);
2883  GetPathComponent(image_info->filename,CanonicalPath,component);
2884  (void) CopyMagickString(image_info->filename,component,
2886  }
2887  }
2888  sans_exception=DestroyExceptionInfo(sans_exception);
2889  if ((magick_info == (const MagickInfo *) NULL) ||
2890  (GetMagickEndianSupport(magick_info) == MagickFalse))
2891  image_info->endian=UndefinedEndian;
2892  if ((image_info->adjoin != MagickFalse) && (frames > 1))
2893  {
2894  /*
2895  Test for multiple image support (e.g. image%02d.png).
2896  */
2897  (void) InterpretImageFilename(image_info,(Image *) NULL,
2898  image_info->filename,(int) image_info->scene,component,exception);
2899  if ((LocaleCompare(component,image_info->filename) != 0) &&
2900  (strchr(component,'%') == (char *) NULL))
2901  image_info->adjoin=MagickFalse;
2902  }
2903  if ((image_info->adjoin != MagickFalse) && (frames > 0))
2904  {
2905  /*
2906  Some image formats do not support multiple frames per file.
2907  */
2908  magick_info=GetMagickInfo(magic,exception);
2909  if (magick_info != (const MagickInfo *) NULL)
2910  if (GetMagickAdjoin(magick_info) == MagickFalse)
2911  image_info->adjoin=MagickFalse;
2912  }
2913  if (image_info->affirm != MagickFalse)
2914  return(MagickTrue);
2915  if (frames == 0)
2916  {
2917  unsigned char
2918  *magick;
2919 
2920  size_t
2921  magick_size;
2922 
2923  /*
2924  Determine the image format from the first few bytes of the file.
2925  */
2926  magick_size=GetMagicPatternExtent(exception);
2927  if (magick_size == 0)
2928  return(MagickFalse);
2929  image=AcquireImage(image_info,exception);
2930  (void) CopyMagickString(image->filename,image_info->filename,
2932  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2933  if (status == MagickFalse)
2934  {
2935  image=DestroyImage(image);
2936  return(MagickFalse);
2937  }
2938  if ((IsBlobSeekable(image) == MagickFalse) ||
2939  (IsBlobExempt(image) != MagickFalse))
2940  {
2941  /*
2942  Copy image to seekable temporary file.
2943  */
2944  *component='\0';
2945  status=ImageToFile(image,component,exception);
2946  (void) CloseBlob(image);
2947  if (status == MagickFalse)
2948  {
2949  image=DestroyImage(image);
2950  return(MagickFalse);
2951  }
2952  SetImageInfoFile(image_info,(FILE *) NULL);
2953  (void) CopyMagickString(image->filename,component,MagickPathExtent);
2954  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2955  if (status == MagickFalse)
2956  {
2957  image=DestroyImage(image);
2958  return(MagickFalse);
2959  }
2960  (void) CopyMagickString(image_info->filename,component,
2962  image_info->temporary=MagickTrue;
2963  }
2964  magick=(unsigned char *) AcquireMagickMemory(magick_size);
2965  if (magick == (unsigned char *) NULL)
2966  {
2967  (void) CloseBlob(image);
2968  image=DestroyImage(image);
2969  return(MagickFalse);
2970  }
2971  (void) ResetMagickMemory(magick,0,magick_size);
2972  count=ReadBlob(image,magick_size,magick);
2973  (void) SeekBlob(image,-((MagickOffsetType) count),SEEK_CUR);
2974  (void) CloseBlob(image);
2975  image=DestroyImage(image);
2976  /*
2977  Check magic.xml configuration file.
2978  */
2979  sans_exception=AcquireExceptionInfo();
2980  magic_info=GetMagicInfo(magick,(size_t) count,sans_exception);
2981  magick=(unsigned char *) RelinquishMagickMemory(magick);
2982  if ((magic_info != (const MagicInfo *) NULL) &&
2983  (GetMagicName(magic_info) != (char *) NULL))
2984  {
2985  /*
2986  Try to use magick_info that was determined earlier by the extension
2987  */
2988  if ((magick_info != (const MagickInfo *) NULL) &&
2989  (GetMagickUseExtension(magick_info) != MagickFalse) &&
2990  (LocaleCompare(magick_info->module,GetMagicName(
2991  magic_info)) == 0))
2992  (void) CopyMagickString(image_info->magick,magick_info->name,
2994  else
2995  {
2996  (void) CopyMagickString(image_info->magick,GetMagicName(
2997  magic_info),MagickPathExtent);
2998  magick_info=GetMagickInfo(image_info->magick,sans_exception);
2999  }
3000  if ((magick_info == (const MagickInfo *) NULL) ||
3001  (GetMagickEndianSupport(magick_info) == MagickFalse))
3002  image_info->endian=UndefinedEndian;
3003  sans_exception=DestroyExceptionInfo(sans_exception);
3004  return(MagickTrue);
3005  }
3006  magick_info=GetMagickInfo(image_info->magick,sans_exception);
3007  if ((magick_info == (const MagickInfo *) NULL) ||
3008  (GetMagickEndianSupport(magick_info) == MagickFalse))
3009  image_info->endian=UndefinedEndian;
3010  sans_exception=DestroyExceptionInfo(sans_exception);
3011  }
3012  return(MagickTrue);
3013 }
3014 
3015 /*
3016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3017 % %
3018 % %
3019 % %
3020 % S e t I m a g e I n f o B l o b %
3021 % %
3022 % %
3023 % %
3024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3025 %
3026 % SetImageInfoBlob() sets the image info blob member.
3027 %
3028 % The format of the SetImageInfoBlob method is:
3029 %
3030 % void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
3031 % const size_t length)
3032 %
3033 % A description of each parameter follows:
3034 %
3035 % o image_info: the image info.
3036 %
3037 % o blob: the blob.
3038 %
3039 % o length: the blob length.
3040 %
3041 */
3042 MagickExport void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
3043  const size_t length)
3044 {
3045  assert(image_info != (ImageInfo *) NULL);
3046  assert(image_info->signature == MagickCoreSignature);
3047  if (image_info->debug != MagickFalse)
3049  image_info->filename);
3050  image_info->blob=(void *) blob;
3051  image_info->length=length;
3052 }
3053 
3054 /*
3055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3056 % %
3057 % %
3058 % %
3059 % S e t I m a g e I n f o C u s t o m S t r e a m %
3060 % %
3061 % %
3062 % %
3063 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3064 %
3065 % SetImageInfoCustomStream() sets the image info custom stream handlers.
3066 %
3067 % The format of the SetImageInfoCustomStream method is:
3068 %
3069 % void SetImageInfoCustomStream(ImageInfo *image_info,
3070 % CustomStreamInfo *custom_stream)
3071 %
3072 % A description of each parameter follows:
3073 %
3074 % o image_info: the image info.
3075 %
3076 % o custom_stream: your custom stream methods.
3077 %
3078 */
3080  CustomStreamInfo *custom_stream)
3081 {
3082  assert(image_info != (ImageInfo *) NULL);
3083  assert(image_info->signature == MagickCoreSignature);
3084  if (image_info->debug != MagickFalse)
3086  image_info->filename);
3087  image_info->custom_stream=(CustomStreamInfo *) custom_stream;
3088 }
3089 
3090 /*
3091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3092 % %
3093 % %
3094 % %
3095 % S e t I m a g e I n f o F i l e %
3096 % %
3097 % %
3098 % %
3099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3100 %
3101 % SetImageInfoFile() sets the image info file member.
3102 %
3103 % The format of the SetImageInfoFile method is:
3104 %
3105 % void SetImageInfoFile(ImageInfo *image_info,FILE *file)
3106 %
3107 % A description of each parameter follows:
3108 %
3109 % o image_info: the image info.
3110 %
3111 % o file: the file.
3112 %
3113 */
3114 MagickExport void SetImageInfoFile(ImageInfo *image_info,FILE *file)
3115 {
3116  assert(image_info != (ImageInfo *) NULL);
3117  assert(image_info->signature == MagickCoreSignature);
3118  if (image_info->debug != MagickFalse)
3120  image_info->filename);
3121  image_info->file=file;
3122 }
3123 
3124 /*
3125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3126 % %
3127 % %
3128 % %
3129 % S e t I m a g e M a s k %
3130 % %
3131 % %
3132 % %
3133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3134 %
3135 % SetImageMask() associates a mask with the image. The mask must be the same
3136 % dimensions as the image.
3137 %
3138 % The format of the SetImageMask method is:
3139 %
3140 % MagickBooleanType SetImageMask(Image *image,const PixelMask type,
3141 % const Image *mask,ExceptionInfo *exception)
3142 %
3143 % A description of each parameter follows:
3144 %
3145 % o image: the image.
3146 %
3147 % o type: the mask type, ReadPixelMask or WritePixelMask.
3148 %
3149 % o mask: the image mask.
3150 %
3151 % o exception: return any errors or warnings in this structure.
3152 %
3153 */
3155  const Image *mask,ExceptionInfo *exception)
3156 {
3157  CacheView
3158  *mask_view,
3159  *image_view;
3160 
3162  status;
3163 
3164  ssize_t
3165  y;
3166 
3167  /*
3168  Set image mask.
3169  */
3170  assert(image != (Image *) NULL);
3171  if (image->debug != MagickFalse)
3172  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3173  assert(image->signature == MagickCoreSignature);
3174  if (mask == (const Image *) NULL)
3175  {
3176  switch (type)
3177  {
3178  case WritePixelMask: image->write_mask=MagickFalse; break;
3179  default: image->read_mask=MagickFalse; break;
3180  }
3181  return(SyncImagePixelCache(image,exception));
3182  }
3183  switch (type)
3184  {
3185  case WritePixelMask: image->write_mask=MagickTrue; break;
3186  default: image->read_mask=MagickTrue; break;
3187  }
3188  if (SyncImagePixelCache(image,exception) == MagickFalse)
3189  return(MagickFalse);
3190  status=MagickTrue;
3191  mask_view=AcquireVirtualCacheView(mask,exception);
3192  image_view=AcquireAuthenticCacheView(image,exception);
3193 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3194  #pragma omp parallel for schedule(static,4) shared(status) \
3195  magick_number_threads(mask,image,image->rows,1)
3196 #endif
3197  for (y=0; y < (ssize_t) image->rows; y++)
3198  {
3199  register const Quantum
3200  *magick_restrict p;
3201 
3202  register Quantum
3203  *magick_restrict q;
3204 
3205  register ssize_t
3206  x;
3207 
3208  if (status == MagickFalse)
3209  continue;
3210  p=GetCacheViewVirtualPixels(mask_view,0,y,mask->columns,1,exception);
3211  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3212  if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
3213  {
3214  status=MagickFalse;
3215  continue;
3216  }
3217  for (x=0; x < (ssize_t) image->columns; x++)
3218  {
3220  intensity;
3221 
3222  intensity=0.0;
3223  if ((x < (ssize_t) mask->columns) && (y < (ssize_t) mask->rows))
3224  intensity=GetPixelIntensity(mask,p);
3225  switch (type)
3226  {
3227  case WritePixelMask:
3228  {
3229  SetPixelWriteMask(image,ClampToQuantum(intensity),q);
3230  break;
3231  }
3232  default:
3233  {
3234  SetPixelReadMask(image,ClampToQuantum(intensity),q);
3235  break;
3236  }
3237  }
3238  p+=GetPixelChannels(mask);
3239  q+=GetPixelChannels(image);
3240  }
3241  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3242  status=MagickFalse;
3243  }
3244  mask_view=DestroyCacheView(mask_view);
3245  image_view=DestroyCacheView(image_view);
3246  return(status);
3247 }
3248 
3249 /*
3250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3251 % %
3252 % %
3253 % %
3254 % S e t I m a g e R e g i o n M a s k %
3255 % %
3256 % %
3257 % %
3258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3259 %
3260 % SetImageRegionMask() associates a mask with the image as defined by the
3261 % specified region.
3262 %
3263 % The format of the SetImageRegionMask method is:
3264 %
3265 % MagickBooleanType SetImageRegionMask(Image *image,const PixelMask type,
3266 % const RectangleInfo *region,ExceptionInfo *exception)
3267 %
3268 % A description of each parameter follows:
3269 %
3270 % o image: the image.
3271 %
3272 % o type: the mask type, ReadPixelMask or WritePixelMask.
3273 %
3274 % o geometry: the mask region.
3275 %
3276 % o exception: return any errors or warnings in this structure.
3277 %
3278 */
3280  const PixelMask type,const RectangleInfo *region,ExceptionInfo *exception)
3281 {
3282  CacheView
3283  *image_view;
3284 
3286  status;
3287 
3288  ssize_t
3289  y;
3290 
3291  /*
3292  Set image mask as defined by the region.
3293  */
3294  assert(image != (Image *) NULL);
3295  if (image->debug != MagickFalse)
3296  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3297  assert(image->signature == MagickCoreSignature);
3298  if (region == (const RectangleInfo *) NULL)
3299  {
3300  switch (type)
3301  {
3302  case WritePixelMask: image->write_mask=MagickFalse; break;
3303  default: image->read_mask=MagickFalse; break;
3304  }
3305  return(SyncImagePixelCache(image,exception));
3306  }
3307  switch (type)
3308  {
3309  case WritePixelMask: image->write_mask=MagickTrue; break;
3310  default: image->read_mask=MagickTrue; break;
3311  }
3312  if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
3313  return(MagickFalse);
3314  status=MagickTrue;
3315  image_view=AcquireAuthenticCacheView(image,exception);
3316 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3317  #pragma omp parallel for schedule(static,4) shared(status) \
3318  magick_number_threads(image,image,image->rows,1)
3319 #endif
3320  for (y=0; y < (ssize_t) image->rows; y++)
3321  {
3322  register Quantum
3323  *magick_restrict q;
3324 
3325  register ssize_t
3326  x;
3327 
3328  if (status == MagickFalse)
3329  continue;
3330  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3331  if (q == (Quantum *) NULL)
3332  {
3333  status=MagickFalse;
3334  continue;
3335  }
3336  for (x=0; x < (ssize_t) image->columns; x++)
3337  {
3338  Quantum
3339  pixel;
3340 
3341  pixel=(Quantum) 0;
3342  if (((x >= region->x) && (x < (region->x+(ssize_t) region->width))) &&
3343  ((y >= region->y) && (y < (region->y+(ssize_t) region->height))))
3344  pixel=QuantumRange;
3345  switch (type)
3346  {
3347  case WritePixelMask:
3348  {
3349  SetPixelWriteMask(image,pixel,q);
3350  break;
3351  }
3352  default:
3353  {
3354  SetPixelReadMask(image,pixel,q);
3355  break;
3356  }
3357  }
3358  q+=GetPixelChannels(image);
3359  }
3360  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3361  status=MagickFalse;
3362  }
3363  image_view=DestroyCacheView(image_view);
3364  return(status);
3365 }
3366 
3367 /*
3368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3369 % %
3370 % %
3371 % %
3372 % 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 %
3373 % %
3374 % %
3375 % %
3376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3377 %
3378 % SetImageVirtualPixelMethod() sets the "virtual pixels" method for the
3379 % image and returns the previous setting. A virtual pixel is any pixel access
3380 % that is outside the boundaries of the image cache.
3381 %
3382 % The format of the SetImageVirtualPixelMethod() method is:
3383 %
3384 % VirtualPixelMethod SetImageVirtualPixelMethod(Image *image,
3385 % const VirtualPixelMethod virtual_pixel_method,ExceptionInfo *exception)
3386 %
3387 % A description of each parameter follows:
3388 %
3389 % o image: the image.
3390 %
3391 % o virtual_pixel_method: choose the type of virtual pixel.
3392 %
3393 % o exception: return any errors or warnings in this structure.
3394 %
3395 */
3397  const VirtualPixelMethod virtual_pixel_method,ExceptionInfo *exception)
3398 {
3399  assert(image != (const Image *) NULL);
3400  assert(image->signature == MagickCoreSignature);
3401  if (image->debug != MagickFalse)
3402  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3403  return(SetPixelCacheVirtualMethod(image,virtual_pixel_method,exception));
3404 }
3405 
3406 /*
3407 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3408 % %
3409 % %
3410 % %
3411 % S m u s h I m a g e s %
3412 % %
3413 % %
3414 % %
3415 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3416 %
3417 % SmushImages() takes all images from the current image pointer to the end
3418 % of the image list and smushes them to each other top-to-bottom if the
3419 % stack parameter is true, otherwise left-to-right.
3420 %
3421 % The current gravity setting now effects how the image is justified in the
3422 % final image.
3423 %
3424 % The format of the SmushImages method is:
3425 %
3426 % Image *SmushImages(const Image *images,const MagickBooleanType stack,
3427 % ExceptionInfo *exception)
3428 %
3429 % A description of each parameter follows:
3430 %
3431 % o images: the image sequence.
3432 %
3433 % o stack: A value other than 0 stacks the images top-to-bottom.
3434 %
3435 % o offset: minimum distance in pixels between images.
3436 %
3437 % o exception: return any errors or warnings in this structure.
3438 %
3439 */
3440 
3441 static ssize_t SmushXGap(const Image *smush_image,const Image *images,
3442  const ssize_t offset,ExceptionInfo *exception)
3443 {
3444  CacheView
3445  *left_view,
3446  *right_view;
3447 
3448  const Image
3449  *left_image,
3450  *right_image;
3451 
3453  left_geometry,
3454  right_geometry;
3455 
3456  register const Quantum
3457  *p;
3458 
3459  register ssize_t
3460  i,
3461  y;
3462 
3463  size_t
3464  gap;
3465 
3466  ssize_t
3467  x;
3468 
3469  if (images->previous == (Image *) NULL)
3470  return(0);
3471  right_image=images;
3472  SetGeometry(smush_image,&right_geometry);
3473  GravityAdjustGeometry(right_image->columns,right_image->rows,
3474  right_image->gravity,&right_geometry);
3475  left_image=images->previous;
3476  SetGeometry(smush_image,&left_geometry);
3477  GravityAdjustGeometry(left_image->columns,left_image->rows,
3478  left_image->gravity,&left_geometry);
3479  gap=right_image->columns;
3480  left_view=AcquireVirtualCacheView(left_image,exception);
3481  right_view=AcquireVirtualCacheView(right_image,exception);
3482  for (y=0; y < (ssize_t) smush_image->rows; y++)
3483  {
3484  for (x=(ssize_t) left_image->columns-1; x > 0; x--)
3485  {
3486  p=GetCacheViewVirtualPixels(left_view,x,left_geometry.y+y,1,1,exception);
3487  if ((p == (const Quantum *) NULL) ||
3488  (GetPixelAlpha(left_image,p) != TransparentAlpha) ||
3489  ((left_image->columns-x-1) >= gap))
3490  break;
3491  }
3492  i=(ssize_t) left_image->columns-x-1;
3493  for (x=0; x < (ssize_t) right_image->columns; x++)
3494  {
3495  p=GetCacheViewVirtualPixels(right_view,x,right_geometry.y+y,1,1,
3496  exception);
3497  if ((p == (const Quantum *) NULL) ||
3498  (GetPixelAlpha(right_image,p) != TransparentAlpha) ||
3499  ((x+i) >= (ssize_t) gap))
3500  break;
3501  }
3502  if ((x+i) < (ssize_t) gap)
3503  gap=(size_t) (x+i);
3504  }
3505  right_view=DestroyCacheView(right_view);
3506  left_view=DestroyCacheView(left_view);
3507  if (y < (ssize_t) smush_image->rows)
3508  return(offset);
3509  return((ssize_t) gap-offset);
3510 }
3511 
3512 static ssize_t SmushYGap(const Image *smush_image,const Image *images,
3513  const ssize_t offset,ExceptionInfo *exception)
3514 {
3515  CacheView
3516  *bottom_view,
3517  *top_view;
3518 
3519  const Image
3520  *bottom_image,
3521  *top_image;
3522 
3524  bottom_geometry,
3525  top_geometry;
3526 
3527  register const Quantum
3528  *p;
3529 
3530  register ssize_t
3531  i,
3532  x;
3533 
3534  size_t
3535  gap;
3536 
3537  ssize_t
3538  y;
3539 
3540  if (images->previous == (Image *) NULL)
3541  return(0);
3542  bottom_image=images;
3543  SetGeometry(smush_image,&bottom_geometry);
3544  GravityAdjustGeometry(bottom_image->columns,bottom_image->rows,
3545  bottom_image->gravity,&bottom_geometry);
3546  top_image=images->previous;
3547  SetGeometry(smush_image,&top_geometry);
3548  GravityAdjustGeometry(top_image->columns,top_image->rows,top_image->gravity,
3549  &top_geometry);
3550  gap=bottom_image->rows;
3551  top_view=AcquireVirtualCacheView(top_image,exception);
3552  bottom_view=AcquireVirtualCacheView(bottom_image,exception);
3553  for (x=0; x < (ssize_t) smush_image->columns; x++)
3554  {
3555  for (y=(ssize_t) top_image->rows-1; y > 0; y--)
3556  {
3557  p=GetCacheViewVirtualPixels(top_view,top_geometry.x+x,y,1,1,exception);
3558  if ((p == (const Quantum *) NULL) ||
3559  (GetPixelAlpha(top_image,p) != TransparentAlpha) ||
3560  ((top_image->rows-y-1) >= gap))
3561  break;
3562  }
3563  i=(ssize_t) top_image->rows-y-1;
3564  for (y=0; y < (ssize_t) bottom_image->rows; y++)
3565  {
3566  p=GetCacheViewVirtualPixels(bottom_view,bottom_geometry.x+x,y,1,1,
3567  exception);
3568  if ((p == (const Quantum *) NULL) ||
3569  (GetPixelAlpha(bottom_image,p) != TransparentAlpha) ||
3570  ((y+i) >= (ssize_t) gap))
3571  break;
3572  }
3573  if ((y+i) < (ssize_t) gap)
3574  gap=(size_t) (y+i);
3575  }
3576  bottom_view=DestroyCacheView(bottom_view);
3577  top_view=DestroyCacheView(top_view);
3578  if (x < (ssize_t) smush_image->columns)
3579  return(offset);
3580  return((ssize_t) gap-offset);
3581 }
3582 
3584  const MagickBooleanType stack,const ssize_t offset,ExceptionInfo *exception)
3585 {
3586 #define SmushImageTag "Smush/Image"
3587 
3588  const Image
3589  *image;
3590 
3591  Image
3592  *smush_image;
3593 
3595  proceed,
3596  status;
3597 
3599  n;
3600 
3601  PixelTrait
3602  alpha_trait;
3603 
3605  geometry;
3606 
3607  register const Image
3608  *next;
3609 
3610  size_t
3611  height,
3612  number_images,
3613  width;
3614 
3615  ssize_t
3616  x_offset,
3617  y_offset;
3618 
3619  /*
3620  Compute maximum area of smushed area.
3621  */
3622  assert(images != (Image *) NULL);
3623  assert(images->signature == MagickCoreSignature);
3624  if (images->debug != MagickFalse)
3625  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3626  assert(exception != (ExceptionInfo *) NULL);
3627  assert(exception->signature == MagickCoreSignature);
3628  image=images;
3629  alpha_trait=image->alpha_trait;
3630  number_images=1;
3631  width=image->columns;
3632  height=image->rows;
3633  next=GetNextImageInList(image);
3634  for ( ; next != (Image *) NULL; next=GetNextImageInList(next))
3635  {
3636  if (next->alpha_trait != UndefinedPixelTrait)
3637  alpha_trait=BlendPixelTrait;
3638  number_images++;
3639  if (stack != MagickFalse)
3640  {
3641  if (next->columns > width)
3642  width=next->columns;
3643  height+=next->rows;
3644  if (next->previous != (Image *) NULL)
3645  height+=offset;
3646  continue;
3647  }
3648  width+=next->columns;
3649  if (next->previous != (Image *) NULL)
3650  width+=offset;
3651  if (next->rows > height)
3652  height=next->rows;
3653  }
3654  /*
3655  Smush images.
3656  */
3657  smush_image=CloneImage(image,width,height,MagickTrue,exception);
3658  if (smush_image == (Image *) NULL)
3659  return((Image *) NULL);
3660  if (SetImageStorageClass(smush_image,DirectClass,exception) == MagickFalse)
3661  {
3662  smush_image=DestroyImage(smush_image);
3663  return((Image *) NULL);
3664  }
3665  smush_image->alpha_trait=alpha_trait;
3666  (void) SetImageBackgroundColor(smush_image,exception);
3667  status=MagickTrue;
3668  x_offset=0;
3669  y_offset=0;
3670  for (n=0; n < (MagickOffsetType) number_images; n++)
3671  {
3672  SetGeometry(smush_image,&geometry);
3673  GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
3674  if (stack != MagickFalse)
3675  {
3676  x_offset-=geometry.x;
3677  y_offset-=SmushYGap(smush_image,image,offset,exception);
3678  }
3679  else
3680  {
3681  x_offset-=SmushXGap(smush_image,image,offset,exception);
3682  y_offset-=geometry.y;
3683  }
3684  status=CompositeImage(smush_image,image,OverCompositeOp,MagickTrue,x_offset,
3685  y_offset,exception);
3686  proceed=SetImageProgress(image,SmushImageTag,n,number_images);
3687  if (proceed == MagickFalse)
3688  break;
3689  if (stack == MagickFalse)
3690  {
3691  x_offset+=(ssize_t) image->columns;
3692  y_offset=0;
3693  }
3694  else
3695  {
3696  x_offset=0;
3697  y_offset+=(ssize_t) image->rows;
3698  }
3699  image=GetNextImageInList(image);
3700  }
3701  if (stack == MagickFalse)
3702  smush_image->columns=(size_t) x_offset;
3703  else
3704  smush_image->rows=(size_t) y_offset;
3705  if (status == MagickFalse)
3706  smush_image=DestroyImage(smush_image);
3707  return(smush_image);
3708 }
3709 
3710 /*
3711 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3712 % %
3713 % %
3714 % %
3715 % S t r i p I m a g e %
3716 % %
3717 % %
3718 % %
3719 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3720 %
3721 % StripImage() strips an image of all profiles and comments.
3722 %
3723 % The format of the StripImage method is:
3724 %
3725 % MagickBooleanType StripImage(Image *image,ExceptionInfo *exception)
3726 %
3727 % A description of each parameter follows:
3728 %
3729 % o image: the image.
3730 %
3731 % o exception: return any errors or warnings in this structure.
3732 %
3733 */
3735 {
3737  status;
3738 
3739  assert(image != (Image *) NULL);
3740  if (image->debug != MagickFalse)
3741  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3742  (void) exception;
3743  DestroyImageProfiles(image);
3744  (void) DeleteImageProperty(image,"comment");
3745  (void) DeleteImageProperty(image,"date:create");
3746  (void) DeleteImageProperty(image,"date:modify");
3747  status=SetImageArtifact(image,"png:exclude-chunk",
3748  "bKGD,caNv,cHRM,eXIf,gAMA,iCCP,iTXt,pHYs,sRGB,tEXt,zCCP,zTXt,date");
3749  return(status);
3750 }
3751 
3752 /*
3753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3754 % %
3755 % %
3756 % %
3757 + S y n c I m a g e %
3758 % %
3759 % %
3760 % %
3761 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3762 %
3763 % SyncImage() initializes the red, green, and blue intensities of each pixel
3764 % as defined by the colormap index.
3765 %
3766 % The format of the SyncImage method is:
3767 %
3768 % MagickBooleanType SyncImage(Image *image,ExceptionInfo *exception)
3769 %
3770 % A description of each parameter follows:
3771 %
3772 % o image: the image.
3773 %
3774 % o exception: return any errors or warnings in this structure.
3775 %
3776 */
3777 
3778 static inline Quantum PushColormapIndex(Image *image,const Quantum index,
3779  MagickBooleanType *range_exception)
3780 {
3781  if ((size_t) index < image->colors)
3782  return(index);
3783  *range_exception=MagickTrue;
3784  return((Quantum) 0);
3785 }
3786 
3788 {
3789  CacheView
3790  *image_view;
3791 
3793  range_exception,
3794  status,
3795  taint;
3796 
3797  ssize_t
3798  y;
3799 
3800  assert(image != (Image *) NULL);
3801  if (image->debug != MagickFalse)
3802  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3803  assert(image->signature == MagickCoreSignature);
3804  if (image->ping != MagickFalse)
3805  return(MagickTrue);
3806  if (image->storage_class != PseudoClass)
3807  return(MagickFalse);
3808  assert(image->colormap != (PixelInfo *) NULL);
3809  range_exception=MagickFalse;
3810  status=MagickTrue;
3811  taint=image->taint;
3812  image_view=AcquireAuthenticCacheView(image,exception);
3813 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3814  #pragma omp parallel for schedule(static,4) shared(range_exception,status) \
3815  magick_number_threads(image,image,image->rows,1)
3816 #endif
3817  for (y=0; y < (ssize_t) image->rows; y++)
3818  {
3819  Quantum
3820  index;
3821 
3822  register Quantum
3823  *magick_restrict q;
3824 
3825  register ssize_t
3826  x;
3827 
3828  if (status == MagickFalse)
3829  continue;
3830  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3831  if (q == (Quantum *) NULL)
3832  {
3833  status=MagickFalse;
3834  continue;
3835  }
3836  for (x=0; x < (ssize_t) image->columns; x++)
3837  {
3838  index=PushColormapIndex(image,GetPixelIndex(image,q),&range_exception);
3839  SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);
3840  q+=GetPixelChannels(image);
3841  }
3842  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3843  status=MagickFalse;
3844  }
3845  image_view=DestroyCacheView(image_view);
3846  image->taint=taint;
3847  if ((image->ping == MagickFalse) && (range_exception != MagickFalse))
3848  (void) ThrowMagickException(exception,GetMagickModule(),
3849  CorruptImageWarning,"InvalidColormapIndex","`%s'",image->filename);
3850  return(status);
3851 }
3852 
3853 /*
3854 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3855 % %
3856 % %
3857 % %
3858 % S y n c I m a g e S e t t i n g s %
3859 % %
3860 % %
3861 % %
3862 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3863 %
3864 % SyncImageSettings() syncs any image_info global options into per-image
3865 % attributes.
3866 %
3867 % Note: in IMv6 free form 'options' were always mapped into 'artifacts', so
3868 % that operations and coders can find such settings. In IMv7 if a desired
3869 % per-image artifact is not set, then it will directly look for a global
3870 % option as a fallback, as such this copy is no longer needed, only the
3871 % link set up.
3872 %
3873 % The format of the SyncImageSettings method is:
3874 %
3875 % MagickBooleanType SyncImageSettings(const ImageInfo *image_info,
3876 % Image *image,ExceptionInfo *exception)
3877 % MagickBooleanType SyncImagesSettings(const ImageInfo *image_info,
3878 % Image *image,ExceptionInfo *exception)
3879 %
3880 % A description of each parameter follows:
3881 %
3882 % o image_info: the image info.
3883 %
3884 % o image: the image.
3885 %
3886 % o exception: return any errors or warnings in this structure.
3887 %
3888 */
3889 
3891  Image *images,ExceptionInfo *exception)
3892 {
3893  Image
3894  *image;
3895 
3896  assert(image_info != (const ImageInfo *) NULL);
3897  assert(image_info->signature == MagickCoreSignature);
3898  assert(images != (Image *) NULL);
3899  assert(images->signature == MagickCoreSignature);
3900  if (images->debug != MagickFalse)
3901  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3902  image=images;
3903  for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
3904  (void) SyncImageSettings(image_info,image,exception);
3905  (void) DeleteImageOption(image_info,"page");
3906  return(MagickTrue);
3907 }
3908 
3911 {
3912  const char
3913  *option;
3914 
3915  GeometryInfo
3916  geometry_info;
3917 
3919  flags;
3920 
3922  units;
3923 
3924  /*
3925  Sync image options.
3926  */
3927  assert(image_info != (const ImageInfo *) NULL);
3928  assert(image_info->signature == MagickCoreSignature);
3929  assert(image != (Image *) NULL);
3930  assert(image->signature == MagickCoreSignature);
3931  if (image->debug != MagickFalse)
3932  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3933  option=GetImageOption(image_info,"background");
3934  if (option != (const char *) NULL)
3935  (void) QueryColorCompliance(option,AllCompliance,&image->background_color,
3936  exception);
3937  option=GetImageOption(image_info,"black-point-compensation");
3938  if (option != (const char *) NULL)
3941  option=GetImageOption(image_info,"blue-primary");
3942  if (option != (const char *) NULL)
3943  {
3944  flags=ParseGeometry(option,&geometry_info);
3945  image->chromaticity.blue_primary.x=geometry_info.rho;
3946  image->chromaticity.blue_primary.y=geometry_info.sigma;
3947  if ((flags & SigmaValue) == 0)
3949  }
3950  option=GetImageOption(image_info,"bordercolor");
3951  if (option != (const char *) NULL)
3952  (void) QueryColorCompliance(option,AllCompliance,&image->border_color,
3953  exception);
3954  /* FUTURE: do not sync compose to per-image compose setting here */
3955  option=GetImageOption(image_info,"compose");
3956  if (option != (const char *) NULL)
3958  MagickFalse,option);
3959  /* -- */
3960  option=GetImageOption(image_info,"compress");
3961  if (option != (const char *) NULL)
3964  option=GetImageOption(image_info,"debug");
3965  if (option != (const char *) NULL)
3967  MagickFalse,option);
3968  option=GetImageOption(image_info,"density");
3969  if (option != (const char *) NULL)
3970  {
3971  flags=ParseGeometry(option,&geometry_info);
3972  image->resolution.x=geometry_info.rho;
3973  image->resolution.y=geometry_info.sigma;
3974  if ((flags & SigmaValue) == 0)
3975  image->resolution.y=image->resolution.x;
3976  }
3977  option=GetImageOption(image_info,"depth");
3978  if (option != (const char *) NULL)
3979  image->depth=StringToUnsignedLong(option);
3980  option=GetImageOption(image_info,"endian");
3981  if (option != (const char *) NULL)
3983  MagickFalse,option);
3984  option=GetImageOption(image_info,"filter");
3985  if (option != (const char *) NULL)
3987  MagickFalse,option);
3988  option=GetImageOption(image_info,"fuzz");
3989  if (option != (const char *) NULL)
3990  image->fuzz=StringToDoubleInterval(option,(double) QuantumRange+1.0);
3991  option=GetImageOption(image_info,"gravity");
3992  if (option != (const char *) NULL)
3994  MagickFalse,option);
3995  option=GetImageOption(image_info,"green-primary");
3996  if (option != (const char *) NULL)
3997  {
3998  flags=ParseGeometry(option,&geometry_info);
3999  image->chromaticity.green_primary.x=geometry_info.rho;
4000  image->chromaticity.green_primary.y=geometry_info.sigma;
4001  if ((flags & SigmaValue) == 0)
4003  }
4004  option=GetImageOption(image_info,"intent");
4005  if (option != (const char *) NULL)
4008  option=GetImageOption(image_info,"intensity");
4009  if (option != (const char *) NULL)
4012  option=GetImageOption(image_info,"interlace");
4013  if (option != (const char *) NULL)
4015  MagickFalse,option);
4016  option=GetImageOption(image_info,"interpolate");
4017  if (option != (const char *) NULL)
4020  option=GetImageOption(image_info,"loop");
4021  if (option != (const char *) NULL)
4022  image->iterations=StringToUnsignedLong(option);
4023  option=GetImageOption(image_info,"mattecolor");
4024  if (option != (const char *) NULL)
4025  (void) QueryColorCompliance(option,AllCompliance,&image->matte_color,
4026  exception);
4027  option=GetImageOption(image_info,"orient");
4028  if (option != (const char *) NULL)
4031  option=GetImageOption(image_info,"page");
4032  if (option != (const char *) NULL)
4033  {
4034  char
4035  *geometry;
4036 
4037  geometry=GetPageGeometry(option);
4038  flags=ParseAbsoluteGeometry(geometry,&image->page);
4039  geometry=DestroyString(geometry);
4040  }
4041  option=GetImageOption(image_info,"quality");
4042  if (option != (const char *) NULL)
4043  image->quality=StringToUnsignedLong(option);
4044  option=GetImageOption(image_info,"red-primary");
4045  if (option != (const char *) NULL)
4046  {
4047  flags=ParseGeometry(option,&geometry_info);
4048  image->chromaticity.red_primary.x=geometry_info.rho;
4049  image->chromaticity.red_primary.y=geometry_info.sigma;
4050  if ((flags & SigmaValue) == 0)
4052  }
4053  if (image_info->quality != UndefinedCompressionQuality)
4054  image->quality=image_info->quality;
4055  option=GetImageOption(image_info,"scene");
4056  if (option != (const char *) NULL)
4057  image->scene=StringToUnsignedLong(option);
4058  option=GetImageOption(image_info,"taint");
4059  if (option != (const char *) NULL)
4061  MagickFalse,option);
4062  option=GetImageOption(image_info,"tile-offset");
4063  if (option != (const char *) NULL)
4064  {
4065  char
4066  *geometry;
4067 
4068  geometry=GetPageGeometry(option);
4069  flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4070  geometry=DestroyString(geometry);
4071  }
4072  option=GetImageOption(image_info,"transparent-color");
4073  if (option != (const char *) NULL)
4075  exception);
4076  option=GetImageOption(image_info,"type");
4077  if (option != (const char *) NULL)
4079  option);
4080  option=GetImageOption(image_info,"units");
4081  units=image_info->units;
4082  if (option != (const char *) NULL)
4084  MagickFalse,option);
4085  if (units != UndefinedResolution)
4086  {
4087  if (image->units != units)
4088  switch (image->units)
4089  {
4091  {
4092  if (units == PixelsPerCentimeterResolution)
4093  {
4094  image->resolution.x/=2.54;
4095  image->resolution.y/=2.54;
4096  }
4097  break;
4098  }
4100  {
4101  if (units == PixelsPerInchResolution)
4102  {
4103  image->resolution.x=(double) ((size_t) (100.0*2.54*
4104  image->resolution.x+0.5))/100.0;
4105  image->resolution.y=(double) ((size_t) (100.0*2.54*
4106  image->resolution.y+0.5))/100.0;
4107  }
4108  break;
4109  }
4110  default:
4111  break;
4112  }
4113  image->units=units;
4114  }
4115  option=GetImageOption(image_info,"virtual-pixel");
4116  if (option != (const char *) NULL)
4119  exception);
4120  option=GetImageOption(image_info,"white-point");
4121  if (option != (const char *) NULL)
4122  {
4123  flags=ParseGeometry(option,&geometry_info);
4124  image->chromaticity.white_point.x=geometry_info.rho;
4125  image->chromaticity.white_point.y=geometry_info.sigma;
4126  if ((flags & SigmaValue) == 0)
4128  }
4129  /*
4130  Pointer to allow the lookup of pre-image artifact will fallback to a global
4131  option setting/define. This saves a lot of duplication of global options
4132  into per-image artifacts, while ensuring only specifically set per-image
4133  artifacts are preserved when parenthesis ends.
4134  */
4135  if (image->image_info != (ImageInfo *) NULL)
4136  image->image_info=DestroyImageInfo(image->image_info);
4137  image->image_info=CloneImageInfo(image_info);
4138  return(MagickTrue);
4139 }
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:3419
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:814
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:3787
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:2123
FilterType filter
Definition: image.h:219
MagickExport MagickBooleanType DeleteImageOption(ImageInfo *image_info, const char *option)
Definition: option.c:2214
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:2954
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:2036
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:698
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:3909
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:5288
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:4532
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:2305
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:3042
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:2127
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:2289
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)
#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:2250
EndianType
Definition: quantum.h:28
char * size
Definition: image.h:381
MagickExport void SetImageInfoFile(ImageInfo *image_info, FILE *file)
Definition: image.c:3114
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:134
MagickExport MagickBooleanType SetImageMask(Image *image, const PixelMask type, const Image *mask, ExceptionInfo *exception)
Definition: image.c:3154
#define UndefinedTicksPerSecond
Definition: image-private.h:35
MagickExport MagickBooleanType IsGeometry(const char *geometry)
Definition: geometry.c:605
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:3441
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:1892
MagickExport void * ResetMagickMemory(void *memory, int byte, const size_t size)
Definition: memory.c:1153
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:314
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:4755
MagickExport ChannelType SetImageChannelMask(Image *image, const ChannelType channel_mask)
Definition: image.c:2473
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:2677
MagickExport VirtualPixelMethod SetImageVirtualPixelMethod(Image *image, const VirtualPixelMethod virtual_pixel_method, ExceptionInfo *exception)
Definition: image.c:3396
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:2389
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:3583
MagickExport MagickBooleanType SetImageColor(Image *image, const PixelInfo *color, ExceptionInfo *exception)
Definition: image.c:2506
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:3778
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:2589
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:2159
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:2709
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:2631
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:3890
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:2230
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:1929
MagickExport MagickBooleanType CloneImageOptions(ImageInfo *image_info, const ImageInfo *clone_info)
Definition: option.c:2117
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:279
MagickExport const char * GetImageProperty(const Image *image, const char *property, ExceptionInfo *exception)
Definition: property.c:2199
MagickExport MagickBooleanType ModifyImage(Image **image, ExceptionInfo *exception)
Definition: image.c:1982
MagickPrivate VirtualPixelMethod SetPixelCacheVirtualMethod(Image *, const VirtualPixelMethod, ExceptionInfo *)
Definition: cache.c:4996
MagickExport MagickBooleanType IsBlobExempt(const Image *image)
Definition: blob.c:2678
MagickExport MagickBooleanType StripImage(Image *image, ExceptionInfo *exception)
Definition: image.c:3734
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:848
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:1653
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:1788
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:526
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:3079
MagickExport BlobInfo * ReferenceBlob(BlobInfo *)
Definition: blob.c:4595
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:3512
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:646
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:3279
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 void * CopyMagickMemory(void *destination, const void *source, const size_t size)
Definition: memory.c:710
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