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. It checks if the
1152 % blob of the specified image is referenced by other images. If the reference
1153 % count is higher then 1 a new blob is assigned to the specified image.
1154 %
1155 % The format of the DisassociateImageStream method is:
1156 %
1157 % void DisassociateImageStream(const Image *image)
1158 %
1159 % A description of each parameter follows:
1160 %
1161 % o image: the image.
1162 %
1163 */
1165 {
1166  assert(image != (Image *) NULL);
1167  assert(image->signature == MagickSignature);
1168  if (image->debug != MagickFalse)
1169  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1170  DisassociateBlob(image);
1171 }
1172 
1173 /*
1174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1175 % %
1176 % %
1177 % %
1178 % G e t I m a g e C l i p M a s k %
1179 % %
1180 % %
1181 % %
1182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1183 %
1184 % GetImageClipMask() returns the clip path associated with the image.
1185 %
1186 % The format of the GetImageClipMask method is:
1187 %
1188 % Image *GetImageClipMask(const Image *image,ExceptionInfo *exception)
1189 %
1190 % A description of each parameter follows:
1191 %
1192 % o image: the image.
1193 %
1194 */
1197 {
1198  assert(image != (const Image *) NULL);
1199  if (image->debug != MagickFalse)
1200  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1201  assert(image->signature == MagickSignature);
1202  if (image->clip_mask == (Image *) NULL)
1203  return((Image *) NULL);
1204  return(CloneImage(image->clip_mask,0,0,MagickTrue,exception));
1205 }
1206 
1207 /*
1208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1209 % %
1210 % %
1211 % %
1212 % G e t I m a g e E x c e p t i o n %
1213 % %
1214 % %
1215 % %
1216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1217 %
1218 % GetImageException() traverses an image sequence and returns any
1219 % error more severe than noted by the exception parameter.
1220 %
1221 % The format of the GetImageException method is:
1222 %
1223 % void GetImageException(Image *image,ExceptionInfo *exception)
1224 %
1225 % A description of each parameter follows:
1226 %
1227 % o image: Specifies a pointer to a list of one or more images.
1228 %
1229 % o exception: return the highest severity exception.
1230 %
1231 */
1233 {
1234  register Image
1235  *next;
1236 
1237  assert(image != (Image *) NULL);
1238  assert(image->signature == MagickSignature);
1239  if (image->debug != MagickFalse)
1240  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1241  assert(exception != (ExceptionInfo *) NULL);
1242  assert(exception->signature == MagickSignature);
1243  for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
1244  {
1245  if (next->exception.severity == UndefinedException)
1246  continue;
1247  if (next->exception.severity > exception->severity)
1248  InheritException(exception,&next->exception);
1250  }
1251 }
1252 
1253 /*
1254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1255 % %
1256 % %
1257 % %
1258 % G e t I m a g e I n f o %
1259 % %
1260 % %
1261 % %
1262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1263 %
1264 % GetImageInfo() initializes image_info to default values.
1265 %
1266 % The format of the GetImageInfo method is:
1267 %
1268 % void GetImageInfo(ImageInfo *image_info)
1269 %
1270 % A description of each parameter follows:
1271 %
1272 % o image_info: the image info.
1273 %
1274 */
1276 {
1277  char
1278  *synchronize;
1279 
1281  *exception;
1282 
1283  /*
1284  File and image dimension members.
1285  */
1286  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1287  assert(image_info != (ImageInfo *) NULL);
1288  (void) ResetMagickMemory(image_info,0,sizeof(*image_info));
1289  image_info->adjoin=MagickTrue;
1290  image_info->interlace=NoInterlace;
1291  image_info->channel=DefaultChannels;
1293  image_info->antialias=MagickTrue;
1294  image_info->dither=MagickTrue;
1295  synchronize=GetEnvironmentValue("MAGICK_SYNCHRONIZE");
1296  if (synchronize != (const char *) NULL)
1297  {
1298  image_info->synchronize=IsStringTrue(synchronize);
1299  synchronize=DestroyString(synchronize);
1300  }
1301  exception=AcquireExceptionInfo();
1303  exception);
1304  (void) QueryColorDatabase(BorderColor,&image_info->border_color,exception);
1305  (void) QueryColorDatabase(MatteColor,&image_info->matte_color,exception);
1307  exception);
1308  exception=DestroyExceptionInfo(exception);
1309  image_info->debug=IsEventLogging();
1310  image_info->signature=MagickSignature;
1311 }
1312 
1313 /*
1314 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1315 % %
1316 % %
1317 % %
1318 % G e t I m a g e I n f o F i l e %
1319 % %
1320 % %
1321 % %
1322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1323 %
1324 % GetImageInfoFile() returns the image info file member.
1325 %
1326 % The format of the GetImageInfoFile method is:
1327 %
1328 % FILE *GetImageInfoFile(const ImageInfo *image_info)
1329 %
1330 % A description of each parameter follows:
1331 %
1332 % o image_info: the image info.
1333 %
1334 */
1335 MagickExport FILE *GetImageInfoFile(const ImageInfo *image_info)
1336 {
1337  return(image_info->file);
1338 }
1339 
1340 /*
1341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1342 % %
1343 % %
1344 % %
1345 % G e t I m a g e M a s k %
1346 % %
1347 % %
1348 % %
1349 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1350 %
1351 % GetImageMask() returns the mask associated with the image.
1352 %
1353 % The format of the GetImageMask method is:
1354 %
1355 % Image *GetImageMask(const Image *image,ExceptionInfo *exception)
1356 %
1357 % A description of each parameter follows:
1358 %
1359 % o image: the image.
1360 %
1361 */
1363 {
1364  assert(image != (const Image *) NULL);
1365  if (image->debug != MagickFalse)
1366  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1367  assert(image->signature == MagickSignature);
1368  if (image->mask == (Image *) NULL)
1369  return((Image *) NULL);
1370  return(CloneImage(image->mask,0,0,MagickTrue,exception));
1371 }
1372 
1373 /*
1374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1375 % %
1376 % %
1377 % %
1378 % G e t I m a g e C h a n n e l s %
1379 % %
1380 % %
1381 % %
1382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1383 %
1384 % GetImageChannels() returns the number of pixel channels associated with the
1385 % specified image.
1386 %
1387 % The format of the GetChannels method is:
1388 %
1389 % size_t GetImageChannels(Image *image)
1390 %
1391 % A description of each parameter follows:
1392 %
1393 % o image: the image.
1394 %
1395 */
1397 {
1398  assert(image != (Image *) NULL);
1399  assert(image->signature == MagickSignature);
1400  if (image->debug != MagickFalse)
1401  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1402  return(image->channels);
1403 }
1404 
1405 /*
1406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1407 % %
1408 % %
1409 % %
1410 + G e t I m a g e R e f e r e n c e C o u n t %
1411 % %
1412 % %
1413 % %
1414 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1415 %
1416 % GetImageReferenceCount() returns the image reference count.
1417 %
1418 % The format of the GetReferenceCount method is:
1419 %
1420 % ssize_t GetImageReferenceCount(Image *image)
1421 %
1422 % A description of each parameter follows:
1423 %
1424 % o image: the image.
1425 %
1426 */
1428 {
1429  ssize_t
1430  reference_count;
1431 
1432  assert(image != (Image *) NULL);
1433  assert(image->signature == MagickSignature);
1434  if (image->debug != MagickFalse)
1435  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1436  LockSemaphoreInfo(image->semaphore);
1437  reference_count=image->reference_count;
1439  return(reference_count);
1440 }
1441 
1442 /*
1443 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1444 % %
1445 % %
1446 % %
1447 % 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 %
1448 % %
1449 % %
1450 % %
1451 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1452 %
1453 % GetImageVirtualPixelMethod() gets the "virtual pixels" method for the
1454 % image. A virtual pixel is any pixel access that is outside the boundaries
1455 % of the image cache.
1456 %
1457 % The format of the GetImageVirtualPixelMethod() method is:
1458 %
1459 % VirtualPixelMethod GetImageVirtualPixelMethod(const Image *image)
1460 %
1461 % A description of each parameter follows:
1462 %
1463 % o image: the image.
1464 %
1465 */
1467 {
1468  assert(image != (Image *) NULL);
1469  assert(image->signature == MagickSignature);
1470  if (image->debug != MagickFalse)
1471  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1472  return(GetPixelCacheVirtualMethod(image));
1473 }
1474 
1475 /*
1476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1477 % %
1478 % %
1479 % %
1480 % I n t e r p r e t I m a g e F i l e n a m e %
1481 % %
1482 % %
1483 % %
1484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1485 %
1486 % InterpretImageFilename() interprets embedded characters in an image filename.
1487 % The filename length is returned.
1488 %
1489 % The format of the InterpretImageFilename method is:
1490 %
1491 % size_t InterpretImageFilename(const ImageInfo *image_info,Image *image,
1492 % const char *format,int value,char *filename)
1493 %
1494 % A description of each parameter follows.
1495 %
1496 % o image_info: the image info..
1497 %
1498 % o image: the image.
1499 %
1500 % o format: A filename describing the format to use to write the numeric
1501 % argument. Only the first numeric format identifier is replaced.
1502 %
1503 % o value: Numeric value to substitute into format filename.
1504 %
1505 % o filename: return the formatted filename in this character buffer.
1506 %
1507 */
1509  Image *image,const char *format,int value,char *filename)
1510 {
1511  char
1512  *q;
1513 
1514  int
1515  c;
1516 
1518  canonical;
1519 
1520  register const char
1521  *p;
1522 
1523  size_t
1524  length;
1525 
1526  canonical=MagickFalse;
1527  length=0;
1528  (void) CopyMagickString(filename,format,MaxTextExtent);
1529  for (p=strchr(format,'%'); p != (char *) NULL; p=strchr(p+1,'%'))
1530  {
1531  q=(char *) p+1;
1532  if (*q == '%')
1533  {
1534  p=q+1;
1535  continue;
1536  }
1537  if (*q == '0')
1538  {
1539  ssize_t
1540  value;
1541 
1542  value=(ssize_t) strtol(q,&q,10);
1543  (void) value;
1544  }
1545  switch (*q)
1546  {
1547  case 'd':
1548  case 'o':
1549  case 'x':
1550  {
1551  q++;
1552  c=(*q);
1553  *q='\0';
1554  (void) FormatLocaleString(filename+(p-format),(size_t) (MaxTextExtent-
1555  (p-format)),p,value);
1556  *q=c;
1557  (void) ConcatenateMagickString(filename,q,MaxTextExtent);
1558  canonical=MagickTrue;
1559  if (*(q-1) != '%')
1560  break;
1561  p++;
1562  break;
1563  }
1564  case '[':
1565  {
1566  char
1567  pattern[MaxTextExtent];
1568 
1569  const char
1570  *value;
1571 
1572  register char
1573  *r;
1574 
1575  register ssize_t
1576  i;
1577 
1578  ssize_t
1579  depth;
1580 
1581  /*
1582  Image option.
1583  */
1584  if (strchr(p,']') == (char *) NULL)
1585  break;
1586  depth=1;
1587  r=q+1;
1588  for (i=0; (i < (MaxTextExtent-1L)) && (*r != '\0'); i++)
1589  {
1590  if (*r == '[')
1591  depth++;
1592  if (*r == ']')
1593  depth--;
1594  if (depth <= 0)
1595  break;
1596  pattern[i]=(*r++);
1597  }
1598  pattern[i]='\0';
1599  if (LocaleNCompare(pattern,"filename:",9) != 0)
1600  break;
1601  value=(const char *) NULL;
1602 #if 0
1603  /* FUTURE: remove this code. -- Anthony 29 Arpil 2012
1604  Removed as GetMagickProperty() will will never match a "filename:"
1605  string as this is not a 'known' image property.
1606  */
1607  if ((image_info != (const ImageInfo *) NULL) &&
1608  (image != (const Image *) NULL))
1609  value=GetMagickProperty(image_info,image,pattern);
1610  else
1611 #endif
1612  if (image != (Image *) NULL)
1613  value=GetImageProperty(image,pattern);
1614  if ((value == (const char *) NULL) &&
1615  (image != (Image *) NULL))
1616  value=GetImageArtifact(image,pattern);
1617  if ((value == (const char *) NULL) &&
1618  (image_info != (ImageInfo *) NULL))
1619  value=GetImageOption(image_info,pattern);
1620  if (value == (const char *) NULL)
1621  break;
1622  q--;
1623  c=(*q);
1624  *q='\0';
1625  (void) CopyMagickString(filename+(p-format-length),value,(size_t)
1626  (MaxTextExtent-(p-format-length)));
1627  length+=strlen(pattern)-1;
1628  *q=c;
1629  (void) ConcatenateMagickString(filename,r+1,MaxTextExtent);
1630  canonical=MagickTrue;
1631  if (*(q-1) != '%')
1632  break;
1633  p++;
1634  break;
1635  }
1636  default:
1637  break;
1638  }
1639  }
1640  for (q=filename; *q != '\0'; q++)
1641  if ((*q == '%') && (*(q+1) == '%'))
1642  {
1643  (void) CopyMagickString(q,q+1,(size_t) (MaxTextExtent-(q-filename)));
1644  canonical=MagickTrue;
1645  }
1646  if (canonical == MagickFalse)
1647  (void) CopyMagickString(filename,format,MaxTextExtent);
1648  return(strlen(filename));
1649 }
1650 
1651 /*
1652 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1653 % %
1654 % %
1655 % %
1656 % I s H i g h D y n a m i c R a n g e I m a g e %
1657 % %
1658 % %
1659 % %
1660 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1661 %
1662 % IsHighDynamicRangeImage() returns MagickTrue if any pixel component is
1663 % non-integer or exceeds the bounds of the quantum depth (e.g. for Q16
1664 % 0..65535.
1665 %
1666 % The format of the IsHighDynamicRangeImage method is:
1667 %
1668 % MagickBooleanType IsHighDynamicRangeImage(const Image *image,
1669 % ExceptionInfo *exception)
1670 %
1671 % A description of each parameter follows:
1672 %
1673 % o image: the image.
1674 %
1675 % o exception: return any errors or warnings in this structure.
1676 %
1677 */
1680 {
1681 #if !defined(MAGICKCORE_HDRI_SUPPORT)
1682  (void) image;
1683  (void) exception;
1684  return(MagickFalse);
1685 #else
1686  CacheView
1687  *image_view;
1688 
1690  status;
1691 
1693  zero;
1694 
1695  ssize_t
1696  y;
1697 
1698  assert(image != (Image *) NULL);
1699  assert(image->signature == MagickSignature);
1700  if (image->debug != MagickFalse)
1701  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1702  status=MagickTrue;
1703  GetMagickPixelPacket(image,&zero);
1704  image_view=AcquireVirtualCacheView(image,exception);
1705 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1706  #pragma omp parallel for schedule(static,4) shared(status) \
1707  magick_threads(image,image,image->rows,1)
1708 #endif
1709  for (y=0; y < (ssize_t) image->rows; y++)
1710  {
1712  pixel;
1713 
1714  register const IndexPacket
1715  *indexes;
1716 
1717  register const PixelPacket
1718  *p;
1719 
1720  register ssize_t
1721  x;
1722 
1723  if (status == MagickFalse)
1724  continue;
1725  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
1726  if (p == (const PixelPacket *) NULL)
1727  {
1728  status=MagickFalse;
1729  continue;
1730  }
1731  indexes=GetCacheViewVirtualIndexQueue(image_view);
1732  pixel=zero;
1733  for (x=0; x < (ssize_t) image->columns; x++)
1734  {
1735  SetMagickPixelPacket(image,p,indexes+x,&pixel);
1736  if ((pixel.red < 0.0) || (pixel.red > QuantumRange) ||
1737  (pixel.red != (QuantumAny) pixel.red))
1738  break;
1739  if ((pixel.green < 0.0) || (pixel.green > QuantumRange) ||
1740  (pixel.green != (QuantumAny) pixel.green))
1741  break;
1742  if ((pixel.blue < 0.0) || (pixel.blue > QuantumRange) ||
1743  (pixel.blue != (QuantumAny) pixel.blue))
1744  break;
1745  if (pixel.matte != MagickFalse)
1746  {
1747  if ((pixel.opacity < 0.0) || (pixel.opacity > QuantumRange) ||
1748  (pixel.opacity != (QuantumAny) pixel.opacity))
1749  break;
1750  }
1751  if (pixel.colorspace == CMYKColorspace)
1752  {
1753  if ((pixel.index < 0.0) || (pixel.index > QuantumRange) ||
1754  (pixel.index != (QuantumAny) pixel.index))
1755  break;
1756  }
1757  p++;
1758  }
1759  if (x < (ssize_t) image->columns)
1760  status=MagickFalse;
1761  }
1762  image_view=DestroyCacheView(image_view);
1763  return(status != MagickFalse ? MagickFalse : MagickTrue);
1764 #endif
1765 }
1766 
1767 /*
1768 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1769 % %
1770 % %
1771 % %
1772 % I s I m a g e O b j e c t %
1773 % %
1774 % %
1775 % %
1776 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1777 %
1778 % IsImageObject() returns MagickTrue if the image sequence contains a valid
1779 % set of image objects.
1780 %
1781 % The format of the IsImageObject method is:
1782 %
1783 % MagickBooleanType IsImageObject(const Image *image)
1784 %
1785 % A description of each parameter follows:
1786 %
1787 % o image: the image.
1788 %
1789 */
1791 {
1792  register const Image
1793  *p;
1794 
1795  assert(image != (Image *) NULL);
1796  if (image->debug != MagickFalse)
1797  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1798  for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1799  if (p->signature != MagickSignature)
1800  return(MagickFalse);
1801  return(MagickTrue);
1802 }
1803 
1804 /*
1805 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1806 % %
1807 % %
1808 % %
1809 % I s T a i n t I m a g e %
1810 % %
1811 % %
1812 % %
1813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1814 %
1815 % IsTaintImage() returns MagickTrue any pixel in the image has been altered
1816 % since it was first constituted.
1817 %
1818 % The format of the IsTaintImage method is:
1819 %
1820 % MagickBooleanType IsTaintImage(const Image *image)
1821 %
1822 % A description of each parameter follows:
1823 %
1824 % o image: the image.
1825 %
1826 */
1828 {
1829  char
1830  magick[MaxTextExtent],
1831  filename[MaxTextExtent];
1832 
1833  register const Image
1834  *p;
1835 
1836  assert(image != (Image *) NULL);
1837  if (image->debug != MagickFalse)
1838  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1839  assert(image->signature == MagickSignature);
1840  (void) CopyMagickString(magick,image->magick,MaxTextExtent);
1841  (void) CopyMagickString(filename,image->filename,MaxTextExtent);
1842  for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1843  {
1844  if (p->taint != MagickFalse)
1845  return(MagickTrue);
1846  if (LocaleCompare(p->magick,magick) != 0)
1847  return(MagickTrue);
1848  if (LocaleCompare(p->filename,filename) != 0)
1849  return(MagickTrue);
1850  }
1851  return(MagickFalse);
1852 }
1853 
1854 /*
1855 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1856 % %
1857 % %
1858 % %
1859 % M o d i f y I m a g e %
1860 % %
1861 % %
1862 % %
1863 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1864 %
1865 % ModifyImage() ensures that there is only a single reference to the image
1866 % to be modified, updating the provided image pointer to point to a clone of
1867 % the original image if necessary.
1868 %
1869 % The format of the ModifyImage method is:
1870 %
1871 % MagickBooleanType ModifyImage(Image *image,ExceptionInfo *exception)
1872 %
1873 % A description of each parameter follows:
1874 %
1875 % o image: the image.
1876 %
1877 % o exception: return any errors or warnings in this structure.
1878 %
1879 */
1882 {
1883  Image
1884  *clone_image;
1885 
1886  assert(image != (Image **) NULL);
1887  assert(*image != (Image *) NULL);
1888  assert((*image)->signature == MagickSignature);
1889  if ((*image)->debug != MagickFalse)
1890  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1891  if (GetImageReferenceCount(*image) <= 1)
1892  return(MagickTrue);
1893  clone_image=CloneImage(*image,0,0,MagickTrue,exception);
1894  LockSemaphoreInfo((*image)->semaphore);
1895  (*image)->reference_count--;
1896  UnlockSemaphoreInfo((*image)->semaphore);
1897  *image=clone_image;
1898  return(MagickTrue);
1899 }
1900 
1901 /*
1902 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1903 % %
1904 % %
1905 % %
1906 % N e w M a g i c k I m a g e %
1907 % %
1908 % %
1909 % %
1910 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1911 %
1912 % NewMagickImage() creates a blank image canvas of the specified size and
1913 % background color.
1914 %
1915 % The format of the NewMagickImage method is:
1916 %
1917 % Image *NewMagickImage(const ImageInfo *image_info,const size_t width,
1918 % const size_t height,const MagickPixelPacket *background)
1919 %
1920 % A description of each parameter follows:
1921 %
1922 % o image: the image.
1923 %
1924 % o width: the image width.
1925 %
1926 % o height: the image height.
1927 %
1928 % o background: the image color.
1929 %
1930 */
1932  const size_t width,const size_t height,const MagickPixelPacket *background)
1933 {
1934  CacheView
1935  *image_view;
1936 
1938  *exception;
1939 
1940  Image
1941  *image;
1942 
1943  ssize_t
1944  y;
1945 
1947  status;
1948 
1949  assert(image_info != (const ImageInfo *) NULL);
1950  if (image_info->debug != MagickFalse)
1951  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1952  assert(image_info->signature == MagickSignature);
1953  assert(background != (const MagickPixelPacket *) NULL);
1954  image=AcquireImage(image_info);
1955  image->columns=width;
1956  image->rows=height;
1957  image->colorspace=background->colorspace;
1958  image->matte=background->matte;
1959  image->fuzz=background->fuzz;
1960  image->depth=background->depth;
1961  status=MagickTrue;
1962  exception=(&image->exception);
1963  image_view=AcquireAuthenticCacheView(image,exception);
1964 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1965  #pragma omp parallel for schedule(static,4) shared(status) \
1966  magick_threads(image,image,image->rows,1)
1967 #endif
1968  for (y=0; y < (ssize_t) image->rows; y++)
1969  {
1970  register IndexPacket
1971  *restrict indexes;
1972 
1973  register PixelPacket
1974  *restrict q;
1975 
1976  register ssize_t
1977  x;
1978 
1979  if (status == MagickFalse)
1980  continue;
1981  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
1982  if (q == (PixelPacket *) NULL)
1983  {
1984  status=MagickFalse;
1985  continue;
1986  }
1987  indexes=GetCacheViewAuthenticIndexQueue(image_view);
1988  for (x=0; x < (ssize_t) image->columns; x++)
1989  {
1990  SetPixelPacket(image,background,q,indexes+x);
1991  q++;
1992  }
1993  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
1994  status=MagickFalse;
1995  }
1996  image_view=DestroyCacheView(image_view);
1997  if (status == MagickFalse)
1998  image=DestroyImage(image);
1999  return(image);
2000 }
2001 
2002 /*
2003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2004 % %
2005 % %
2006 % %
2007 % R e f e r e n c e I m a g e %
2008 % %
2009 % %
2010 % %
2011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2012 %
2013 % ReferenceImage() increments the reference count associated with an image
2014 % returning a pointer to the image.
2015 %
2016 % The format of the ReferenceImage method is:
2017 %
2018 % Image *ReferenceImage(Image *image)
2019 %
2020 % A description of each parameter follows:
2021 %
2022 % o image: the image.
2023 %
2024 */
2026 {
2027  assert(image != (Image *) NULL);
2028  if (image->debug != MagickFalse)
2029  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2030  assert(image->signature == MagickSignature);
2031  LockSemaphoreInfo(image->semaphore);
2032  image->reference_count++;
2034  return(image);
2035 }
2036 
2037 /*
2038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2039 % %
2040 % %
2041 % %
2042 % R e s e t I m a g e P a g e %
2043 % %
2044 % %
2045 % %
2046 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2047 %
2048 % ResetImagePage() resets the image page canvas and position.
2049 %
2050 % The format of the ResetImagePage method is:
2051 %
2052 % MagickBooleanType ResetImagePage(Image *image,const char *page)
2053 %
2054 % A description of each parameter follows:
2055 %
2056 % o image: the image.
2057 %
2058 % o page: the relative page specification.
2059 %
2060 */
2062 {
2064  flags;
2065 
2067  geometry;
2068 
2069  assert(image != (Image *) NULL);
2070  assert(image->signature == MagickSignature);
2071  if (image->debug != MagickFalse)
2072  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2073  flags=ParseAbsoluteGeometry(page,&geometry);
2074  if ((flags & WidthValue) != 0)
2075  {
2076  if ((flags & HeightValue) == 0)
2077  geometry.height=geometry.width;
2078  image->page.width=geometry.width;
2079  image->page.height=geometry.height;
2080  }
2081  if ((flags & AspectValue) != 0)
2082  {
2083  if ((flags & XValue) != 0)
2084  image->page.x+=geometry.x;
2085  if ((flags & YValue) != 0)
2086  image->page.y+=geometry.y;
2087  }
2088  else
2089  {
2090  if ((flags & XValue) != 0)
2091  {
2092  image->page.x=geometry.x;
2093  if ((image->page.width == 0) && (geometry.x > 0))
2094  image->page.width=image->columns+geometry.x;
2095  }
2096  if ((flags & YValue) != 0)
2097  {
2098  image->page.y=geometry.y;
2099  if ((image->page.height == 0) && (geometry.y > 0))
2100  image->page.height=image->rows+geometry.y;
2101  }
2102  }
2103  return(MagickTrue);
2104 }
2105 
2106 /*
2107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2108 % %
2109 % %
2110 % %
2111 % S e t I m a g e B a c k g r o u n d C o l o r %
2112 % %
2113 % %
2114 % %
2115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2116 %
2117 % SetImageBackgroundColor() initializes the image pixels to the image
2118 % background color. The background color is defined by the background_color
2119 % member of the image structure.
2120 %
2121 % The format of the SetImage method is:
2122 %
2123 % MagickBooleanType SetImageBackgroundColor(Image *image)
2124 %
2125 % A description of each parameter follows:
2126 %
2127 % o image: the image.
2128 %
2129 */
2131 {
2132  CacheView
2133  *image_view;
2134 
2136  *exception;
2137 
2138  IndexPacket
2139  index;
2140 
2142  status;
2143 
2145  background;
2146 
2147  PixelPacket
2148  pixel;
2149 
2150  ssize_t
2151  y;
2152 
2153  assert(image != (Image *) NULL);
2154  if (image->debug != MagickFalse)
2155  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2156  assert(image->signature == MagickSignature);
2158  return(MagickFalse);
2159  if ((IsPixelGray(&image->background_color) == MagickFalse) &&
2162  if ((image->background_color.opacity != OpaqueOpacity) &&
2163  (image->matte == MagickFalse))
2165  GetMagickPixelPacket(image,&background);
2166  SetMagickPixelPacket(image,&image->background_color,(const IndexPacket *)
2167  NULL,&background);
2168  if (image->colorspace == CMYKColorspace)
2169  ConvertRGBToCMYK(&background);
2170  index=0;
2171  SetPixelPacket(image,&background,&pixel,&index);
2172  /*
2173  Set image background color.
2174  */
2175  status=MagickTrue;
2176  exception=(&image->exception);
2177  image_view=AcquireAuthenticCacheView(image,exception);
2178  for (y=0; y < (ssize_t) image->rows; y++)
2179  {
2180  register PixelPacket
2181  *restrict q;
2182 
2183  register ssize_t
2184  x;
2185 
2186  if (status == MagickFalse)
2187  continue;
2188  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2189  if (q == (PixelPacket *) NULL)
2190  {
2191  status=MagickFalse;
2192  continue;
2193  }
2194  for (x=0; x < (ssize_t) image->columns; x++)
2195  *q++=pixel;
2196  if (image->colorspace == CMYKColorspace)
2197  {
2198  register IndexPacket
2199  *restrict indexes;
2200 
2201  indexes=GetCacheViewAuthenticIndexQueue(image_view);
2202  for (x=0; x < (ssize_t) image->columns; x++)
2203  SetPixelIndex(indexes+x,index);
2204  }
2205  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2206  status=MagickFalse;
2207  }
2208  image_view=DestroyCacheView(image_view);
2209  return(status);
2210 }
2211 
2212 /*
2213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2214 % %
2215 % %
2216 % %
2217 % S e t I m a g e C h a n n e l s %
2218 % %
2219 % %
2220 % %
2221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2222 %
2223 % SetImageChannels() sets the number of pixels channels associated with the
2224 % image.
2225 %
2226 % The format of the SetImageChannels method is:
2227 %
2228 % MagickBooleanType SetImageChannels(Image *image,const size_t channels)
2229 %
2230 % A description of each parameter follows:
2231 %
2232 % o image: the image.
2233 %
2234 % o channels: The number of pixel channels.
2235 %
2236 */
2238  const size_t channels)
2239 {
2240  image->channels=channels;
2241  return(MagickTrue);
2242 }
2243 
2244 /*
2245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2246 % %
2247 % %
2248 % %
2249 % S e t I m a g e C o l o r %
2250 % %
2251 % %
2252 % %
2253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2254 %
2255 % SetImageColor() set the entire image canvas to the specified color.
2256 %
2257 % The format of the SetImageColor method is:
2258 %
2259 % MagickBooleanType SetImageColor(Image *image,
2260 % const MagickPixelPacket *color)
2261 %
2262 % A description of each parameter follows:
2263 %
2264 % o image: the image.
2265 %
2266 % o background: the image color.
2267 %
2268 */
2270  const MagickPixelPacket *color)
2271 {
2272  CacheView
2273  *image_view;
2274 
2276  *exception;
2277 
2279  status;
2280 
2281  ssize_t
2282  y;
2283 
2284  assert(image != (Image *) NULL);
2285  if (image->debug != MagickFalse)
2286  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2287  assert(image->signature == MagickSignature);
2288  assert(color != (const MagickPixelPacket *) NULL);
2289  image->colorspace=color->colorspace;
2290  image->matte=color->matte;
2291  image->fuzz=color->fuzz;
2292  image->depth=color->depth;
2293  status=MagickTrue;
2294  exception=(&image->exception);
2295  image_view=AcquireAuthenticCacheView(image,exception);
2296 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2297  #pragma omp parallel for schedule(static,4) shared(status) \
2298  magick_threads(image,image,image->rows,1)
2299 #endif
2300  for (y=0; y < (ssize_t) image->rows; y++)
2301  {
2302  register IndexPacket
2303  *restrict indexes;
2304 
2305  register PixelPacket
2306  *restrict q;
2307 
2308  register ssize_t
2309  x;
2310 
2311  if (status == MagickFalse)
2312  continue;
2313  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2314  if (q == (PixelPacket *) NULL)
2315  {
2316  status=MagickFalse;
2317  continue;
2318  }
2319  indexes=GetCacheViewAuthenticIndexQueue(image_view);
2320  for (x=0; x < (ssize_t) image->columns; x++)
2321  {
2322  SetPixelPacket(image,color,q,indexes+x);
2323  q++;
2324  }
2325  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2326  status=MagickFalse;
2327  }
2328  image_view=DestroyCacheView(image_view);
2329  return(status);
2330 }
2331 
2332 /*
2333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2334 % %
2335 % %
2336 % %
2337 % S e t I m a g e S t o r a g e C l a s s %
2338 % %
2339 % %
2340 % %
2341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2342 %
2343 % SetImageStorageClass() sets the image class: DirectClass for true color
2344 % images or PseudoClass for colormapped images.
2345 %
2346 % The format of the SetImageStorageClass method is:
2347 %
2348 % MagickBooleanType SetImageStorageClass(Image *image,
2349 % const ClassType storage_class)
2350 %
2351 % A description of each parameter follows:
2352 %
2353 % o image: the image.
2354 %
2355 % o storage_class: The image class.
2356 %
2357 */
2359  const ClassType storage_class)
2360 {
2361  image->storage_class=storage_class;
2362  return(SyncImagePixelCache(image,&image->exception));
2363 }
2364 
2365 /*
2366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2367 % %
2368 % %
2369 % %
2370 % S e t I m a g e C l i p M a s k %
2371 % %
2372 % %
2373 % %
2374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2375 %
2376 % SetImageClipMask() associates a clip path with the image. The clip path
2377 % must be the same dimensions as the image. Set any pixel component of
2378 % the clip path to TransparentOpacity to prevent that corresponding image
2379 % pixel component from being updated when SyncAuthenticPixels() is applied.
2380 %
2381 % The format of the SetImageClipMask method is:
2382 %
2383 % MagickBooleanType SetImageClipMask(Image *image,const Image *clip_mask)
2384 %
2385 % A description of each parameter follows:
2386 %
2387 % o image: the image.
2388 %
2389 % o clip_mask: the image clip path.
2390 %
2391 */
2393  const Image *clip_mask)
2394 {
2395  assert(image != (Image *) NULL);
2396  if (image->debug != MagickFalse)
2397  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2398  assert(image->signature == MagickSignature);
2399  if (clip_mask != (const Image *) NULL)
2400  if ((clip_mask->columns != image->columns) ||
2401  (clip_mask->rows != image->rows))
2402  ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
2403  if (image->clip_mask != (Image *) NULL)
2404  image->clip_mask=DestroyImage(image->clip_mask);
2405  image->clip_mask=NewImageList();
2406  if (clip_mask == (Image *) NULL)
2407  return(MagickTrue);
2409  return(MagickFalse);
2410  image->clip_mask=CloneImage(clip_mask,0,0,MagickTrue,&image->exception);
2411  if (image->clip_mask == (Image *) NULL)
2412  return(MagickFalse);
2413  return(MagickTrue);
2414 }
2415 
2416 /*
2417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2418 % %
2419 % %
2420 % %
2421 % S e t I m a g e E x t e n t %
2422 % %
2423 % %
2424 % %
2425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2426 %
2427 % SetImageExtent() sets the image size (i.e. columns & rows).
2428 %
2429 % The format of the SetImageExtent method is:
2430 %
2431 % MagickBooleanType SetImageExtent(Image *image,
2432 % const size_t columns,const size_t rows)
2433 %
2434 % A description of each parameter follows:
2435 %
2436 % o image: the image.
2437 %
2438 % o columns: The image width in pixels.
2439 %
2440 % o rows: The image height in pixels.
2441 %
2442 */
2444  const size_t columns,const size_t rows)
2445 {
2446  if ((columns == 0) || (rows == 0))
2447  return(MagickFalse);
2448  image->columns=columns;
2449  image->rows=rows;
2450  return(SyncImagePixelCache(image,&image->exception));
2451 }
2452 
2453 /*
2454 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2455 % %
2456 % %
2457 % %
2458 + S e t I m a g e I n f o %
2459 % %
2460 % %
2461 % %
2462 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2463 %
2464 % SetImageInfo() initializes the `magick' field of the ImageInfo structure.
2465 % It is set to a type of image format based on the prefix or suffix of the
2466 % filename. For example, `ps:image' returns PS indicating a Postscript image.
2467 % JPEG is returned for this filename: `image.jpg'. The filename prefix has
2468 % precendence over the suffix. Use an optional index enclosed in brackets
2469 % after a file name to specify a desired scene of a multi-resolution image
2470 % format like Photo CD (e.g. img0001.pcd[4]). A True (non-zero) return value
2471 % indicates success.
2472 %
2473 % The format of the SetImageInfo method is:
2474 %
2475 % MagickBooleanType SetImageInfo(ImageInfo *image_info,
2476 % const unsigned int frames,ExceptionInfo *exception)
2477 %
2478 % A description of each parameter follows:
2479 %
2480 % o image_info: the image info.
2481 %
2482 % o frames: the number of images you intend to write.
2483 %
2484 % o exception: return any errors or warnings in this structure.
2485 %
2486 */
2488  const unsigned int frames,ExceptionInfo *exception)
2489 {
2490  char
2491  extension[MaxTextExtent],
2492  filename[MaxTextExtent],
2493  magic[MaxTextExtent],
2494  *q,
2495  subimage[MaxTextExtent];
2496 
2497  const MagicInfo
2498  *magic_info;
2499 
2500  const MagickInfo
2501  *magick_info;
2502 
2504  *sans_exception;
2505 
2506  Image
2507  *image;
2508 
2510  status;
2511 
2512  register const char
2513  *p;
2514 
2515  ssize_t
2516  count;
2517 
2518  unsigned char
2519  magick[2*MaxTextExtent];
2520 
2521  /*
2522  Look for 'image.format' in filename.
2523  */
2524  assert(image_info != (ImageInfo *) NULL);
2525  assert(image_info->signature == MagickSignature);
2526  if (image_info->debug != MagickFalse)
2528  image_info->filename);
2529  *subimage='\0';
2530  GetPathComponent(image_info->filename,SubimagePath,subimage);
2531  if (*subimage != '\0')
2532  {
2533  /*
2534  Look for scene specification (e.g. img0001.pcd[4]).
2535  */
2536  if (IsSceneGeometry(subimage,MagickFalse) == MagickFalse)
2537  {
2538  if (IsGeometry(subimage) != MagickFalse)
2539  (void) CloneString(&image_info->extract,subimage);
2540  }
2541  else
2542  {
2543  size_t
2544  first,
2545  last;
2546 
2547  (void) CloneString(&image_info->scenes,subimage);
2548  image_info->scene=StringToUnsignedLong(image_info->scenes);
2549  image_info->number_scenes=image_info->scene;
2550  p=image_info->scenes;
2551  for (q=(char *) image_info->scenes; *q != '\0'; p++)
2552  {
2553  while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
2554  p++;
2555  first=(size_t) strtol(p,&q,10);
2556  last=first;
2557  while (isspace((int) ((unsigned char) *q)) != 0)
2558  q++;
2559  if (*q == '-')
2560  last=(size_t) strtol(q+1,&q,10);
2561  if (first > last)
2562  Swap(first,last);
2563  if (first < image_info->scene)
2564  image_info->scene=first;
2565  if (last > image_info->number_scenes)
2566  image_info->number_scenes=last;
2567  p=q;
2568  }
2569  image_info->number_scenes-=image_info->scene-1;
2570  image_info->subimage=image_info->scene;
2571  image_info->subrange=image_info->number_scenes;
2572  }
2573  }
2574  *extension='\0';
2575  GetPathComponent(image_info->filename,ExtensionPath,extension);
2576 #if defined(MAGICKCORE_ZLIB_DELEGATE)
2577  if (*extension != '\0')
2578  if ((LocaleCompare(extension,"gz") == 0) ||
2579  (LocaleCompare(extension,"Z") == 0) ||
2580  (LocaleCompare(extension,"svgz") == 0) ||
2581  (LocaleCompare(extension,"wmz") == 0))
2582  {
2583  char
2584  path[MaxTextExtent];
2585 
2586  (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
2587  path[strlen(path)-strlen(extension)-1]='\0';
2588  GetPathComponent(path,ExtensionPath,extension);
2589  }
2590 #endif
2591 #if defined(MAGICKCORE_BZLIB_DELEGATE)
2592  if (*extension != '\0')
2593  if (LocaleCompare(extension,"bz2") == 0)
2594  {
2595  char
2596  path[MaxTextExtent];
2597 
2598  (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
2599  path[strlen(path)-strlen(extension)-1]='\0';
2600  GetPathComponent(path,ExtensionPath,extension);
2601  }
2602 #endif
2603  image_info->affirm=MagickFalse;
2604  sans_exception=AcquireExceptionInfo();
2605  if (*extension != '\0')
2606  {
2608  format_type;
2609 
2610  register ssize_t
2611  i;
2612 
2613  static const char
2614  *format_type_formats[] =
2615  {
2616  "AUTOTRACE",
2617  "BROWSE",
2618  "DCRAW",
2619  "EDIT",
2620  "EPHEMERAL",
2621  "LAUNCH",
2622  "MPEG:DECODE",
2623  "MPEG:ENCODE",
2624  "PRINT",
2625  "PS:ALPHA",
2626  "PS:CMYK",
2627  "PS:COLOR",
2628  "PS:GRAY",
2629  "PS:MONO",
2630  "SCAN",
2631  "SHOW",
2632  "WIN",
2633  (char *) NULL
2634  };
2635 
2636  /*
2637  User specified image format.
2638  */
2639  (void) CopyMagickString(magic,extension,MaxTextExtent);
2640  LocaleUpper(magic);
2641  /*
2642  Look for explicit image formats.
2643  */
2644  format_type=UndefinedFormatType;
2645  i=0;
2646  while ((format_type == UndefinedFormatType) &&
2647  (format_type_formats[i] != (char *) NULL))
2648  {
2649  if ((*magic == *format_type_formats[i]) &&
2650  (LocaleCompare(magic,format_type_formats[i]) == 0))
2651  format_type=ExplicitFormatType;
2652  i++;
2653  }
2654  magick_info=GetMagickInfo(magic,sans_exception);
2655  if ((magick_info != (const MagickInfo *) NULL) &&
2656  (magick_info->format_type != UndefinedFormatType))
2657  format_type=magick_info->format_type;
2658  if (format_type == UndefinedFormatType)
2659  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2660  else
2661  if (format_type == ExplicitFormatType)
2662  {
2663  image_info->affirm=MagickTrue;
2664  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2665  }
2666  if (LocaleCompare(magic,"RGB") == 0)
2667  image_info->affirm=MagickFalse; /* maybe SGI disguised as RGB */
2668  }
2669  /*
2670  Look for explicit 'format:image' in filename.
2671  */
2672  *magic='\0';
2673  GetPathComponent(image_info->filename,MagickPath,magic);
2674  if (*magic == '\0')
2675  (void) CopyMagickString(magic,image_info->magick,MaxTextExtent);
2676  else
2677  {
2678  /*
2679  User specified image format.
2680  */
2681  LocaleUpper(magic);
2682  if (IsMagickConflict(magic) == MagickFalse)
2683  {
2684  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2685  if (LocaleCompare(magic,"EPHEMERAL") != 0)
2686  image_info->affirm=MagickTrue;
2687  else
2688  image_info->temporary=MagickTrue;
2689  }
2690  }
2691  magick_info=GetMagickInfo(magic,sans_exception);
2692  sans_exception=DestroyExceptionInfo(sans_exception);
2693  if ((magick_info == (const MagickInfo *) NULL) ||
2694  (GetMagickEndianSupport(magick_info) == MagickFalse))
2695  image_info->endian=UndefinedEndian;
2696  GetPathComponent(image_info->filename,CanonicalPath,filename);
2697  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2698  if ((image_info->adjoin != MagickFalse) && (frames > 1))
2699  {
2700  /*
2701  Test for multiple image support (e.g. image%02d.png).
2702  */
2703  (void) InterpretImageFilename(image_info,(Image *) NULL,
2704  image_info->filename,(int) image_info->scene,filename);
2705  if ((LocaleCompare(filename,image_info->filename) != 0) &&
2706  (strchr(filename,'%') == (char *) NULL))
2707  image_info->adjoin=MagickFalse;
2708  }
2709  if ((image_info->adjoin != MagickFalse) && (frames > 0))
2710  {
2711  /*
2712  Some image formats do not support multiple frames per file.
2713  */
2714  magick_info=GetMagickInfo(magic,exception);
2715  if (magick_info != (const MagickInfo *) NULL)
2716  if (GetMagickAdjoin(magick_info) == MagickFalse)
2717  image_info->adjoin=MagickFalse;
2718  }
2719  if (image_info->affirm != MagickFalse)
2720  return(MagickTrue);
2721  if (frames == 0)
2722  {
2723  /*
2724  Determine the image format from the first few bytes of the file.
2725  */
2726  image=AcquireImage(image_info);
2727  (void) CopyMagickString(image->filename,image_info->filename,
2728  MaxTextExtent);
2729  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2730  if (status == MagickFalse)
2731  {
2732  image=DestroyImage(image);
2733  return(MagickFalse);
2734  }
2735  if ((IsBlobSeekable(image) == MagickFalse) ||
2736  (IsBlobExempt(image) != MagickFalse))
2737  {
2738  /*
2739  Copy standard input or pipe to temporary file.
2740  */
2741  *filename='\0';
2742  status=ImageToFile(image,filename,exception);
2743  (void) CloseBlob(image);
2744  if (status == MagickFalse)
2745  {
2746  image=DestroyImage(image);
2747  return(MagickFalse);
2748  }
2749  SetImageInfoFile(image_info,(FILE *) NULL);
2750  (void) CopyMagickString(image->filename,filename,MaxTextExtent);
2751  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2752  if (status == MagickFalse)
2753  {
2754  image=DestroyImage(image);
2755  return(MagickFalse);
2756  }
2757  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2758  image_info->temporary=MagickTrue;
2759  }
2760  (void) ResetMagickMemory(magick,0,sizeof(magick));
2761  count=ReadBlob(image,2*MaxTextExtent,magick);
2762  (void) SeekBlob(image,-((MagickOffsetType) count),SEEK_CUR);
2763  (void) CloseBlob(image);
2764  image=DestroyImage(image);
2765  /*
2766  Check magic.xml configuration file.
2767  */
2768  sans_exception=AcquireExceptionInfo();
2769  magic_info=GetMagicInfo(magick,(size_t) count,sans_exception);
2770  if ((magic_info != (const MagicInfo *) NULL) &&
2771  (GetMagicName(magic_info) != (char *) NULL))
2772  {
2773  (void) CopyMagickString(image_info->magick,GetMagicName(magic_info),
2774  MaxTextExtent);
2775  magick_info=GetMagickInfo(image_info->magick,sans_exception);
2776  if ((magick_info == (const MagickInfo *) NULL) ||
2777  (GetMagickEndianSupport(magick_info) == MagickFalse))
2778  image_info->endian=UndefinedEndian;
2779  sans_exception=DestroyExceptionInfo(sans_exception);
2780  return(MagickTrue);
2781  }
2782  magick_info=GetMagickInfo(image_info->magick,sans_exception);
2783  if ((magick_info == (const MagickInfo *) NULL) ||
2784  (GetMagickEndianSupport(magick_info) == MagickFalse))
2785  image_info->endian=UndefinedEndian;
2786  sans_exception=DestroyExceptionInfo(sans_exception);
2787  }
2788  return(MagickTrue);
2789 }
2790 
2791 /*
2792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2793 % %
2794 % %
2795 % %
2796 % S e t I m a g e I n f o B l o b %
2797 % %
2798 % %
2799 % %
2800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2801 %
2802 % SetImageInfoBlob() sets the image info blob member.
2803 %
2804 % The format of the SetImageInfoBlob method is:
2805 %
2806 % void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
2807 % const size_t length)
2808 %
2809 % A description of each parameter follows:
2810 %
2811 % o image_info: the image info.
2812 %
2813 % o blob: the blob.
2814 %
2815 % o length: the blob length.
2816 %
2817 */
2818 MagickExport void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
2819  const size_t length)
2820 {
2821  assert(image_info != (ImageInfo *) NULL);
2822  assert(image_info->signature == MagickSignature);
2823  if (image_info->debug != MagickFalse)
2825  image_info->filename);
2826  image_info->blob=(void *) blob;
2827  image_info->length=length;
2828 }
2829 
2830 /*
2831 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2832 % %
2833 % %
2834 % %
2835 % S e t I m a g e I n f o F i l e %
2836 % %
2837 % %
2838 % %
2839 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2840 %
2841 % SetImageInfoFile() sets the image info file member.
2842 %
2843 % The format of the SetImageInfoFile method is:
2844 %
2845 % void SetImageInfoFile(ImageInfo *image_info,FILE *file)
2846 %
2847 % A description of each parameter follows:
2848 %
2849 % o image_info: the image info.
2850 %
2851 % o file: the file.
2852 %
2853 */
2854 MagickExport void SetImageInfoFile(ImageInfo *image_info,FILE *file)
2855 {
2856  assert(image_info != (ImageInfo *) NULL);
2857  assert(image_info->signature == MagickSignature);
2858  if (image_info->debug != MagickFalse)
2860  image_info->filename);
2861  image_info->file=file;
2862 }
2863 
2864 /*
2865 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2866 % %
2867 % %
2868 % %
2869 % S e t I m a g e M a s k %
2870 % %
2871 % %
2872 % %
2873 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2874 %
2875 % SetImageMask() associates a mask with the image. The mask must be the same
2876 % dimensions as the image.
2877 %
2878 % The format of the SetImageMask method is:
2879 %
2880 % MagickBooleanType SetImageMask(Image *image,const Image *mask)
2881 %
2882 % A description of each parameter follows:
2883 %
2884 % o image: the image.
2885 %
2886 % o mask: the image mask.
2887 %
2888 */
2890 {
2891  assert(image != (Image *) NULL);
2892  if (image->debug != MagickFalse)
2893  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2894  assert(image->signature == MagickSignature);
2895  if (mask != (const Image *) NULL)
2896  if ((mask->columns != image->columns) || (mask->rows != image->rows))
2897  ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
2898  if (image->mask != (Image *) NULL)
2899  image->mask=DestroyImage(image->mask);
2900  image->mask=NewImageList();
2901  if (mask == (Image *) NULL)
2902  return(MagickTrue);
2904  return(MagickFalse);
2905  image->mask=CloneImage(mask,0,0,MagickTrue,&image->exception);
2906  if (image->mask == (Image *) NULL)
2907  return(MagickFalse);
2908  return(MagickTrue);
2909 }
2910 
2911 /*
2912 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2913 % %
2914 % %
2915 % %
2916 % S e t I m a g e O p a c i t y %
2917 % %
2918 % %
2919 % %
2920 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2921 %
2922 % SetImageOpacity() sets the opacity levels of the image.
2923 %
2924 % The format of the SetImageOpacity method is:
2925 %
2926 % MagickBooleanType SetImageOpacity(Image *image,const Quantum opacity)
2927 %
2928 % A description of each parameter follows:
2929 %
2930 % o image: the image.
2931 %
2932 % o opacity: the level of transparency: 0 is fully opaque and QuantumRange is
2933 % fully transparent.
2934 %
2935 */
2937  const Quantum opacity)
2938 {
2939  CacheView
2940  *image_view;
2941 
2943  *exception;
2944 
2946  status;
2947 
2948  ssize_t
2949  y;
2950 
2951  assert(image != (Image *) NULL);
2952  if (image->debug != MagickFalse)
2953  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2954  assert(image->signature == MagickSignature);
2955  image->matte=MagickTrue;
2956  status=MagickTrue;
2957  exception=(&image->exception);
2958  image_view=AcquireAuthenticCacheView(image,exception);
2959 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2960  #pragma omp parallel for schedule(static,4) shared(status) \
2961  magick_threads(image,image,image->rows,1)
2962 #endif
2963  for (y=0; y < (ssize_t) image->rows; y++)
2964  {
2965  register PixelPacket
2966  *restrict q;
2967 
2968  register ssize_t
2969  x;
2970 
2971  if (status == MagickFalse)
2972  continue;
2973  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2974  if (q == (PixelPacket *) NULL)
2975  {
2976  status=MagickFalse;
2977  continue;
2978  }
2979  for (x=0; x < (ssize_t) image->columns; x++)
2980  {
2981  SetPixelOpacity(q,opacity);
2982  q++;
2983  }
2984  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2985  status=MagickFalse;
2986  }
2987  image_view=DestroyCacheView(image_view);
2988  return(status);
2989 }
2990 
2991 /*
2992 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2993 % %
2994 % %
2995 % %
2996 % 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 %
2997 % %
2998 % %
2999 % %
3000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3001 %
3002 % SetImageVirtualPixelMethod() sets the "virtual pixels" method for the
3003 % image and returns the previous setting. A virtual pixel is any pixel access
3004 % that is outside the boundaries of the image cache.
3005 %
3006 % The format of the SetImageVirtualPixelMethod() method is:
3007 %
3008 % VirtualPixelMethod SetImageVirtualPixelMethod(const Image *image,
3009 % const VirtualPixelMethod virtual_pixel_method)
3010 %
3011 % A description of each parameter follows:
3012 %
3013 % o image: the image.
3014 %
3015 % o virtual_pixel_method: choose the type of virtual pixel.
3016 %
3017 */
3019  const VirtualPixelMethod virtual_pixel_method)
3020 {
3021  assert(image != (const Image *) NULL);
3022  assert(image->signature == MagickSignature);
3023  if (image->debug != MagickFalse)
3024  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3025  return(SetPixelCacheVirtualMethod(image,virtual_pixel_method));
3026 }
3027 
3028 /*
3029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3030 % %
3031 % %
3032 % %
3033 % S m u s h I m a g e s %
3034 % %
3035 % %
3036 % %
3037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3038 %
3039 % SmushImages() takes all images from the current image pointer to the end
3040 % of the image list and smushes them to each other top-to-bottom if the
3041 % stack parameter is true, otherwise left-to-right.
3042 %
3043 % The current gravity setting now effects how the image is justified in the
3044 % final image.
3045 %
3046 % The format of the SmushImages method is:
3047 %
3048 % Image *SmushImages(const Image *images,const MagickBooleanType stack,
3049 % ExceptionInfo *exception)
3050 %
3051 % A description of each parameter follows:
3052 %
3053 % o images: the image sequence.
3054 %
3055 % o stack: A value other than 0 stacks the images top-to-bottom.
3056 %
3057 % o offset: minimum distance in pixels between images.
3058 %
3059 % o exception: return any errors or warnings in this structure.
3060 %
3061 */
3062 
3063 static ssize_t SmushXGap(const Image *smush_image,const Image *images,
3064  const ssize_t offset,ExceptionInfo *exception)
3065 {
3066  CacheView
3067  *left_view,
3068  *right_view;
3069 
3070  const Image
3071  *left_image,
3072  *right_image;
3073 
3075  left_geometry,
3076  right_geometry;
3077 
3078  register const PixelPacket
3079  *p;
3080 
3081  register ssize_t
3082  i,
3083  y;
3084 
3085  size_t
3086  gap;
3087 
3088  ssize_t
3089  x;
3090 
3091  if (images->previous == (Image *) NULL)
3092  return(0);
3093  right_image=images;
3094  SetGeometry(smush_image,&right_geometry);
3095  GravityAdjustGeometry(right_image->columns,right_image->rows,
3096  right_image->gravity,&right_geometry);
3097  left_image=images->previous;
3098  SetGeometry(smush_image,&left_geometry);
3099  GravityAdjustGeometry(left_image->columns,left_image->rows,
3100  left_image->gravity,&left_geometry);
3101  gap=right_image->columns;
3102  left_view=AcquireVirtualCacheView(left_image,exception);
3103  right_view=AcquireVirtualCacheView(right_image,exception);
3104  for (y=0; y < (ssize_t) smush_image->rows; y++)
3105  {
3106  for (x=(ssize_t) left_image->columns-1; x > 0; x--)
3107  {
3108  p=GetCacheViewVirtualPixels(left_view,x,left_geometry.y+y,1,1,exception);
3109  if ((p == (const PixelPacket *) NULL) ||
3111  ((left_image->columns-x-1) >= gap))
3112  break;
3113  }
3114  i=(ssize_t) left_image->columns-x-1;
3115  for (x=0; x < (ssize_t) right_image->columns; x++)
3116  {
3117  p=GetCacheViewVirtualPixels(right_view,x,right_geometry.y+y,1,1,
3118  exception);
3119  if ((p == (const PixelPacket *) NULL) ||
3121  ((x+i) >= (ssize_t) gap))
3122  break;
3123  }
3124  if ((x+i) < (ssize_t) gap)
3125  gap=(size_t) (x+i);
3126  }
3127  right_view=DestroyCacheView(right_view);
3128  left_view=DestroyCacheView(left_view);
3129  if (y < (ssize_t) smush_image->rows)
3130  return(offset);
3131  return((ssize_t) gap-offset);
3132 }
3133 
3134 static ssize_t SmushYGap(const Image *smush_image,const Image *images,
3135  const ssize_t offset,ExceptionInfo *exception)
3136 {
3137  CacheView
3138  *bottom_view,
3139  *top_view;
3140 
3141  const Image
3142  *bottom_image,
3143  *top_image;
3144 
3146  bottom_geometry,
3147  top_geometry;
3148 
3149  register const PixelPacket
3150  *p;
3151 
3152  register ssize_t
3153  i,
3154  x;
3155 
3156  size_t
3157  gap;
3158 
3159  ssize_t
3160  y;
3161 
3162  if (images->previous == (Image *) NULL)
3163  return(0);
3164  bottom_image=images;
3165  SetGeometry(smush_image,&bottom_geometry);
3166  GravityAdjustGeometry(bottom_image->columns,bottom_image->rows,
3167  bottom_image->gravity,&bottom_geometry);
3168  top_image=images->previous;
3169  SetGeometry(smush_image,&top_geometry);
3170  GravityAdjustGeometry(top_image->columns,top_image->rows,top_image->gravity,
3171  &top_geometry);
3172  gap=bottom_image->rows;
3173  top_view=AcquireVirtualCacheView(top_image,exception);
3174  bottom_view=AcquireVirtualCacheView(bottom_image,exception);
3175  for (x=0; x < (ssize_t) smush_image->columns; x++)
3176  {
3177  for (y=(ssize_t) top_image->rows-1; y > 0; y--)
3178  {
3179  p=GetCacheViewVirtualPixels(top_view,top_geometry.x+x,y,1,1,exception);
3180  if ((p == (const PixelPacket *) NULL) ||
3182  ((top_image->rows-y-1) >= gap))
3183  break;
3184  }
3185  i=(ssize_t) top_image->rows-y-1;
3186  for (y=0; y < (ssize_t) bottom_image->rows; y++)
3187  {
3188  p=GetCacheViewVirtualPixels(bottom_view,bottom_geometry.x+x,y,1,1,
3189  exception);
3190  if ((p == (const PixelPacket *) NULL) ||
3192  ((y+i) >= (ssize_t) gap))
3193  break;
3194  }
3195  if ((y+i) < (ssize_t) gap)
3196  gap=(size_t) (y+i);
3197  }
3198  bottom_view=DestroyCacheView(bottom_view);
3199  top_view=DestroyCacheView(top_view);
3200  if (x < (ssize_t) smush_image->columns)
3201  return(offset);
3202  return((ssize_t) gap-offset);
3203 }
3204 
3206  const MagickBooleanType stack,const ssize_t offset,ExceptionInfo *exception)
3207 {
3208 #define SmushImageTag "Smush/Image"
3209 
3210  CacheView
3211  *smush_view;
3212 
3213  const Image
3214  *image;
3215 
3216  Image
3217  *smush_image;
3218 
3220  matte,
3221  proceed,
3222  status;
3223 
3225  n;
3226 
3228  geometry;
3229 
3230  register const Image
3231  *next;
3232 
3233  size_t
3234  height,
3235  number_images,
3236  width;
3237 
3238  ssize_t
3239  x_offset,
3240  y_offset;
3241 
3242  /*
3243  Compute maximum area of smushed area.
3244  */
3245  assert(images != (Image *) NULL);
3246  assert(images->signature == MagickSignature);
3247  if (images->debug != MagickFalse)
3248  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3249  assert(exception != (ExceptionInfo *) NULL);
3250  assert(exception->signature == MagickSignature);
3251  image=images;
3252  matte=image->matte;
3253  number_images=1;
3254  width=image->columns;
3255  height=image->rows;
3256  next=GetNextImageInList(image);
3257  for ( ; next != (Image *) NULL; next=GetNextImageInList(next))
3258  {
3259  if (next->matte != MagickFalse)
3260  matte=MagickTrue;
3261  number_images++;
3262  if (stack != MagickFalse)
3263  {
3264  if (next->columns > width)
3265  width=next->columns;
3266  height+=next->rows;
3267  if (next->previous != (Image *) NULL)
3268  height+=offset;
3269  continue;
3270  }
3271  width+=next->columns;
3272  if (next->previous != (Image *) NULL)
3273  width+=offset;
3274  if (next->rows > height)
3275  height=next->rows;
3276  }
3277  /*
3278  Smush images.
3279  */
3280  smush_image=CloneImage(image,width,height,MagickTrue,exception);
3281  if (smush_image == (Image *) NULL)
3282  return((Image *) NULL);
3283  if (SetImageStorageClass(smush_image,DirectClass) == MagickFalse)
3284  {
3285  InheritException(exception,&smush_image->exception);
3286  smush_image=DestroyImage(smush_image);
3287  return((Image *) NULL);
3288  }
3289  smush_image->matte=matte;
3290  (void) SetImageBackgroundColor(smush_image);
3291  status=MagickTrue;
3292  x_offset=0;
3293  y_offset=0;
3294  smush_view=AcquireVirtualCacheView(smush_image,exception);
3295  for (n=0; n < (MagickOffsetType) number_images; n++)
3296  {
3297  SetGeometry(smush_image,&geometry);
3298  GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
3299  if (stack != MagickFalse)
3300  {
3301  x_offset-=geometry.x;
3302  y_offset-=SmushYGap(smush_image,image,offset,exception);
3303  }
3304  else
3305  {
3306  x_offset-=SmushXGap(smush_image,image,offset,exception);
3307  y_offset-=geometry.y;
3308  }
3309  status=CompositeImage(smush_image,OverCompositeOp,image,x_offset,y_offset);
3310  proceed=SetImageProgress(image,SmushImageTag,n,number_images);
3311  if (proceed == MagickFalse)
3312  break;
3313  if (stack == MagickFalse)
3314  {
3315  x_offset+=(ssize_t) image->columns;
3316  y_offset=0;
3317  }
3318  else
3319  {
3320  x_offset=0;
3321  y_offset+=(ssize_t) image->rows;
3322  }
3323  image=GetNextImageInList(image);
3324  }
3325  if (stack == MagickFalse)
3326  smush_image->columns=(size_t) x_offset;
3327  else
3328  smush_image->rows=(size_t) y_offset;
3329  smush_view=DestroyCacheView(smush_view);
3330  if (status == MagickFalse)
3331  smush_image=DestroyImage(smush_image);
3332  return(smush_image);
3333 }
3334 
3335 /*
3336 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3337 % %
3338 % %
3339 % %
3340 % S t r i p I m a g e %
3341 % %
3342 % %
3343 % %
3344 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3345 %
3346 % StripImage() strips an image of all profiles and comments.
3347 %
3348 % The format of the StripImage method is:
3349 %
3350 % MagickBooleanType StripImage(Image *image)
3351 %
3352 % A description of each parameter follows:
3353 %
3354 % o image: the image.
3355 %
3356 */
3358 {
3360  status;
3361 
3362  assert(image != (Image *) NULL);
3363  if (image->debug != MagickFalse)
3364  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3365  DestroyImageProfiles(image);
3366  (void) DeleteImageProperty(image,"comment");
3367  (void) DeleteImageProperty(image,"date:create");
3368  (void) DeleteImageProperty(image,"date:modify");
3369  status=SetImageArtifact(image,"png:exclude-chunk",
3370  "EXIF,iCCP,iTXt,sRGB,tEXt,zCCP,zTXt,date");
3371  return(status);
3372 }
3373 
3374 /*
3375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3376 % %
3377 % %
3378 % %
3379 + S y n c I m a g e %
3380 % %
3381 % %
3382 % %
3383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3384 %
3385 % SyncImage() initializes the red, green, and blue intensities of each pixel
3386 % as defined by the colormap index.
3387 %
3388 % The format of the SyncImage method is:
3389 %
3390 % MagickBooleanType SyncImage(Image *image)
3391 %
3392 % A description of each parameter follows:
3393 %
3394 % o image: the image.
3395 %
3396 */
3397 
3398 static inline IndexPacket PushColormapIndex(Image *image,
3399  const size_t index,MagickBooleanType *range_exception)
3400 {
3401  if (index < image->colors)
3402  return((IndexPacket) index);
3403  *range_exception=MagickTrue;
3404  return((IndexPacket) 0);
3405 }
3406 
3408 {
3409  CacheView
3410  *image_view;
3411 
3413  *exception;
3414 
3416  range_exception,
3417  status;
3418 
3419  ssize_t
3420  y;
3421 
3422  assert(image != (Image *) NULL);
3423  if (image->debug != MagickFalse)
3424  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3425  assert(image->signature == MagickSignature);
3426  if (image->storage_class == DirectClass)
3427  return(MagickFalse);
3428  range_exception=MagickFalse;
3429  status=MagickTrue;
3430  exception=(&image->exception);
3431  image_view=AcquireAuthenticCacheView(image,exception);
3432 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3433  #pragma omp parallel for schedule(static,4) shared(range_exception,status) \
3434  magick_threads(image,image,image->rows,1)
3435 #endif
3436  for (y=0; y < (ssize_t) image->rows; y++)
3437  {
3438  IndexPacket
3439  index;
3440 
3441  register IndexPacket
3442  *restrict indexes;
3443 
3444  register PixelPacket
3445  *restrict q;
3446 
3447  register ssize_t
3448  x;
3449 
3450  if (status == MagickFalse)
3451  continue;
3452  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3453  if (q == (PixelPacket *) NULL)
3454  {
3455  status=MagickFalse;
3456  continue;
3457  }
3458  indexes=GetCacheViewAuthenticIndexQueue(image_view);
3459  for (x=0; x < (ssize_t) image->columns; x++)
3460  {
3461  index=PushColormapIndex(image,(size_t) GetPixelIndex(indexes+x),
3462  &range_exception);
3463  if (image->matte == MagickFalse)
3464  SetPixelRgb(q,image->colormap+(ssize_t) index)
3465  else
3466  SetPixelRGBO(q,image->colormap+(ssize_t) index);
3467  q++;
3468  }
3469  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3470  status=MagickFalse;
3471  }
3472  image_view=DestroyCacheView(image_view);
3473  if ((image->ping == MagickFalse) && (range_exception != MagickFalse))
3475  CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
3476  return(status);
3477 }
3478 
3479 /*
3480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3481 % %
3482 % %
3483 % %
3484 % S y n c I m a g e S e t t i n g s %
3485 % %
3486 % %
3487 % %
3488 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3489 %
3490 % SyncImageSettings() syncs image_info options into per-image attributes.
3491 %
3492 % The format of the SyncImageSettings method is:
3493 %
3494 % MagickBooleanType SyncImageSettings(const ImageInfo *image_info,
3495 % Image *image)
3496 % MagickBooleanType SyncImagesSettings(const ImageInfo *image_info,
3497 % Image *image)
3498 %
3499 % A description of each parameter follows:
3500 %
3501 % o image_info: the image info.
3502 %
3503 % o image: the image.
3504 %
3505 */
3506 
3508  Image *images)
3509 {
3510  Image
3511  *image;
3512 
3513  assert(image_info != (const ImageInfo *) NULL);
3514  assert(image_info->signature == MagickSignature);
3515  assert(images != (Image *) NULL);
3516  assert(images->signature == MagickSignature);
3517  if (images->debug != MagickFalse)
3518  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3519  image=images;
3520  for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
3521  (void) SyncImageSettings(image_info,image);
3522  (void) DeleteImageOption(image_info,"page");
3523  return(MagickTrue);
3524 }
3525 
3527  Image *image)
3528 {
3529  char
3530  property[MaxTextExtent];
3531 
3532  const char
3533  *option,
3534  *value;
3535 
3536  GeometryInfo
3537  geometry_info;
3538 
3540  flags;
3541 
3543  units;
3544 
3545  /*
3546  Sync image options.
3547  */
3548  assert(image_info != (const ImageInfo *) NULL);
3549  assert(image_info->signature == MagickSignature);
3550  assert(image != (Image *) NULL);
3551  assert(image->signature == MagickSignature);
3552  if (image->debug != MagickFalse)
3553  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3554  option=GetImageOption(image_info,"background");
3555  if (option != (const char *) NULL)
3556  (void) QueryColorDatabase(option,&image->background_color,
3557  &image->exception);
3558  option=GetImageOption(image_info,"bias");
3559  if (option != (const char *) NULL)
3560  image->bias=StringToDoubleInterval(option,(double) QuantumRange+1.0);
3561  option=GetImageOption(image_info,"black-point-compensation");
3562  if (option != (const char *) NULL)
3565  option=GetImageOption(image_info,"blue-primary");
3566  if (option != (const char *) NULL)
3567  {
3568  flags=ParseGeometry(option,&geometry_info);
3569  image->chromaticity.blue_primary.x=geometry_info.rho;
3570  image->chromaticity.blue_primary.y=geometry_info.sigma;
3571  if ((flags & SigmaValue) == 0)
3573  }
3574  option=GetImageOption(image_info,"bordercolor");
3575  if (option != (const char *) NULL)
3576  (void) QueryColorDatabase(option,&image->border_color,&image->exception);
3577  option=GetImageOption(image_info,"colors");
3578  if (option != (const char *) NULL)
3579  image->colors=StringToUnsignedLong(option);
3580  option=GetImageOption(image_info,"compose");
3581  if (option != (const char *) NULL)
3583  MagickFalse,option);
3584  option=GetImageOption(image_info,"compress");
3585  if (option != (const char *) NULL)
3588  option=GetImageOption(image_info,"debug");
3589  if (option != (const char *) NULL)
3591  MagickFalse,option);
3592  option=GetImageOption(image_info,"density");
3593  if (option != (const char *) NULL)
3594  {
3595  GeometryInfo
3596  geometry_info;
3597 
3598  /*
3599  Set image density.
3600  */
3601  flags=ParseGeometry(option,&geometry_info);
3602  image->x_resolution=geometry_info.rho;
3603  image->y_resolution=geometry_info.sigma;
3604  if ((flags & SigmaValue) == 0)
3605  image->y_resolution=image->x_resolution;
3606  }
3607  option=GetImageOption(image_info,"depth");
3608  if (option != (const char *) NULL)
3609  image->depth=StringToUnsignedLong(option);
3610  option=GetImageOption(image_info,"endian");
3611  if (option != (const char *) NULL)
3613  MagickFalse,option);
3614  option=GetImageOption(image_info,"filter");
3615  if (option != (const char *) NULL)
3617  MagickFalse,option);
3618  option=GetImageOption(image_info,"fuzz");
3619  if (option != (const char *) NULL)
3620  image->fuzz=StringToDoubleInterval(option,(double) QuantumRange+1.0);
3621  option=GetImageOption(image_info,"gravity");
3622  if (option != (const char *) NULL)
3624  MagickFalse,option);
3625  option=GetImageOption(image_info,"green-primary");
3626  if (option != (const char *) NULL)
3627  {
3628  flags=ParseGeometry(option,&geometry_info);
3629  image->chromaticity.green_primary.x=geometry_info.rho;
3630  image->chromaticity.green_primary.y=geometry_info.sigma;
3631  if ((flags & SigmaValue) == 0)
3633  }
3634  option=GetImageOption(image_info,"intensity");
3635  if (option != (const char *) NULL)
3638  option=GetImageOption(image_info,"intent");
3639  if (option != (const char *) NULL)
3642  option=GetImageOption(image_info,"interlace");
3643  if (option != (const char *) NULL)
3645  MagickFalse,option);
3646  option=GetImageOption(image_info,"interpolate");
3647  if (option != (const char *) NULL)
3650  option=GetImageOption(image_info,"loop");
3651  if (option != (const char *) NULL)
3652  image->iterations=StringToUnsignedLong(option);
3653  option=GetImageOption(image_info,"mattecolor");
3654  if (option != (const char *) NULL)
3655  (void) QueryColorDatabase(option,&image->matte_color,&image->exception);
3656  option=GetImageOption(image_info,"orient");
3657  if (option != (const char *) NULL)
3660  option=GetImageOption(image_info,"page");
3661  if (option != (const char *) NULL)
3662  {
3663  char
3664  *geometry;
3665 
3666  geometry=GetPageGeometry(option);
3667  flags=ParseAbsoluteGeometry(geometry,&image->page);
3668  geometry=DestroyString(geometry);
3669  }
3670  option=GetImageOption(image_info,"quality");
3671  if (option != (const char *) NULL)
3672  image->quality=StringToUnsignedLong(option);
3673  option=GetImageOption(image_info,"red-primary");
3674  if (option != (const char *) NULL)
3675  {
3676  flags=ParseGeometry(option,&geometry_info);
3677  image->chromaticity.red_primary.x=geometry_info.rho;
3678  image->chromaticity.red_primary.y=geometry_info.sigma;
3679  if ((flags & SigmaValue) == 0)
3681  }
3682  if (image_info->quality != UndefinedCompressionQuality)
3683  image->quality=image_info->quality;
3684  option=GetImageOption(image_info,"scene");
3685  if (option != (const char *) NULL)
3686  image->scene=StringToUnsignedLong(option);
3687  option=GetImageOption(image_info,"taint");
3688  if (option != (const char *) NULL)
3690  MagickFalse,option);
3691  option=GetImageOption(image_info,"tile-offset");
3692  if (option != (const char *) NULL)
3693  {
3694  char
3695  *geometry;
3696 
3697  geometry=GetPageGeometry(option);
3698  flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3699  geometry=DestroyString(geometry);
3700  }
3701  option=GetImageOption(image_info,"transparent-color");
3702  if (option != (const char *) NULL)
3703  (void) QueryColorDatabase(option,&image->transparent_color,
3704  &image->exception);
3705  option=GetImageOption(image_info,"type");
3706  if (option != (const char *) NULL)
3708  option);
3709  option=GetImageOption(image_info,"units");
3710  if (option != (const char *) NULL)
3712  MagickFalse,option);
3713  else
3714  units = image_info->units;
3715  if (units != UndefinedResolution)
3716  {
3717  if (image->units != units)
3718  switch (image->units)
3719  {
3721  {
3722  if (units == PixelsPerCentimeterResolution)
3723  {
3724  image->x_resolution/=2.54;
3725  image->y_resolution/=2.54;
3726  }
3727  break;
3728  }
3730  {
3731  if (units == PixelsPerInchResolution)
3732  {
3733  image->x_resolution=(double) ((size_t) (100.0*2.54*
3734  image->x_resolution+0.5))/100.0;
3735  image->y_resolution=(double) ((size_t) (100.0*2.54*
3736  image->y_resolution+0.5))/100.0;
3737  }
3738  break;
3739  }
3740  default:
3741  break;
3742  }
3743  image->units=units;
3744  }
3745  option=GetImageOption(image_info,"white-point");
3746  if (option != (const char *) NULL)
3747  {
3748  flags=ParseGeometry(option,&geometry_info);
3749  image->chromaticity.white_point.x=geometry_info.rho;
3750  image->chromaticity.white_point.y=geometry_info.sigma;
3751  if ((flags & SigmaValue) == 0)
3753  }
3754  ResetImageOptionIterator(image_info);
3755  for (option=GetNextImageOption(image_info); option != (const char *) NULL; )
3756  {
3757  value=GetImageOption(image_info,option);
3758  if (value != (const char *) NULL)
3759  {
3760  (void) FormatLocaleString(property,MaxTextExtent,"%s",option);
3761  (void) SetImageArtifact(image,property,value);
3762  }
3763  option=GetNextImageOption(image_info);
3764  }
3765  return(MagickTrue);
3766 }
size_t rows
Definition: image.h:172
MagickExport FILE * GetImageInfoFile(const ImageInfo *image_info)
Definition: image.c:1335
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:1931
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:2025
MagickExport MagickBooleanType DeleteImageOption(ImageInfo *image_info, const char *option)
Definition: option.c:1795
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:2495
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:3507
#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:3018
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:3526
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:2130
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:2358
static MagickBooleanType IsGrayColorspace(const ColorspaceType colorspace)
MagickExport void SetImageInfoBlob(ImageInfo *image_info, const void *blob, const size_t length)
Definition: image.c:2818
ResolutionType units
Definition: image.h:196
MagickExport MagickBooleanType SetImageChannels(Image *image, const size_t channels)
Definition: image.c:2237
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:1685
MagickExport MagickBooleanType SyncImage(Image *image)
Definition: image.c:3407
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:1830
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:2854
Definition: image.h:150
void * cache
Definition: image.h:449
MagickExport VirtualPixelMethod GetImageVirtualPixelMethod(const Image *image)
Definition: image.c:1466
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:3398
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:129
#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:1195
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:3063
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:3357
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:2053
const char PSPageGeometry[]
Definition: image.c:116
MagickBooleanType black_point_compensation
Definition: image.h:316
MagickExport MagickBooleanType IsImageObject(const Image *image)
Definition: image.c:1790
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:306
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:3767
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:1866
MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info, const unsigned int frames, ExceptionInfo *exception)
Definition: image.c:2487
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:1508
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:3205
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:2676
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
RectangleInfo extract_info
Definition: image.h:211
MagickExport MagickBooleanType ResetImagePage(Image *image, const char *page)
Definition: image.c:2061
MagickExport MagickBooleanType GetMagickEndianSupport(const MagickInfo *magick_info)
Definition: magick.c:367
MagickExport MagickBooleanType IsBlobSeekable(const Image *image)
Definition: blob.c:2125
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:2443
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:1827
MagickExport MagickBooleanType CloneImageOptions(ImageInfo *image_info, const ImageInfo *clone_info)
Definition: option.c:1702
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:1362
MagickExport MagickBooleanType QueryColorDatabase(const char *name, PixelPacket *color, ExceptionInfo *exception)
Definition: color.c:2443
MagickExport size_t GetImageChannels(Image *image)
Definition: image.c:1396
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:270
MagickExport MagickBooleanType ModifyImage(Image **image, ExceptionInfo *exception)
Definition: image.c:1880
MagickExport MagickBooleanType IsBlobExempt(const Image *image)
Definition: blob.c:2094
MagickPrivate void DisassociateBlob(Image *)
Definition: blob.c:735
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:1275
MagickExport MagickBooleanType SetImageOpacity(Image *image, const Quantum opacity)
Definition: image.c:2936
MagickExport MagickBooleanType IsHighDynamicRangeImage(const Image *image, ExceptionInfo *exception)
Definition: image.c:1678
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:951
MagickExport void GetImageException(Image *image, ExceptionInfo *exception)
Definition: image.c:1232
MagickExport const char * GetMagickProperty(const ImageInfo *image_info, Image *image, const char *property)
Definition: property.c:2680
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:3605
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:3134
Quantum IndexPacket
Definition: pixel.h:129
MagickExport MagickBooleanType SetImageColor(Image *image, const MagickPixelPacket *color)
Definition: image.c:2269
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:2392
#define AppendImageTag
#define SetPixelBlue(pixel, value)
MagickExport char * GetNextImageOption(const ImageInfo *image_info)
Definition: option.c:2129
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:2889
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:1427
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:1164
#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