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