MagickCore  6.9.1
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-2015 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  if ((image->columns == 0) || (image->rows == 0))
805  {
807  "NegativeOrZeroImageSize","`%s'",image->filename);
808  return((Image *) NULL);
809  }
810  clone_image=(Image *) AcquireMagickMemory(sizeof(*clone_image));
811  if (clone_image == (Image *) NULL)
812  ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
813  (void) ResetMagickMemory(clone_image,0,sizeof(*clone_image));
814  clone_image->signature=MagickSignature;
815  clone_image->storage_class=image->storage_class;
816  clone_image->channels=image->channels;
817  clone_image->colorspace=image->colorspace;
818  clone_image->matte=image->matte;
819  clone_image->columns=image->columns;
820  clone_image->rows=image->rows;
821  clone_image->dither=image->dither;
822  if (image->colormap != (PixelPacket *) NULL)
823  {
824  /*
825  Allocate and copy the image colormap.
826  */
827  clone_image->colors=image->colors;
828  length=(size_t) image->colors;
829  clone_image->colormap=(PixelPacket *) AcquireQuantumMemory(length,
830  sizeof(*clone_image->colormap));
831  if (clone_image->colormap == (PixelPacket *) NULL)
832  ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
833  (void) CopyMagickMemory(clone_image->colormap,image->colormap,length*
834  sizeof(*clone_image->colormap));
835  }
836  (void) CloneImageProfiles(clone_image,image);
837  (void) CloneImageProperties(clone_image,image);
838  (void) CloneImageArtifacts(clone_image,image);
839  GetTimerInfo(&clone_image->timer);
840  InitializeExceptionInfo(&clone_image->exception);
841  InheritException(&clone_image->exception,&image->exception);
842  if (image->ascii85 != (void *) NULL)
843  Ascii85Initialize(clone_image);
844  clone_image->magick_columns=image->magick_columns;
845  clone_image->magick_rows=image->magick_rows;
846  clone_image->type=image->type;
847  (void) CopyMagickString(clone_image->magick_filename,image->magick_filename,
848  MaxTextExtent);
849  (void) CopyMagickString(clone_image->magick,image->magick,MaxTextExtent);
850  (void) CopyMagickString(clone_image->filename,image->filename,MaxTextExtent);
851  clone_image->progress_monitor=image->progress_monitor;
852  clone_image->client_data=image->client_data;
853  clone_image->reference_count=1;
854  clone_image->next=image->next;
855  clone_image->previous=image->previous;
856  clone_image->list=NewImageList();
857  clone_image->clip_mask=NewImageList();
858  clone_image->mask=NewImageList();
859  if (detach == MagickFalse)
860  clone_image->blob=ReferenceBlob(image->blob);
861  else
862  {
863  clone_image->next=NewImageList();
864  clone_image->previous=NewImageList();
865  clone_image->blob=CloneBlobInfo((BlobInfo *) NULL);
866  }
867  clone_image->ping=image->ping;
868  clone_image->debug=IsEventLogging();
869  clone_image->semaphore=AllocateSemaphoreInfo();
870  if ((columns == 0) || (rows == 0))
871  {
872  if (image->montage != (char *) NULL)
873  (void) CloneString(&clone_image->montage,image->montage);
874  if (image->directory != (char *) NULL)
875  (void) CloneString(&clone_image->directory,image->directory);
876  if (image->clip_mask != (Image *) NULL)
877  clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
878  exception);
879  if (image->mask != (Image *) NULL)
880  clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
881  clone_image->cache=ReferencePixelCache(image->cache);
882  return(clone_image);
883  }
884  if ((columns == image->columns) && (rows == image->rows))
885  {
886  if (image->clip_mask != (Image *) NULL)
887  clone_image->clip_mask=CloneImage(image->clip_mask,0,0,MagickTrue,
888  exception);
889  if (image->mask != (Image *) NULL)
890  clone_image->mask=CloneImage(image->mask,0,0,MagickTrue,exception);
891  }
892  scale=1.0;
893  if (image->columns != 0)
894  scale=(double) columns/(double) image->columns;
895  clone_image->page.width=(size_t) floor(scale*image->page.width+0.5);
896  clone_image->page.x=(ssize_t) ceil(scale*image->page.x-0.5);
897  clone_image->tile_offset.x=(ssize_t) ceil(scale*image->tile_offset.x-0.5);
898  scale=1.0;
899  if (image->rows != 0)
900  scale=(double) rows/(double) image->rows;
901  clone_image->page.height=(size_t) floor(scale*image->page.height+0.5);
902  clone_image->page.y=(ssize_t) ceil(scale*image->page.y-0.5);
903  clone_image->tile_offset.y=(ssize_t) ceil(scale*image->tile_offset.y-0.5);
904  clone_image->columns=columns;
905  clone_image->rows=rows;
906  clone_image->cache=ClonePixelCache(image->cache);
907  return(clone_image);
908 }
909 
910 /*
911 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
912 % %
913 % %
914 % %
915 % C l o n e I m a g e I n f o %
916 % %
917 % %
918 % %
919 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
920 %
921 % CloneImageInfo() makes a copy of the given image info structure. If
922 % NULL is specified, a new image info structure is created initialized to
923 % default values.
924 %
925 % The format of the CloneImageInfo method is:
926 %
927 % ImageInfo *CloneImageInfo(const ImageInfo *image_info)
928 %
929 % A description of each parameter follows:
930 %
931 % o image_info: the image info.
932 %
933 */
935 {
936  ImageInfo
937  *clone_info;
938 
939  clone_info=AcquireImageInfo();
940  if (image_info == (ImageInfo *) NULL)
941  return(clone_info);
942  clone_info->compression=image_info->compression;
943  clone_info->temporary=image_info->temporary;
944  clone_info->adjoin=image_info->adjoin;
945  clone_info->antialias=image_info->antialias;
946  clone_info->scene=image_info->scene;
947  clone_info->number_scenes=image_info->number_scenes;
948  clone_info->depth=image_info->depth;
949  (void) CloneString(&clone_info->size,image_info->size);
950  (void) CloneString(&clone_info->extract,image_info->extract);
951  (void) CloneString(&clone_info->scenes,image_info->scenes);
952  (void) CloneString(&clone_info->page,image_info->page);
953  clone_info->interlace=image_info->interlace;
954  clone_info->endian=image_info->endian;
955  clone_info->units=image_info->units;
956  clone_info->quality=image_info->quality;
957  (void) CloneString(&clone_info->sampling_factor,image_info->sampling_factor);
958  (void) CloneString(&clone_info->server_name,image_info->server_name);
959  (void) CloneString(&clone_info->font,image_info->font);
960  (void) CloneString(&clone_info->texture,image_info->texture);
961  (void) CloneString(&clone_info->density,image_info->density);
962  clone_info->pointsize=image_info->pointsize;
963  clone_info->fuzz=image_info->fuzz;
964  clone_info->pen=image_info->pen;
965  clone_info->background_color=image_info->background_color;
966  clone_info->border_color=image_info->border_color;
967  clone_info->matte_color=image_info->matte_color;
968  clone_info->transparent_color=image_info->transparent_color;
969  clone_info->dither=image_info->dither;
970  clone_info->monochrome=image_info->monochrome;
971  clone_info->colors=image_info->colors;
972  clone_info->colorspace=image_info->colorspace;
973  clone_info->type=image_info->type;
974  clone_info->orientation=image_info->orientation;
975  clone_info->preview_type=image_info->preview_type;
976  clone_info->group=image_info->group;
977  clone_info->ping=image_info->ping;
978  clone_info->verbose=image_info->verbose;
979  (void) CloneString(&clone_info->view,image_info->view);
980  (void) CloneString(&clone_info->authenticate,image_info->authenticate);
981  (void) CloneImageOptions(clone_info,image_info);
982  clone_info->progress_monitor=image_info->progress_monitor;
983  clone_info->client_data=image_info->client_data;
984  clone_info->cache=image_info->cache;
985  if (image_info->cache != (void *) NULL)
986  clone_info->cache=ReferencePixelCache(image_info->cache);
987  if (image_info->profile != (void *) NULL)
988  clone_info->profile=(void *) CloneStringInfo((StringInfo *)
989  image_info->profile);
990  SetImageInfoFile(clone_info,image_info->file);
991  SetImageInfoBlob(clone_info,image_info->blob,image_info->length);
992  clone_info->stream=image_info->stream;
993  clone_info->virtual_pixel_method=image_info->virtual_pixel_method;
994  (void) CopyMagickString(clone_info->magick,image_info->magick,MaxTextExtent);
995  (void) CopyMagickString(clone_info->unique,image_info->unique,MaxTextExtent);
996  (void) CopyMagickString(clone_info->zero,image_info->zero,MaxTextExtent);
997  (void) CopyMagickString(clone_info->filename,image_info->filename,
998  MaxTextExtent);
999  clone_info->subimage=image_info->scene; /* deprecated */
1000  clone_info->subrange=image_info->number_scenes; /* deprecated */
1001  clone_info->channel=image_info->channel;
1002  clone_info->debug=IsEventLogging();
1003  clone_info->signature=image_info->signature;
1004  return(clone_info);
1005 }
1006 
1007 /*
1008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1009 % %
1010 % %
1011 % %
1012 % D e s t r o y I m a g e %
1013 % %
1014 % %
1015 % %
1016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1017 %
1018 % DestroyImage() dereferences an image, deallocating memory associated with
1019 % the image if the reference count becomes zero.
1020 %
1021 % The format of the DestroyImage method is:
1022 %
1023 % Image *DestroyImage(Image *image)
1024 %
1025 % A description of each parameter follows:
1026 %
1027 % o image: the image.
1028 %
1029 */
1031 {
1033  destroy;
1034 
1035  /*
1036  Dereference image.
1037  */
1038  assert(image != (Image *) NULL);
1039  assert(image->signature == MagickSignature);
1040  if (image->debug != MagickFalse)
1041  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1042  destroy=MagickFalse;
1043  LockSemaphoreInfo(image->semaphore);
1044  image->reference_count--;
1045  if (image->reference_count == 0)
1046  destroy=MagickTrue;
1048  if (destroy == MagickFalse)
1049  return((Image *) NULL);
1050  /*
1051  Destroy image.
1052  */
1053  DestroyImagePixels(image);
1054  if (image->clip_mask != (Image *) NULL)
1055  image->clip_mask=DestroyImage(image->clip_mask);
1056  if (image->mask != (Image *) NULL)
1057  image->mask=DestroyImage(image->mask);
1058  if (image->montage != (char *) NULL)
1059  image->montage=DestroyString(image->montage);
1060  if (image->directory != (char *) NULL)
1061  image->directory=DestroyString(image->directory);
1062  if (image->colormap != (PixelPacket *) NULL)
1064  if (image->geometry != (char *) NULL)
1065  image->geometry=DestroyString(image->geometry);
1066  DestroyImageProfiles(image);
1067  DestroyImageProperties(image);
1068  DestroyImageArtifacts(image);
1069  if (image->ascii85 != (Ascii85Info*) NULL)
1071  DestroyBlob(image);
1072  (void) ClearExceptionInfo(&image->exception,MagickTrue);
1073  if (image->semaphore != (SemaphoreInfo *) NULL)
1075  image->signature=(~MagickSignature);
1076  image=(Image *) RelinquishMagickMemory(image);
1077  return(image);
1078 }
1079 
1080 /*
1081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1082 % %
1083 % %
1084 % %
1085 % D e s t r o y I m a g e I n f o %
1086 % %
1087 % %
1088 % %
1089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1090 %
1091 % DestroyImageInfo() deallocates memory associated with an ImageInfo
1092 % structure.
1093 %
1094 % The format of the DestroyImageInfo method is:
1095 %
1096 % ImageInfo *DestroyImageInfo(ImageInfo *image_info)
1097 %
1098 % A description of each parameter follows:
1099 %
1100 % o image_info: the image info.
1101 %
1102 */
1104 {
1105  assert(image_info != (ImageInfo *) NULL);
1106  assert(image_info->signature == MagickSignature);
1107  if (image_info->debug != MagickFalse)
1109  image_info->filename);
1110  if (image_info->size != (char *) NULL)
1111  image_info->size=DestroyString(image_info->size);
1112  if (image_info->extract != (char *) NULL)
1113  image_info->extract=DestroyString(image_info->extract);
1114  if (image_info->scenes != (char *) NULL)
1115  image_info->scenes=DestroyString(image_info->scenes);
1116  if (image_info->page != (char *) NULL)
1117  image_info->page=DestroyString(image_info->page);
1118  if (image_info->sampling_factor != (char *) NULL)
1119  image_info->sampling_factor=DestroyString(
1120  image_info->sampling_factor);
1121  if (image_info->server_name != (char *) NULL)
1122  image_info->server_name=DestroyString(
1123  image_info->server_name);
1124  if (image_info->font != (char *) NULL)
1125  image_info->font=DestroyString(image_info->font);
1126  if (image_info->texture != (char *) NULL)
1127  image_info->texture=DestroyString(image_info->texture);
1128  if (image_info->density != (char *) NULL)
1129  image_info->density=DestroyString(image_info->density);
1130  if (image_info->view != (char *) NULL)
1131  image_info->view=DestroyString(image_info->view);
1132  if (image_info->authenticate != (char *) NULL)
1133  image_info->authenticate=DestroyString(
1134  image_info->authenticate);
1135  DestroyImageOptions(image_info);
1136  if (image_info->cache != (void *) NULL)
1137  image_info->cache=DestroyPixelCache(image_info->cache);
1138  if (image_info->profile != (StringInfo *) NULL)
1139  image_info->profile=(void *) DestroyStringInfo((StringInfo *)
1140  image_info->profile);
1141  image_info->signature=(~MagickSignature);
1142  image_info=(ImageInfo *) RelinquishMagickMemory(image_info);
1143  return(image_info);
1144 }
1145 
1146 /*
1147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1148 % %
1149 % %
1150 % %
1151 + D i s a s s o c i a t e I m a g e S t r e a m %
1152 % %
1153 % %
1154 % %
1155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1156 %
1157 % DisassociateImageStream() disassociates the image stream. It checks if the
1158 % blob of the specified image is referenced by other images. If the reference
1159 % count is higher then 1 a new blob is assigned to the specified image.
1160 %
1161 % The format of the DisassociateImageStream method is:
1162 %
1163 % void DisassociateImageStream(const Image *image)
1164 %
1165 % A description of each parameter follows:
1166 %
1167 % o image: the image.
1168 %
1169 */
1171 {
1172  assert(image != (Image *) NULL);
1173  assert(image->signature == MagickSignature);
1174  if (image->debug != MagickFalse)
1175  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1176  DisassociateBlob(image);
1177 }
1178 
1179 /*
1180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1181 % %
1182 % %
1183 % %
1184 % G e t I m a g e C l i p M a s k %
1185 % %
1186 % %
1187 % %
1188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1189 %
1190 % GetImageClipMask() returns the clip path associated with the image.
1191 %
1192 % The format of the GetImageClipMask method is:
1193 %
1194 % Image *GetImageClipMask(const Image *image,ExceptionInfo *exception)
1195 %
1196 % A description of each parameter follows:
1197 %
1198 % o image: the image.
1199 %
1200 */
1203 {
1204  assert(image != (const Image *) NULL);
1205  if (image->debug != MagickFalse)
1206  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1207  assert(image->signature == MagickSignature);
1208  if (image->clip_mask == (Image *) NULL)
1209  return((Image *) NULL);
1210  return(CloneImage(image->clip_mask,0,0,MagickTrue,exception));
1211 }
1212 
1213 /*
1214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1215 % %
1216 % %
1217 % %
1218 % G e t I m a g e E x c e p t i o n %
1219 % %
1220 % %
1221 % %
1222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1223 %
1224 % GetImageException() traverses an image sequence and returns any
1225 % error more severe than noted by the exception parameter.
1226 %
1227 % The format of the GetImageException method is:
1228 %
1229 % void GetImageException(Image *image,ExceptionInfo *exception)
1230 %
1231 % A description of each parameter follows:
1232 %
1233 % o image: Specifies a pointer to a list of one or more images.
1234 %
1235 % o exception: return the highest severity exception.
1236 %
1237 */
1239 {
1240  register Image
1241  *next;
1242 
1243  assert(image != (Image *) NULL);
1244  assert(image->signature == MagickSignature);
1245  if (image->debug != MagickFalse)
1246  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1247  assert(exception != (ExceptionInfo *) NULL);
1248  assert(exception->signature == MagickSignature);
1249  for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
1250  {
1251  if (next->exception.severity == UndefinedException)
1252  continue;
1253  if (next->exception.severity > exception->severity)
1254  InheritException(exception,&next->exception);
1256  }
1257 }
1258 
1259 /*
1260 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1261 % %
1262 % %
1263 % %
1264 % G e t I m a g e I n f o %
1265 % %
1266 % %
1267 % %
1268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1269 %
1270 % GetImageInfo() initializes image_info to default values.
1271 %
1272 % The format of the GetImageInfo method is:
1273 %
1274 % void GetImageInfo(ImageInfo *image_info)
1275 %
1276 % A description of each parameter follows:
1277 %
1278 % o image_info: the image info.
1279 %
1280 */
1282 {
1283  char
1284  *synchronize;
1285 
1287  *exception;
1288 
1289  /*
1290  File and image dimension members.
1291  */
1292  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1293  assert(image_info != (ImageInfo *) NULL);
1294  (void) ResetMagickMemory(image_info,0,sizeof(*image_info));
1295  image_info->adjoin=MagickTrue;
1296  image_info->interlace=NoInterlace;
1297  image_info->channel=DefaultChannels;
1299  image_info->antialias=MagickTrue;
1300  image_info->dither=MagickTrue;
1301  synchronize=GetEnvironmentValue("MAGICK_SYNCHRONIZE");
1302  if (synchronize != (const char *) NULL)
1303  {
1304  image_info->synchronize=IsStringTrue(synchronize);
1305  synchronize=DestroyString(synchronize);
1306  }
1307  exception=AcquireExceptionInfo();
1309  exception);
1310  (void) QueryColorDatabase(BorderColor,&image_info->border_color,exception);
1311  (void) QueryColorDatabase(MatteColor,&image_info->matte_color,exception);
1313  exception);
1314  exception=DestroyExceptionInfo(exception);
1315  image_info->debug=IsEventLogging();
1316  image_info->signature=MagickSignature;
1317 }
1318 
1319 /*
1320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1321 % %
1322 % %
1323 % %
1324 % G e t I m a g e I n f o F i l e %
1325 % %
1326 % %
1327 % %
1328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1329 %
1330 % GetImageInfoFile() returns the image info file member.
1331 %
1332 % The format of the GetImageInfoFile method is:
1333 %
1334 % FILE *GetImageInfoFile(const ImageInfo *image_info)
1335 %
1336 % A description of each parameter follows:
1337 %
1338 % o image_info: the image info.
1339 %
1340 */
1341 MagickExport FILE *GetImageInfoFile(const ImageInfo *image_info)
1342 {
1343  return(image_info->file);
1344 }
1345 
1346 /*
1347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1348 % %
1349 % %
1350 % %
1351 % G e t I m a g e M a s k %
1352 % %
1353 % %
1354 % %
1355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1356 %
1357 % GetImageMask() returns the mask associated with the image.
1358 %
1359 % The format of the GetImageMask method is:
1360 %
1361 % Image *GetImageMask(const Image *image,ExceptionInfo *exception)
1362 %
1363 % A description of each parameter follows:
1364 %
1365 % o image: the image.
1366 %
1367 */
1369 {
1370  assert(image != (const Image *) NULL);
1371  if (image->debug != MagickFalse)
1372  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1373  assert(image->signature == MagickSignature);
1374  if (image->mask == (Image *) NULL)
1375  return((Image *) NULL);
1376  return(CloneImage(image->mask,0,0,MagickTrue,exception));
1377 }
1378 
1379 /*
1380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1381 % %
1382 % %
1383 % %
1384 % G e t I m a g e C h a n n e l s %
1385 % %
1386 % %
1387 % %
1388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1389 %
1390 % GetImageChannels() returns the number of pixel channels associated with the
1391 % specified image.
1392 %
1393 % The format of the GetChannels method is:
1394 %
1395 % size_t GetImageChannels(Image *image)
1396 %
1397 % A description of each parameter follows:
1398 %
1399 % o image: the image.
1400 %
1401 */
1403 {
1404  assert(image != (Image *) NULL);
1405  assert(image->signature == MagickSignature);
1406  if (image->debug != MagickFalse)
1407  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1408  return(image->channels);
1409 }
1410 
1411 /*
1412 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1413 % %
1414 % %
1415 % %
1416 + G e t I m a g e R e f e r e n c e C o u n t %
1417 % %
1418 % %
1419 % %
1420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1421 %
1422 % GetImageReferenceCount() returns the image reference count.
1423 %
1424 % The format of the GetReferenceCount method is:
1425 %
1426 % ssize_t GetImageReferenceCount(Image *image)
1427 %
1428 % A description of each parameter follows:
1429 %
1430 % o image: the image.
1431 %
1432 */
1434 {
1435  ssize_t
1436  reference_count;
1437 
1438  assert(image != (Image *) NULL);
1439  assert(image->signature == MagickSignature);
1440  if (image->debug != MagickFalse)
1441  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1442  LockSemaphoreInfo(image->semaphore);
1443  reference_count=image->reference_count;
1445  return(reference_count);
1446 }
1447 
1448 /*
1449 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1450 % %
1451 % %
1452 % %
1453 % 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 %
1454 % %
1455 % %
1456 % %
1457 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1458 %
1459 % GetImageVirtualPixelMethod() gets the "virtual pixels" method for the
1460 % image. A virtual pixel is any pixel access that is outside the boundaries
1461 % of the image cache.
1462 %
1463 % The format of the GetImageVirtualPixelMethod() method is:
1464 %
1465 % VirtualPixelMethod GetImageVirtualPixelMethod(const Image *image)
1466 %
1467 % A description of each parameter follows:
1468 %
1469 % o image: the image.
1470 %
1471 */
1473 {
1474  assert(image != (Image *) NULL);
1475  assert(image->signature == MagickSignature);
1476  if (image->debug != MagickFalse)
1477  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1478  return(GetPixelCacheVirtualMethod(image));
1479 }
1480 
1481 /*
1482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1483 % %
1484 % %
1485 % %
1486 % I n t e r p r e t I m a g e F i l e n a m e %
1487 % %
1488 % %
1489 % %
1490 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1491 %
1492 % InterpretImageFilename() interprets embedded characters in an image filename.
1493 % The filename length is returned.
1494 %
1495 % The format of the InterpretImageFilename method is:
1496 %
1497 % size_t InterpretImageFilename(const ImageInfo *image_info,Image *image,
1498 % const char *format,int value,char *filename)
1499 %
1500 % A description of each parameter follows.
1501 %
1502 % o image_info: the image info..
1503 %
1504 % o image: the image.
1505 %
1506 % o format: A filename describing the format to use to write the numeric
1507 % argument. Only the first numeric format identifier is replaced.
1508 %
1509 % o value: Numeric value to substitute into format filename.
1510 %
1511 % o filename: return the formatted filename in this character buffer.
1512 %
1513 */
1515  Image *image,const char *format,int value,char *filename)
1516 {
1517  char
1518  *q;
1519 
1520  int
1521  c;
1522 
1524  canonical;
1525 
1526  register const char
1527  *p;
1528 
1529  size_t
1530  length;
1531 
1532  canonical=MagickFalse;
1533  length=0;
1534  (void) CopyMagickString(filename,format,MaxTextExtent);
1535  for (p=strchr(format,'%'); p != (char *) NULL; p=strchr(p+1,'%'))
1536  {
1537  q=(char *) p+1;
1538  if (*q == '%')
1539  {
1540  p=q+1;
1541  continue;
1542  }
1543  if (*q == '0')
1544  {
1545  ssize_t
1546  value;
1547 
1548  value=(ssize_t) strtol(q,&q,10);
1549  (void) value;
1550  }
1551  switch (*q)
1552  {
1553  case 'd':
1554  case 'o':
1555  case 'x':
1556  {
1557  q++;
1558  c=(*q);
1559  *q='\0';
1560  (void) FormatLocaleString(filename+(p-format),(size_t) (MaxTextExtent-
1561  (p-format)),p,value);
1562  *q=c;
1563  (void) ConcatenateMagickString(filename,q,MaxTextExtent);
1564  canonical=MagickTrue;
1565  if (*(q-1) != '%')
1566  break;
1567  p++;
1568  break;
1569  }
1570  case '[':
1571  {
1572  char
1573  pattern[MaxTextExtent];
1574 
1575  const char
1576  *value;
1577 
1578  register char
1579  *r;
1580 
1581  register ssize_t
1582  i;
1583 
1584  ssize_t
1585  depth;
1586 
1587  /*
1588  Image option.
1589  */
1590  if (strchr(p,']') == (char *) NULL)
1591  break;
1592  depth=1;
1593  r=q+1;
1594  for (i=0; (i < (MaxTextExtent-1L)) && (*r != '\0'); i++)
1595  {
1596  if (*r == '[')
1597  depth++;
1598  if (*r == ']')
1599  depth--;
1600  if (depth <= 0)
1601  break;
1602  pattern[i]=(*r++);
1603  }
1604  pattern[i]='\0';
1605  if (LocaleNCompare(pattern,"filename:",9) != 0)
1606  break;
1607  value=(const char *) NULL;
1608 #if 0
1609  /* FUTURE: remove this code. -- Anthony 29 Arpil 2012
1610  Removed as GetMagickProperty() will will never match a "filename:"
1611  string as this is not a 'known' image property.
1612  */
1613  if ((image_info != (const ImageInfo *) NULL) &&
1614  (image != (const Image *) NULL))
1615  value=GetMagickProperty(image_info,image,pattern);
1616  else
1617 #endif
1618  if (image != (Image *) NULL)
1619  value=GetImageProperty(image,pattern);
1620  if ((value == (const char *) NULL) &&
1621  (image != (Image *) NULL))
1622  value=GetImageArtifact(image,pattern);
1623  if ((value == (const char *) NULL) &&
1624  (image_info != (ImageInfo *) NULL))
1625  value=GetImageOption(image_info,pattern);
1626  if (value == (const char *) NULL)
1627  break;
1628  q--;
1629  c=(*q);
1630  *q='\0';
1631  (void) CopyMagickString(filename+(p-format-length),value,(size_t)
1632  (MaxTextExtent-(p-format-length)));
1633  length+=strlen(pattern)-1;
1634  *q=c;
1635  (void) ConcatenateMagickString(filename,r+1,MaxTextExtent);
1636  canonical=MagickTrue;
1637  if (*(q-1) != '%')
1638  break;
1639  p++;
1640  break;
1641  }
1642  default:
1643  break;
1644  }
1645  }
1646  for (q=filename; *q != '\0'; q++)
1647  if ((*q == '%') && (*(q+1) == '%'))
1648  {
1649  (void) CopyMagickString(q,q+1,(size_t) (MaxTextExtent-(q-filename)));
1650  canonical=MagickTrue;
1651  }
1652  if (canonical == MagickFalse)
1653  (void) CopyMagickString(filename,format,MaxTextExtent);
1654  return(strlen(filename));
1655 }
1656 
1657 /*
1658 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1659 % %
1660 % %
1661 % %
1662 % I s H i g h D y n a m i c R a n g e I m a g e %
1663 % %
1664 % %
1665 % %
1666 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1667 %
1668 % IsHighDynamicRangeImage() returns MagickTrue if any pixel component is
1669 % non-integer or exceeds the bounds of the quantum depth (e.g. for Q16
1670 % 0..65535.
1671 %
1672 % The format of the IsHighDynamicRangeImage method is:
1673 %
1674 % MagickBooleanType IsHighDynamicRangeImage(const Image *image,
1675 % ExceptionInfo *exception)
1676 %
1677 % A description of each parameter follows:
1678 %
1679 % o image: the image.
1680 %
1681 % o exception: return any errors or warnings in this structure.
1682 %
1683 */
1686 {
1687 #if !defined(MAGICKCORE_HDRI_SUPPORT)
1688  (void) image;
1689  (void) exception;
1690  return(MagickFalse);
1691 #else
1692  CacheView
1693  *image_view;
1694 
1696  status;
1697 
1699  zero;
1700 
1701  ssize_t
1702  y;
1703 
1704  assert(image != (Image *) NULL);
1705  assert(image->signature == MagickSignature);
1706  if (image->debug != MagickFalse)
1707  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1708  status=MagickTrue;
1709  GetMagickPixelPacket(image,&zero);
1710  image_view=AcquireVirtualCacheView(image,exception);
1711 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1712  #pragma omp parallel for schedule(static,4) shared(status) \
1713  magick_threads(image,image,image->rows,1)
1714 #endif
1715  for (y=0; y < (ssize_t) image->rows; y++)
1716  {
1718  pixel;
1719 
1720  register const IndexPacket
1721  *indexes;
1722 
1723  register const PixelPacket
1724  *p;
1725 
1726  register ssize_t
1727  x;
1728 
1729  if (status == MagickFalse)
1730  continue;
1731  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
1732  if (p == (const PixelPacket *) NULL)
1733  {
1734  status=MagickFalse;
1735  continue;
1736  }
1737  indexes=GetCacheViewVirtualIndexQueue(image_view);
1738  pixel=zero;
1739  for (x=0; x < (ssize_t) image->columns; x++)
1740  {
1741  SetMagickPixelPacket(image,p,indexes+x,&pixel);
1742  if ((pixel.red < 0.0) || (pixel.red > QuantumRange) ||
1743  (pixel.red != (QuantumAny) pixel.red))
1744  break;
1745  if ((pixel.green < 0.0) || (pixel.green > QuantumRange) ||
1746  (pixel.green != (QuantumAny) pixel.green))
1747  break;
1748  if ((pixel.blue < 0.0) || (pixel.blue > QuantumRange) ||
1749  (pixel.blue != (QuantumAny) pixel.blue))
1750  break;
1751  if (pixel.matte != MagickFalse)
1752  {
1753  if ((pixel.opacity < 0.0) || (pixel.opacity > QuantumRange) ||
1754  (pixel.opacity != (QuantumAny) pixel.opacity))
1755  break;
1756  }
1757  if (pixel.colorspace == CMYKColorspace)
1758  {
1759  if ((pixel.index < 0.0) || (pixel.index > QuantumRange) ||
1760  (pixel.index != (QuantumAny) pixel.index))
1761  break;
1762  }
1763  p++;
1764  }
1765  if (x < (ssize_t) image->columns)
1766  status=MagickFalse;
1767  }
1768  image_view=DestroyCacheView(image_view);
1769  return(status != MagickFalse ? MagickFalse : MagickTrue);
1770 #endif
1771 }
1772 
1773 /*
1774 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1775 % %
1776 % %
1777 % %
1778 % I s I m a g e O b j e c t %
1779 % %
1780 % %
1781 % %
1782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1783 %
1784 % IsImageObject() returns MagickTrue if the image sequence contains a valid
1785 % set of image objects.
1786 %
1787 % The format of the IsImageObject method is:
1788 %
1789 % MagickBooleanType IsImageObject(const Image *image)
1790 %
1791 % A description of each parameter follows:
1792 %
1793 % o image: the image.
1794 %
1795 */
1797 {
1798  register const Image
1799  *p;
1800 
1801  assert(image != (Image *) NULL);
1802  if (image->debug != MagickFalse)
1803  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1804  for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1805  if (p->signature != MagickSignature)
1806  return(MagickFalse);
1807  return(MagickTrue);
1808 }
1809 
1810 /*
1811 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1812 % %
1813 % %
1814 % %
1815 % I s T a i n t I m a g e %
1816 % %
1817 % %
1818 % %
1819 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1820 %
1821 % IsTaintImage() returns MagickTrue any pixel in the image has been altered
1822 % since it was first constituted.
1823 %
1824 % The format of the IsTaintImage method is:
1825 %
1826 % MagickBooleanType IsTaintImage(const Image *image)
1827 %
1828 % A description of each parameter follows:
1829 %
1830 % o image: the image.
1831 %
1832 */
1834 {
1835  char
1836  magick[MaxTextExtent],
1837  filename[MaxTextExtent];
1838 
1839  register const Image
1840  *p;
1841 
1842  assert(image != (Image *) NULL);
1843  if (image->debug != MagickFalse)
1844  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1845  assert(image->signature == MagickSignature);
1846  (void) CopyMagickString(magick,image->magick,MaxTextExtent);
1847  (void) CopyMagickString(filename,image->filename,MaxTextExtent);
1848  for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1849  {
1850  if (p->taint != MagickFalse)
1851  return(MagickTrue);
1852  if (LocaleCompare(p->magick,magick) != 0)
1853  return(MagickTrue);
1854  if (LocaleCompare(p->filename,filename) != 0)
1855  return(MagickTrue);
1856  }
1857  return(MagickFalse);
1858 }
1859 
1860 /*
1861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1862 % %
1863 % %
1864 % %
1865 % M o d i f y I m a g e %
1866 % %
1867 % %
1868 % %
1869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1870 %
1871 % ModifyImage() ensures that there is only a single reference to the image
1872 % to be modified, updating the provided image pointer to point to a clone of
1873 % the original image if necessary.
1874 %
1875 % The format of the ModifyImage method is:
1876 %
1877 % MagickBooleanType ModifyImage(Image *image,ExceptionInfo *exception)
1878 %
1879 % A description of each parameter follows:
1880 %
1881 % o image: the image.
1882 %
1883 % o exception: return any errors or warnings in this structure.
1884 %
1885 */
1888 {
1889  Image
1890  *clone_image;
1891 
1892  assert(image != (Image **) NULL);
1893  assert(*image != (Image *) NULL);
1894  assert((*image)->signature == MagickSignature);
1895  if ((*image)->debug != MagickFalse)
1896  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
1897  if (GetImageReferenceCount(*image) <= 1)
1898  return(MagickTrue);
1899  clone_image=CloneImage(*image,0,0,MagickTrue,exception);
1900  LockSemaphoreInfo((*image)->semaphore);
1901  (*image)->reference_count--;
1902  UnlockSemaphoreInfo((*image)->semaphore);
1903  *image=clone_image;
1904  return(MagickTrue);
1905 }
1906 
1907 /*
1908 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1909 % %
1910 % %
1911 % %
1912 % N e w M a g i c k I m a g e %
1913 % %
1914 % %
1915 % %
1916 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1917 %
1918 % NewMagickImage() creates a blank image canvas of the specified size and
1919 % background color.
1920 %
1921 % The format of the NewMagickImage method is:
1922 %
1923 % Image *NewMagickImage(const ImageInfo *image_info,const size_t width,
1924 % const size_t height,const MagickPixelPacket *background)
1925 %
1926 % A description of each parameter follows:
1927 %
1928 % o image: the image.
1929 %
1930 % o width: the image width.
1931 %
1932 % o height: the image height.
1933 %
1934 % o background: the image color.
1935 %
1936 */
1938  const size_t width,const size_t height,const MagickPixelPacket *background)
1939 {
1940  CacheView
1941  *image_view;
1942 
1944  *exception;
1945 
1946  Image
1947  *image;
1948 
1949  ssize_t
1950  y;
1951 
1953  status;
1954 
1955  assert(image_info != (const ImageInfo *) NULL);
1956  if (image_info->debug != MagickFalse)
1957  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1958  assert(image_info->signature == MagickSignature);
1959  assert(background != (const MagickPixelPacket *) NULL);
1960  image=AcquireImage(image_info);
1961  image->columns=width;
1962  image->rows=height;
1963  image->colorspace=background->colorspace;
1964  image->matte=background->matte;
1965  image->fuzz=background->fuzz;
1966  image->depth=background->depth;
1967  status=MagickTrue;
1968  exception=(&image->exception);
1969  image_view=AcquireAuthenticCacheView(image,exception);
1970 #if defined(MAGICKCORE_OPENMP_SUPPORT)
1971  #pragma omp parallel for schedule(static,4) shared(status) \
1972  magick_threads(image,image,image->rows,1)
1973 #endif
1974  for (y=0; y < (ssize_t) image->rows; y++)
1975  {
1976  register IndexPacket
1977  *restrict indexes;
1978 
1979  register PixelPacket
1980  *restrict q;
1981 
1982  register ssize_t
1983  x;
1984 
1985  if (status == MagickFalse)
1986  continue;
1987  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
1988  if (q == (PixelPacket *) NULL)
1989  {
1990  status=MagickFalse;
1991  continue;
1992  }
1993  indexes=GetCacheViewAuthenticIndexQueue(image_view);
1994  for (x=0; x < (ssize_t) image->columns; x++)
1995  {
1996  SetPixelPacket(image,background,q,indexes+x);
1997  q++;
1998  }
1999  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2000  status=MagickFalse;
2001  }
2002  image_view=DestroyCacheView(image_view);
2003  if (status == MagickFalse)
2004  image=DestroyImage(image);
2005  return(image);
2006 }
2007 
2008 /*
2009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2010 % %
2011 % %
2012 % %
2013 % R e f e r e n c e I m a g e %
2014 % %
2015 % %
2016 % %
2017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2018 %
2019 % ReferenceImage() increments the reference count associated with an image
2020 % returning a pointer to the image.
2021 %
2022 % The format of the ReferenceImage method is:
2023 %
2024 % Image *ReferenceImage(Image *image)
2025 %
2026 % A description of each parameter follows:
2027 %
2028 % o image: the image.
2029 %
2030 */
2032 {
2033  assert(image != (Image *) NULL);
2034  if (image->debug != MagickFalse)
2035  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2036  assert(image->signature == MagickSignature);
2037  LockSemaphoreInfo(image->semaphore);
2038  image->reference_count++;
2040  return(image);
2041 }
2042 
2043 /*
2044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2045 % %
2046 % %
2047 % %
2048 % R e s e t I m a g e P a g e %
2049 % %
2050 % %
2051 % %
2052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2053 %
2054 % ResetImagePage() resets the image page canvas and position.
2055 %
2056 % The format of the ResetImagePage method is:
2057 %
2058 % MagickBooleanType ResetImagePage(Image *image,const char *page)
2059 %
2060 % A description of each parameter follows:
2061 %
2062 % o image: the image.
2063 %
2064 % o page: the relative page specification.
2065 %
2066 */
2068 {
2070  flags;
2071 
2073  geometry;
2074 
2075  assert(image != (Image *) NULL);
2076  assert(image->signature == MagickSignature);
2077  if (image->debug != MagickFalse)
2078  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2079  flags=ParseAbsoluteGeometry(page,&geometry);
2080  if ((flags & WidthValue) != 0)
2081  {
2082  if ((flags & HeightValue) == 0)
2083  geometry.height=geometry.width;
2084  image->page.width=geometry.width;
2085  image->page.height=geometry.height;
2086  }
2087  if ((flags & AspectValue) != 0)
2088  {
2089  if ((flags & XValue) != 0)
2090  image->page.x+=geometry.x;
2091  if ((flags & YValue) != 0)
2092  image->page.y+=geometry.y;
2093  }
2094  else
2095  {
2096  if ((flags & XValue) != 0)
2097  {
2098  image->page.x=geometry.x;
2099  if ((image->page.width == 0) && (geometry.x > 0))
2100  image->page.width=image->columns+geometry.x;
2101  }
2102  if ((flags & YValue) != 0)
2103  {
2104  image->page.y=geometry.y;
2105  if ((image->page.height == 0) && (geometry.y > 0))
2106  image->page.height=image->rows+geometry.y;
2107  }
2108  }
2109  return(MagickTrue);
2110 }
2111 
2112 /*
2113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2114 % %
2115 % %
2116 % %
2117 % S e t I m a g e B a c k g r o u n d C o l o r %
2118 % %
2119 % %
2120 % %
2121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2122 %
2123 % SetImageBackgroundColor() initializes the image pixels to the image
2124 % background color. The background color is defined by the background_color
2125 % member of the image structure.
2126 %
2127 % The format of the SetImage method is:
2128 %
2129 % MagickBooleanType SetImageBackgroundColor(Image *image)
2130 %
2131 % A description of each parameter follows:
2132 %
2133 % o image: the image.
2134 %
2135 */
2137 {
2138  CacheView
2139  *image_view;
2140 
2142  *exception;
2143 
2144  IndexPacket
2145  index;
2146 
2148  status;
2149 
2151  background;
2152 
2153  PixelPacket
2154  pixel;
2155 
2156  ssize_t
2157  y;
2158 
2159  assert(image != (Image *) NULL);
2160  if (image->debug != MagickFalse)
2161  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2162  assert(image->signature == MagickSignature);
2164  return(MagickFalse);
2165  if ((IsPixelGray(&image->background_color) == MagickFalse) &&
2168  if ((image->background_color.opacity != OpaqueOpacity) &&
2169  (image->matte == MagickFalse))
2171  GetMagickPixelPacket(image,&background);
2172  SetMagickPixelPacket(image,&image->background_color,(const IndexPacket *)
2173  NULL,&background);
2174  if (image->colorspace == CMYKColorspace)
2175  ConvertRGBToCMYK(&background);
2176  index=0;
2177  pixel.opacity=OpaqueOpacity;
2178  SetPixelPacket(image,&background,&pixel,&index);
2179  /*
2180  Set image background color.
2181  */
2182  status=MagickTrue;
2183  exception=(&image->exception);
2184  image_view=AcquireAuthenticCacheView(image,exception);
2185  for (y=0; y < (ssize_t) image->rows; y++)
2186  {
2187  register PixelPacket
2188  *restrict q;
2189 
2190  register ssize_t
2191  x;
2192 
2193  if (status == MagickFalse)
2194  continue;
2195  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2196  if (q == (PixelPacket *) NULL)
2197  {
2198  status=MagickFalse;
2199  continue;
2200  }
2201  for (x=0; x < (ssize_t) image->columns; x++)
2202  *q++=pixel;
2203  if (image->colorspace == CMYKColorspace)
2204  {
2205  register IndexPacket
2206  *restrict indexes;
2207 
2208  indexes=GetCacheViewAuthenticIndexQueue(image_view);
2209  for (x=0; x < (ssize_t) image->columns; x++)
2210  SetPixelIndex(indexes+x,index);
2211  }
2212  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2213  status=MagickFalse;
2214  }
2215  image_view=DestroyCacheView(image_view);
2216  return(status);
2217 }
2218 
2219 /*
2220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2221 % %
2222 % %
2223 % %
2224 % S e t I m a g e C h a n n e l s %
2225 % %
2226 % %
2227 % %
2228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2229 %
2230 % SetImageChannels() sets the number of pixels channels associated with the
2231 % image.
2232 %
2233 % The format of the SetImageChannels method is:
2234 %
2235 % MagickBooleanType SetImageChannels(Image *image,const size_t channels)
2236 %
2237 % A description of each parameter follows:
2238 %
2239 % o image: the image.
2240 %
2241 % o channels: The number of pixel channels.
2242 %
2243 */
2245  const size_t channels)
2246 {
2247  image->channels=channels;
2248  return(MagickTrue);
2249 }
2250 
2251 /*
2252 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2253 % %
2254 % %
2255 % %
2256 % S e t I m a g e C o l o r %
2257 % %
2258 % %
2259 % %
2260 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2261 %
2262 % SetImageColor() set the entire image canvas to the specified color.
2263 %
2264 % The format of the SetImageColor method is:
2265 %
2266 % MagickBooleanType SetImageColor(Image *image,
2267 % const MagickPixelPacket *color)
2268 %
2269 % A description of each parameter follows:
2270 %
2271 % o image: the image.
2272 %
2273 % o background: the image color.
2274 %
2275 */
2277  const MagickPixelPacket *color)
2278 {
2279  CacheView
2280  *image_view;
2281 
2283  *exception;
2284 
2286  status;
2287 
2288  ssize_t
2289  y;
2290 
2291  assert(image != (Image *) NULL);
2292  if (image->debug != MagickFalse)
2293  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2294  assert(image->signature == MagickSignature);
2295  assert(color != (const MagickPixelPacket *) NULL);
2296  image->colorspace=color->colorspace;
2297  image->matte=color->matte;
2298  image->fuzz=color->fuzz;
2299  image->depth=color->depth;
2300  status=MagickTrue;
2301  exception=(&image->exception);
2302  image_view=AcquireAuthenticCacheView(image,exception);
2303 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2304  #pragma omp parallel for schedule(static,4) shared(status) \
2305  magick_threads(image,image,image->rows,1)
2306 #endif
2307  for (y=0; y < (ssize_t) image->rows; y++)
2308  {
2309  register IndexPacket
2310  *restrict indexes;
2311 
2312  register PixelPacket
2313  *restrict q;
2314 
2315  register ssize_t
2316  x;
2317 
2318  if (status == MagickFalse)
2319  continue;
2320  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2321  if (q == (PixelPacket *) NULL)
2322  {
2323  status=MagickFalse;
2324  continue;
2325  }
2326  indexes=GetCacheViewAuthenticIndexQueue(image_view);
2327  for (x=0; x < (ssize_t) image->columns; x++)
2328  {
2329  SetPixelPacket(image,color,q,indexes+x);
2330  q++;
2331  }
2332  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2333  status=MagickFalse;
2334  }
2335  image_view=DestroyCacheView(image_view);
2336  return(status);
2337 }
2338 
2339 /*
2340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2341 % %
2342 % %
2343 % %
2344 % S e t I m a g e S t o r a g e C l a s s %
2345 % %
2346 % %
2347 % %
2348 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2349 %
2350 % SetImageStorageClass() sets the image class: DirectClass for true color
2351 % images or PseudoClass for colormapped images.
2352 %
2353 % The format of the SetImageStorageClass method is:
2354 %
2355 % MagickBooleanType SetImageStorageClass(Image *image,
2356 % const ClassType storage_class)
2357 %
2358 % A description of each parameter follows:
2359 %
2360 % o image: the image.
2361 %
2362 % o storage_class: The image class.
2363 %
2364 */
2366  const ClassType storage_class)
2367 {
2368  image->storage_class=storage_class;
2369  return(SyncImagePixelCache(image,&image->exception));
2370 }
2371 
2372 /*
2373 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2374 % %
2375 % %
2376 % %
2377 % S e t I m a g e C l i p M a s k %
2378 % %
2379 % %
2380 % %
2381 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2382 %
2383 % SetImageClipMask() associates a clip path with the image. The clip path
2384 % must be the same dimensions as the image. Set any pixel component of
2385 % the clip path to TransparentOpacity to prevent that corresponding image
2386 % pixel component from being updated when SyncAuthenticPixels() is applied.
2387 %
2388 % The format of the SetImageClipMask method is:
2389 %
2390 % MagickBooleanType SetImageClipMask(Image *image,const Image *clip_mask)
2391 %
2392 % A description of each parameter follows:
2393 %
2394 % o image: the image.
2395 %
2396 % o clip_mask: the image clip path.
2397 %
2398 */
2400  const Image *clip_mask)
2401 {
2402  assert(image != (Image *) NULL);
2403  if (image->debug != MagickFalse)
2404  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2405  assert(image->signature == MagickSignature);
2406  if (clip_mask != (const Image *) NULL)
2407  if ((clip_mask->columns != image->columns) ||
2408  (clip_mask->rows != image->rows))
2409  ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
2410  if (image->clip_mask != (Image *) NULL)
2411  image->clip_mask=DestroyImage(image->clip_mask);
2412  image->clip_mask=NewImageList();
2413  if (clip_mask == (Image *) NULL)
2414  return(MagickTrue);
2416  return(MagickFalse);
2417  image->clip_mask=CloneImage(clip_mask,0,0,MagickTrue,&image->exception);
2418  if (image->clip_mask == (Image *) NULL)
2419  return(MagickFalse);
2420  return(MagickTrue);
2421 }
2422 
2423 /*
2424 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2425 % %
2426 % %
2427 % %
2428 % S e t I m a g e E x t e n t %
2429 % %
2430 % %
2431 % %
2432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2433 %
2434 % SetImageExtent() sets the image size (i.e. columns & rows).
2435 %
2436 % The format of the SetImageExtent method is:
2437 %
2438 % MagickBooleanType SetImageExtent(Image *image,
2439 % const size_t columns,const size_t rows)
2440 %
2441 % A description of each parameter follows:
2442 %
2443 % o image: the image.
2444 %
2445 % o columns: The image width in pixels.
2446 %
2447 % o rows: The image height in pixels.
2448 %
2449 */
2451  const size_t columns,const size_t rows)
2452 {
2453  if ((columns == 0) || (rows == 0))
2454  return(MagickFalse);
2455  image->columns=columns;
2456  image->rows=rows;
2457  return(SyncImagePixelCache(image,&image->exception));
2458 }
2459 
2460 /*
2461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2462 % %
2463 % %
2464 % %
2465 + S e t I m a g e I n f o %
2466 % %
2467 % %
2468 % %
2469 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2470 %
2471 % SetImageInfo() initializes the `magick' field of the ImageInfo structure.
2472 % It is set to a type of image format based on the prefix or suffix of the
2473 % filename. For example, `ps:image' returns PS indicating a Postscript image.
2474 % JPEG is returned for this filename: `image.jpg'. The filename prefix has
2475 % precendence over the suffix. Use an optional index enclosed in brackets
2476 % after a file name to specify a desired scene of a multi-resolution image
2477 % format like Photo CD (e.g. img0001.pcd[4]). A True (non-zero) return value
2478 % indicates success.
2479 %
2480 % The format of the SetImageInfo method is:
2481 %
2482 % MagickBooleanType SetImageInfo(ImageInfo *image_info,
2483 % const unsigned int frames,ExceptionInfo *exception)
2484 %
2485 % A description of each parameter follows:
2486 %
2487 % o image_info: the image info.
2488 %
2489 % o frames: the number of images you intend to write.
2490 %
2491 % o exception: return any errors or warnings in this structure.
2492 %
2493 */
2495  const unsigned int frames,ExceptionInfo *exception)
2496 {
2497  char
2498  extension[MaxTextExtent],
2499  filename[MaxTextExtent],
2500  magic[MaxTextExtent],
2501  *q,
2502  subimage[MaxTextExtent];
2503 
2504  const MagicInfo
2505  *magic_info;
2506 
2507  const MagickInfo
2508  *magick_info;
2509 
2511  *sans_exception;
2512 
2513  Image
2514  *image;
2515 
2517  status;
2518 
2519  register const char
2520  *p;
2521 
2522  ssize_t
2523  count;
2524 
2525  unsigned char
2526  magick[2*MaxTextExtent];
2527 
2528  /*
2529  Look for 'image.format' in filename.
2530  */
2531  assert(image_info != (ImageInfo *) NULL);
2532  assert(image_info->signature == MagickSignature);
2533  if (image_info->debug != MagickFalse)
2535  image_info->filename);
2536  *subimage='\0';
2537  GetPathComponent(image_info->filename,SubimagePath,subimage);
2538  if (*subimage != '\0')
2539  {
2540  /*
2541  Look for scene specification (e.g. img0001.pcd[4]).
2542  */
2543  if (IsSceneGeometry(subimage,MagickFalse) == MagickFalse)
2544  {
2545  if (IsGeometry(subimage) != MagickFalse)
2546  (void) CloneString(&image_info->extract,subimage);
2547  }
2548  else
2549  {
2550  size_t
2551  first,
2552  last;
2553 
2554  (void) CloneString(&image_info->scenes,subimage);
2555  image_info->scene=StringToUnsignedLong(image_info->scenes);
2556  image_info->number_scenes=image_info->scene;
2557  p=image_info->scenes;
2558  for (q=(char *) image_info->scenes; *q != '\0'; p++)
2559  {
2560  while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
2561  p++;
2562  first=(size_t) strtol(p,&q,10);
2563  last=first;
2564  while (isspace((int) ((unsigned char) *q)) != 0)
2565  q++;
2566  if (*q == '-')
2567  last=(size_t) strtol(q+1,&q,10);
2568  if (first > last)
2569  Swap(first,last);
2570  if (first < image_info->scene)
2571  image_info->scene=first;
2572  if (last > image_info->number_scenes)
2573  image_info->number_scenes=last;
2574  p=q;
2575  }
2576  image_info->number_scenes-=image_info->scene-1;
2577  image_info->subimage=image_info->scene;
2578  image_info->subrange=image_info->number_scenes;
2579  }
2580  }
2581  *extension='\0';
2582  if (*image_info->magick == '\0')
2583  GetPathComponent(image_info->filename,ExtensionPath,extension);
2584 #if defined(MAGICKCORE_ZLIB_DELEGATE)
2585  if (*extension != '\0')
2586  if ((LocaleCompare(extension,"gz") == 0) ||
2587  (LocaleCompare(extension,"Z") == 0) ||
2588  (LocaleCompare(extension,"svgz") == 0) ||
2589  (LocaleCompare(extension,"wmz") == 0))
2590  {
2591  char
2592  path[MaxTextExtent];
2593 
2594  (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
2595  path[strlen(path)-strlen(extension)-1]='\0';
2596  GetPathComponent(path,ExtensionPath,extension);
2597  }
2598 #endif
2599 #if defined(MAGICKCORE_BZLIB_DELEGATE)
2600  if (*extension != '\0')
2601  if (LocaleCompare(extension,"bz2") == 0)
2602  {
2603  char
2604  path[MaxTextExtent];
2605 
2606  (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
2607  path[strlen(path)-strlen(extension)-1]='\0';
2608  GetPathComponent(path,ExtensionPath,extension);
2609  }
2610 #endif
2611  image_info->affirm=MagickFalse;
2612  sans_exception=AcquireExceptionInfo();
2613  if (*extension != '\0')
2614  {
2616  format_type;
2617 
2618  register ssize_t
2619  i;
2620 
2621  static const char
2622  *format_type_formats[] =
2623  {
2624  "AUTOTRACE",
2625  "BROWSE",
2626  "DCRAW",
2627  "EDIT",
2628  "EPHEMERAL",
2629  "LAUNCH",
2630  "MPEG:DECODE",
2631  "MPEG:ENCODE",
2632  "PRINT",
2633  "PS:ALPHA",
2634  "PS:CMYK",
2635  "PS:COLOR",
2636  "PS:GRAY",
2637  "PS:MONO",
2638  "SCAN",
2639  "SHOW",
2640  "WIN",
2641  (char *) NULL
2642  };
2643 
2644  /*
2645  User specified image format.
2646  */
2647  (void) CopyMagickString(magic,extension,MaxTextExtent);
2648  LocaleUpper(magic);
2649  /*
2650  Look for explicit image formats.
2651  */
2652  format_type=UndefinedFormatType;
2653  i=0;
2654  while ((format_type == UndefinedFormatType) &&
2655  (format_type_formats[i] != (char *) NULL))
2656  {
2657  if ((*magic == *format_type_formats[i]) &&
2658  (LocaleCompare(magic,format_type_formats[i]) == 0))
2659  format_type=ExplicitFormatType;
2660  i++;
2661  }
2662  magick_info=GetMagickInfo(magic,sans_exception);
2663  if ((magick_info != (const MagickInfo *) NULL) &&
2664  (magick_info->format_type != UndefinedFormatType))
2665  format_type=magick_info->format_type;
2666  if (format_type == UndefinedFormatType)
2667  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2668  else
2669  if (format_type == ExplicitFormatType)
2670  {
2671  image_info->affirm=MagickTrue;
2672  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2673  }
2674  if (LocaleCompare(magic,"RGB") == 0)
2675  image_info->affirm=MagickFalse; /* maybe SGI disguised as RGB */
2676  }
2677  /*
2678  Look for explicit 'format:image' in filename.
2679  */
2680  *magic='\0';
2681  GetPathComponent(image_info->filename,MagickPath,magic);
2682  if (*magic == '\0')
2683  (void) CopyMagickString(magic,image_info->magick,MaxTextExtent);
2684  else
2685  {
2686  /*
2687  User specified image format.
2688  */
2689  LocaleUpper(magic);
2690  if (IsMagickConflict(magic) == MagickFalse)
2691  {
2692  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2693  if (LocaleCompare(magic,"EPHEMERAL") != 0)
2694  image_info->affirm=MagickTrue;
2695  else
2696  image_info->temporary=MagickTrue;
2697  }
2698  }
2699  magick_info=GetMagickInfo(magic,sans_exception);
2700  sans_exception=DestroyExceptionInfo(sans_exception);
2701  if ((magick_info == (const MagickInfo *) NULL) ||
2702  (GetMagickEndianSupport(magick_info) == MagickFalse))
2703  image_info->endian=UndefinedEndian;
2704  GetPathComponent(image_info->filename,CanonicalPath,filename);
2705  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2706  if ((image_info->adjoin != MagickFalse) && (frames > 1))
2707  {
2708  /*
2709  Test for multiple image support (e.g. image%02d.png).
2710  */
2711  (void) InterpretImageFilename(image_info,(Image *) NULL,
2712  image_info->filename,(int) image_info->scene,filename);
2713  if ((LocaleCompare(filename,image_info->filename) != 0) &&
2714  (strchr(filename,'%') == (char *) NULL))
2715  image_info->adjoin=MagickFalse;
2716  }
2717  if ((image_info->adjoin != MagickFalse) && (frames > 0))
2718  {
2719  /*
2720  Some image formats do not support multiple frames per file.
2721  */
2722  magick_info=GetMagickInfo(magic,exception);
2723  if (magick_info != (const MagickInfo *) NULL)
2724  if (GetMagickAdjoin(magick_info) == MagickFalse)
2725  image_info->adjoin=MagickFalse;
2726  }
2727  if (image_info->affirm != MagickFalse)
2728  return(MagickTrue);
2729  if (frames == 0)
2730  {
2731  /*
2732  Determine the image format from the first few bytes of the file.
2733  */
2734  image=AcquireImage(image_info);
2735  (void) CopyMagickString(image->filename,image_info->filename,
2736  MaxTextExtent);
2737  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2738  if (status == MagickFalse)
2739  {
2740  image=DestroyImage(image);
2741  return(MagickFalse);
2742  }
2743  if ((IsBlobSeekable(image) == MagickFalse) ||
2744  (IsBlobExempt(image) != MagickFalse))
2745  {
2746  /*
2747  Copy standard input or pipe to temporary file.
2748  */
2749  *filename='\0';
2750  status=ImageToFile(image,filename,exception);
2751  (void) CloseBlob(image);
2752  if (status == MagickFalse)
2753  {
2754  image=DestroyImage(image);
2755  return(MagickFalse);
2756  }
2757  SetImageInfoFile(image_info,(FILE *) NULL);
2758  (void) CopyMagickString(image->filename,filename,MaxTextExtent);
2759  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2760  if (status == MagickFalse)
2761  {
2762  image=DestroyImage(image);
2763  return(MagickFalse);
2764  }
2765  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2766  image_info->temporary=MagickTrue;
2767  }
2768  (void) ResetMagickMemory(magick,0,sizeof(magick));
2769  count=ReadBlob(image,2*MaxTextExtent,magick);
2770  (void) SeekBlob(image,-((MagickOffsetType) count),SEEK_CUR);
2771  (void) CloseBlob(image);
2772  image=DestroyImage(image);
2773  /*
2774  Check magic.xml configuration file.
2775  */
2776  sans_exception=AcquireExceptionInfo();
2777  magic_info=GetMagicInfo(magick,(size_t) count,sans_exception);
2778  if ((magic_info != (const MagicInfo *) NULL) &&
2779  (GetMagicName(magic_info) != (char *) NULL))
2780  {
2781  (void) CopyMagickString(image_info->magick,GetMagicName(magic_info),
2782  MaxTextExtent);
2783  magick_info=GetMagickInfo(image_info->magick,sans_exception);
2784  if ((magick_info == (const MagickInfo *) NULL) ||
2785  (GetMagickEndianSupport(magick_info) == MagickFalse))
2786  image_info->endian=UndefinedEndian;
2787  sans_exception=DestroyExceptionInfo(sans_exception);
2788  return(MagickTrue);
2789  }
2790  magick_info=GetMagickInfo(image_info->magick,sans_exception);
2791  if ((magick_info == (const MagickInfo *) NULL) ||
2792  (GetMagickEndianSupport(magick_info) == MagickFalse))
2793  image_info->endian=UndefinedEndian;
2794  sans_exception=DestroyExceptionInfo(sans_exception);
2795  }
2796  return(MagickTrue);
2797 }
2798 
2799 /*
2800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2801 % %
2802 % %
2803 % %
2804 % S e t I m a g e I n f o B l o b %
2805 % %
2806 % %
2807 % %
2808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2809 %
2810 % SetImageInfoBlob() sets the image info blob member.
2811 %
2812 % The format of the SetImageInfoBlob method is:
2813 %
2814 % void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
2815 % const size_t length)
2816 %
2817 % A description of each parameter follows:
2818 %
2819 % o image_info: the image info.
2820 %
2821 % o blob: the blob.
2822 %
2823 % o length: the blob length.
2824 %
2825 */
2826 MagickExport void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
2827  const size_t length)
2828 {
2829  assert(image_info != (ImageInfo *) NULL);
2830  assert(image_info->signature == MagickSignature);
2831  if (image_info->debug != MagickFalse)
2833  image_info->filename);
2834  image_info->blob=(void *) blob;
2835  image_info->length=length;
2836 }
2837 
2838 /*
2839 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2840 % %
2841 % %
2842 % %
2843 % S e t I m a g e I n f o F i l e %
2844 % %
2845 % %
2846 % %
2847 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2848 %
2849 % SetImageInfoFile() sets the image info file member.
2850 %
2851 % The format of the SetImageInfoFile method is:
2852 %
2853 % void SetImageInfoFile(ImageInfo *image_info,FILE *file)
2854 %
2855 % A description of each parameter follows:
2856 %
2857 % o image_info: the image info.
2858 %
2859 % o file: the file.
2860 %
2861 */
2862 MagickExport void SetImageInfoFile(ImageInfo *image_info,FILE *file)
2863 {
2864  assert(image_info != (ImageInfo *) NULL);
2865  assert(image_info->signature == MagickSignature);
2866  if (image_info->debug != MagickFalse)
2868  image_info->filename);
2869  image_info->file=file;
2870 }
2871 
2872 /*
2873 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2874 % %
2875 % %
2876 % %
2877 % S e t I m a g e M a s k %
2878 % %
2879 % %
2880 % %
2881 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2882 %
2883 % SetImageMask() associates a mask with the image. The mask must be the same
2884 % dimensions as the image.
2885 %
2886 % The format of the SetImageMask method is:
2887 %
2888 % MagickBooleanType SetImageMask(Image *image,const Image *mask)
2889 %
2890 % A description of each parameter follows:
2891 %
2892 % o image: the image.
2893 %
2894 % o mask: the image mask.
2895 %
2896 */
2898 {
2899  assert(image != (Image *) NULL);
2900  if (image->debug != MagickFalse)
2901  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2902  assert(image->signature == MagickSignature);
2903  if (mask != (const Image *) NULL)
2904  if ((mask->columns != image->columns) || (mask->rows != image->rows))
2905  ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
2906  if (image->mask != (Image *) NULL)
2907  image->mask=DestroyImage(image->mask);
2908  image->mask=NewImageList();
2909  if (mask == (Image *) NULL)
2910  return(MagickTrue);
2912  return(MagickFalse);
2913  image->mask=CloneImage(mask,0,0,MagickTrue,&image->exception);
2914  if (image->mask == (Image *) NULL)
2915  return(MagickFalse);
2916  return(MagickTrue);
2917 }
2918 
2919 /*
2920 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2921 % %
2922 % %
2923 % %
2924 % S e t I m a g e O p a c i t y %
2925 % %
2926 % %
2927 % %
2928 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2929 %
2930 % SetImageOpacity() sets the opacity levels of the image.
2931 %
2932 % The format of the SetImageOpacity method is:
2933 %
2934 % MagickBooleanType SetImageOpacity(Image *image,const Quantum opacity)
2935 %
2936 % A description of each parameter follows:
2937 %
2938 % o image: the image.
2939 %
2940 % o opacity: the level of transparency: 0 is fully opaque and QuantumRange is
2941 % fully transparent.
2942 %
2943 */
2945  const Quantum opacity)
2946 {
2947  CacheView
2948  *image_view;
2949 
2951  *exception;
2952 
2954  status;
2955 
2956  ssize_t
2957  y;
2958 
2959  assert(image != (Image *) NULL);
2960  if (image->debug != MagickFalse)
2961  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2962  assert(image->signature == MagickSignature);
2963  image->matte=MagickTrue;
2964  status=MagickTrue;
2965  exception=(&image->exception);
2966  image_view=AcquireAuthenticCacheView(image,exception);
2967 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2968  #pragma omp parallel for schedule(static,4) shared(status) \
2969  magick_threads(image,image,image->rows,1)
2970 #endif
2971  for (y=0; y < (ssize_t) image->rows; y++)
2972  {
2973  register PixelPacket
2974  *restrict q;
2975 
2976  register ssize_t
2977  x;
2978 
2979  if (status == MagickFalse)
2980  continue;
2981  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2982  if (q == (PixelPacket *) NULL)
2983  {
2984  status=MagickFalse;
2985  continue;
2986  }
2987  for (x=0; x < (ssize_t) image->columns; x++)
2988  {
2989  SetPixelOpacity(q,opacity);
2990  q++;
2991  }
2992  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2993  status=MagickFalse;
2994  }
2995  image_view=DestroyCacheView(image_view);
2996  return(status);
2997 }
2998 
2999 /*
3000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3001 % %
3002 % %
3003 % %
3004 % 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 %
3005 % %
3006 % %
3007 % %
3008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3009 %
3010 % SetImageVirtualPixelMethod() sets the "virtual pixels" method for the
3011 % image and returns the previous setting. A virtual pixel is any pixel access
3012 % that is outside the boundaries of the image cache.
3013 %
3014 % The format of the SetImageVirtualPixelMethod() method is:
3015 %
3016 % VirtualPixelMethod SetImageVirtualPixelMethod(const Image *image,
3017 % const VirtualPixelMethod virtual_pixel_method)
3018 %
3019 % A description of each parameter follows:
3020 %
3021 % o image: the image.
3022 %
3023 % o virtual_pixel_method: choose the type of virtual pixel.
3024 %
3025 */
3027  const VirtualPixelMethod virtual_pixel_method)
3028 {
3029  assert(image != (const Image *) NULL);
3030  assert(image->signature == MagickSignature);
3031  if (image->debug != MagickFalse)
3032  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3033  return(SetPixelCacheVirtualMethod(image,virtual_pixel_method));
3034 }
3035 
3036 /*
3037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3038 % %
3039 % %
3040 % %
3041 % S m u s h I m a g e s %
3042 % %
3043 % %
3044 % %
3045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3046 %
3047 % SmushImages() takes all images from the current image pointer to the end
3048 % of the image list and smushes them to each other top-to-bottom if the
3049 % stack parameter is true, otherwise left-to-right.
3050 %
3051 % The current gravity setting now effects how the image is justified in the
3052 % final image.
3053 %
3054 % The format of the SmushImages method is:
3055 %
3056 % Image *SmushImages(const Image *images,const MagickBooleanType stack,
3057 % ExceptionInfo *exception)
3058 %
3059 % A description of each parameter follows:
3060 %
3061 % o images: the image sequence.
3062 %
3063 % o stack: A value other than 0 stacks the images top-to-bottom.
3064 %
3065 % o offset: minimum distance in pixels between images.
3066 %
3067 % o exception: return any errors or warnings in this structure.
3068 %
3069 */
3070 
3071 static ssize_t SmushXGap(const Image *smush_image,const Image *images,
3072  const ssize_t offset,ExceptionInfo *exception)
3073 {
3074  CacheView
3075  *left_view,
3076  *right_view;
3077 
3078  const Image
3079  *left_image,
3080  *right_image;
3081 
3083  left_geometry,
3084  right_geometry;
3085 
3086  register const PixelPacket
3087  *p;
3088 
3089  register ssize_t
3090  i,
3091  y;
3092 
3093  size_t
3094  gap;
3095 
3096  ssize_t
3097  x;
3098 
3099  if (images->previous == (Image *) NULL)
3100  return(0);
3101  right_image=images;
3102  SetGeometry(smush_image,&right_geometry);
3103  GravityAdjustGeometry(right_image->columns,right_image->rows,
3104  right_image->gravity,&right_geometry);
3105  left_image=images->previous;
3106  SetGeometry(smush_image,&left_geometry);
3107  GravityAdjustGeometry(left_image->columns,left_image->rows,
3108  left_image->gravity,&left_geometry);
3109  gap=right_image->columns;
3110  left_view=AcquireVirtualCacheView(left_image,exception);
3111  right_view=AcquireVirtualCacheView(right_image,exception);
3112  for (y=0; y < (ssize_t) smush_image->rows; y++)
3113  {
3114  for (x=(ssize_t) left_image->columns-1; x > 0; x--)
3115  {
3116  p=GetCacheViewVirtualPixels(left_view,x,left_geometry.y+y,1,1,exception);
3117  if ((p == (const PixelPacket *) NULL) ||
3119  ((left_image->columns-x-1) >= gap))
3120  break;
3121  }
3122  i=(ssize_t) left_image->columns-x-1;
3123  for (x=0; x < (ssize_t) right_image->columns; x++)
3124  {
3125  p=GetCacheViewVirtualPixels(right_view,x,right_geometry.y+y,1,1,
3126  exception);
3127  if ((p == (const PixelPacket *) NULL) ||
3129  ((x+i) >= (ssize_t) gap))
3130  break;
3131  }
3132  if ((x+i) < (ssize_t) gap)
3133  gap=(size_t) (x+i);
3134  }
3135  right_view=DestroyCacheView(right_view);
3136  left_view=DestroyCacheView(left_view);
3137  if (y < (ssize_t) smush_image->rows)
3138  return(offset);
3139  return((ssize_t) gap-offset);
3140 }
3141 
3142 static ssize_t SmushYGap(const Image *smush_image,const Image *images,
3143  const ssize_t offset,ExceptionInfo *exception)
3144 {
3145  CacheView
3146  *bottom_view,
3147  *top_view;
3148 
3149  const Image
3150  *bottom_image,
3151  *top_image;
3152 
3154  bottom_geometry,
3155  top_geometry;
3156 
3157  register const PixelPacket
3158  *p;
3159 
3160  register ssize_t
3161  i,
3162  x;
3163 
3164  size_t
3165  gap;
3166 
3167  ssize_t
3168  y;
3169 
3170  if (images->previous == (Image *) NULL)
3171  return(0);
3172  bottom_image=images;
3173  SetGeometry(smush_image,&bottom_geometry);
3174  GravityAdjustGeometry(bottom_image->columns,bottom_image->rows,
3175  bottom_image->gravity,&bottom_geometry);
3176  top_image=images->previous;
3177  SetGeometry(smush_image,&top_geometry);
3178  GravityAdjustGeometry(top_image->columns,top_image->rows,top_image->gravity,
3179  &top_geometry);
3180  gap=bottom_image->rows;
3181  top_view=AcquireVirtualCacheView(top_image,exception);
3182  bottom_view=AcquireVirtualCacheView(bottom_image,exception);
3183  for (x=0; x < (ssize_t) smush_image->columns; x++)
3184  {
3185  for (y=(ssize_t) top_image->rows-1; y > 0; y--)
3186  {
3187  p=GetCacheViewVirtualPixels(top_view,top_geometry.x+x,y,1,1,exception);
3188  if ((p == (const PixelPacket *) NULL) ||
3190  ((top_image->rows-y-1) >= gap))
3191  break;
3192  }
3193  i=(ssize_t) top_image->rows-y-1;
3194  for (y=0; y < (ssize_t) bottom_image->rows; y++)
3195  {
3196  p=GetCacheViewVirtualPixels(bottom_view,bottom_geometry.x+x,y,1,1,
3197  exception);
3198  if ((p == (const PixelPacket *) NULL) ||
3200  ((y+i) >= (ssize_t) gap))
3201  break;
3202  }
3203  if ((y+i) < (ssize_t) gap)
3204  gap=(size_t) (y+i);
3205  }
3206  bottom_view=DestroyCacheView(bottom_view);
3207  top_view=DestroyCacheView(top_view);
3208  if (x < (ssize_t) smush_image->columns)
3209  return(offset);
3210  return((ssize_t) gap-offset);
3211 }
3212 
3214  const MagickBooleanType stack,const ssize_t offset,ExceptionInfo *exception)
3215 {
3216 #define SmushImageTag "Smush/Image"
3217 
3218  CacheView
3219  *smush_view;
3220 
3221  const Image
3222  *image;
3223 
3224  Image
3225  *smush_image;
3226 
3228  matte,
3229  proceed,
3230  status;
3231 
3233  n;
3234 
3236  geometry;
3237 
3238  register const Image
3239  *next;
3240 
3241  size_t
3242  height,
3243  number_images,
3244  width;
3245 
3246  ssize_t
3247  x_offset,
3248  y_offset;
3249 
3250  /*
3251  Compute maximum area of smushed area.
3252  */
3253  assert(images != (Image *) NULL);
3254  assert(images->signature == MagickSignature);
3255  if (images->debug != MagickFalse)
3256  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3257  assert(exception != (ExceptionInfo *) NULL);
3258  assert(exception->signature == MagickSignature);
3259  image=images;
3260  matte=image->matte;
3261  number_images=1;
3262  width=image->columns;
3263  height=image->rows;
3264  next=GetNextImageInList(image);
3265  for ( ; next != (Image *) NULL; next=GetNextImageInList(next))
3266  {
3267  if (next->matte != MagickFalse)
3268  matte=MagickTrue;
3269  number_images++;
3270  if (stack != MagickFalse)
3271  {
3272  if (next->columns > width)
3273  width=next->columns;
3274  height+=next->rows;
3275  if (next->previous != (Image *) NULL)
3276  height+=offset;
3277  continue;
3278  }
3279  width+=next->columns;
3280  if (next->previous != (Image *) NULL)
3281  width+=offset;
3282  if (next->rows > height)
3283  height=next->rows;
3284  }
3285  /*
3286  Smush images.
3287  */
3288  smush_image=CloneImage(image,width,height,MagickTrue,exception);
3289  if (smush_image == (Image *) NULL)
3290  return((Image *) NULL);
3291  if (SetImageStorageClass(smush_image,DirectClass) == MagickFalse)
3292  {
3293  InheritException(exception,&smush_image->exception);
3294  smush_image=DestroyImage(smush_image);
3295  return((Image *) NULL);
3296  }
3297  smush_image->matte=matte;
3298  (void) SetImageBackgroundColor(smush_image);
3299  status=MagickTrue;
3300  x_offset=0;
3301  y_offset=0;
3302  smush_view=AcquireVirtualCacheView(smush_image,exception);
3303  for (n=0; n < (MagickOffsetType) number_images; n++)
3304  {
3305  SetGeometry(smush_image,&geometry);
3306  GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
3307  if (stack != MagickFalse)
3308  {
3309  x_offset-=geometry.x;
3310  y_offset-=SmushYGap(smush_image,image,offset,exception);
3311  }
3312  else
3313  {
3314  x_offset-=SmushXGap(smush_image,image,offset,exception);
3315  y_offset-=geometry.y;
3316  }
3317  status=CompositeImage(smush_image,OverCompositeOp,image,x_offset,y_offset);
3318  proceed=SetImageProgress(image,SmushImageTag,n,number_images);
3319  if (proceed == MagickFalse)
3320  break;
3321  if (stack == MagickFalse)
3322  {
3323  x_offset+=(ssize_t) image->columns;
3324  y_offset=0;
3325  }
3326  else
3327  {
3328  x_offset=0;
3329  y_offset+=(ssize_t) image->rows;
3330  }
3331  image=GetNextImageInList(image);
3332  }
3333  if (stack == MagickFalse)
3334  smush_image->columns=(size_t) x_offset;
3335  else
3336  smush_image->rows=(size_t) y_offset;
3337  smush_view=DestroyCacheView(smush_view);
3338  if (status == MagickFalse)
3339  smush_image=DestroyImage(smush_image);
3340  return(smush_image);
3341 }
3342 
3343 /*
3344 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3345 % %
3346 % %
3347 % %
3348 % S t r i p I m a g e %
3349 % %
3350 % %
3351 % %
3352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3353 %
3354 % StripImage() strips an image of all profiles and comments.
3355 %
3356 % The format of the StripImage method is:
3357 %
3358 % MagickBooleanType StripImage(Image *image)
3359 %
3360 % A description of each parameter follows:
3361 %
3362 % o image: the image.
3363 %
3364 */
3366 {
3368  status;
3369 
3370  assert(image != (Image *) NULL);
3371  if (image->debug != MagickFalse)
3372  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3373  DestroyImageProfiles(image);
3374  (void) DeleteImageProperty(image,"comment");
3375  (void) DeleteImageProperty(image,"date:create");
3376  (void) DeleteImageProperty(image,"date:modify");
3377  status=SetImageArtifact(image,"png:exclude-chunk",
3378  "EXIF,iCCP,iTXt,sRGB,tEXt,zCCP,zTXt,date");
3379  return(status);
3380 }
3381 
3382 /*
3383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3384 % %
3385 % %
3386 % %
3387 + S y n c I m a g e %
3388 % %
3389 % %
3390 % %
3391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3392 %
3393 % SyncImage() initializes the red, green, and blue intensities of each pixel
3394 % as defined by the colormap index.
3395 %
3396 % The format of the SyncImage method is:
3397 %
3398 % MagickBooleanType SyncImage(Image *image)
3399 %
3400 % A description of each parameter follows:
3401 %
3402 % o image: the image.
3403 %
3404 */
3405 
3406 static inline IndexPacket PushColormapIndex(Image *image,
3407  const size_t index,MagickBooleanType *range_exception)
3408 {
3409  if (index < image->colors)
3410  return((IndexPacket) index);
3411  *range_exception=MagickTrue;
3412  return((IndexPacket) 0);
3413 }
3414 
3416 {
3417  CacheView
3418  *image_view;
3419 
3421  *exception;
3422 
3424  range_exception,
3425  status,
3426  taint;
3427 
3428  ssize_t
3429  y;
3430 
3431  assert(image != (Image *) NULL);
3432  if (image->debug != MagickFalse)
3433  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3434  assert(image->signature == MagickSignature);
3435  if (image->storage_class == DirectClass)
3436  return(MagickFalse);
3437  range_exception=MagickFalse;
3438  status=MagickTrue;
3439  taint=image->taint;
3440  exception=(&image->exception);
3441  image_view=AcquireAuthenticCacheView(image,exception);
3442 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3443  #pragma omp parallel for schedule(static,4) shared(range_exception,status) \
3444  magick_threads(image,image,image->rows,1)
3445 #endif
3446  for (y=0; y < (ssize_t) image->rows; y++)
3447  {
3448  IndexPacket
3449  index;
3450 
3451  register IndexPacket
3452  *restrict indexes;
3453 
3454  register PixelPacket
3455  *restrict q;
3456 
3457  register ssize_t
3458  x;
3459 
3460  if (status == MagickFalse)
3461  continue;
3462  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3463  if (q == (PixelPacket *) NULL)
3464  {
3465  status=MagickFalse;
3466  continue;
3467  }
3468  indexes=GetCacheViewAuthenticIndexQueue(image_view);
3469  for (x=0; x < (ssize_t) image->columns; x++)
3470  {
3471  index=PushColormapIndex(image,(size_t) GetPixelIndex(indexes+x),
3472  &range_exception);
3473  if (image->matte == MagickFalse)
3474  SetPixelRgb(q,image->colormap+(ssize_t) index)
3475  else
3476  SetPixelRGBO(q,image->colormap+(ssize_t) index);
3477  q++;
3478  }
3479  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3480  status=MagickFalse;
3481  }
3482  image_view=DestroyCacheView(image_view);
3483  image->taint=taint;
3484  if ((image->ping == MagickFalse) && (range_exception != MagickFalse))
3486  CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
3487  return(status);
3488 }
3489 
3490 /*
3491 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3492 % %
3493 % %
3494 % %
3495 % S y n c I m a g e S e t t i n g s %
3496 % %
3497 % %
3498 % %
3499 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3500 %
3501 % SyncImageSettings() syncs image_info options into per-image attributes.
3502 %
3503 % The format of the SyncImageSettings method is:
3504 %
3505 % MagickBooleanType SyncImageSettings(const ImageInfo *image_info,
3506 % Image *image)
3507 % MagickBooleanType SyncImagesSettings(const ImageInfo *image_info,
3508 % Image *image)
3509 %
3510 % A description of each parameter follows:
3511 %
3512 % o image_info: the image info.
3513 %
3514 % o image: the image.
3515 %
3516 */
3517 
3519  Image *images)
3520 {
3521  Image
3522  *image;
3523 
3524  assert(image_info != (const ImageInfo *) NULL);
3525  assert(image_info->signature == MagickSignature);
3526  assert(images != (Image *) NULL);
3527  assert(images->signature == MagickSignature);
3528  if (images->debug != MagickFalse)
3529  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3530  image=images;
3531  for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
3532  (void) SyncImageSettings(image_info,image);
3533  (void) DeleteImageOption(image_info,"page");
3534  return(MagickTrue);
3535 }
3536 
3538  Image *image)
3539 {
3540  char
3541  property[MaxTextExtent];
3542 
3543  const char
3544  *option,
3545  *value;
3546 
3547  GeometryInfo
3548  geometry_info;
3549 
3551  flags;
3552 
3554  units;
3555 
3556  /*
3557  Sync image options.
3558  */
3559  assert(image_info != (const ImageInfo *) NULL);
3560  assert(image_info->signature == MagickSignature);
3561  assert(image != (Image *) NULL);
3562  assert(image->signature == MagickSignature);
3563  if (image->debug != MagickFalse)
3564  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3565  option=GetImageOption(image_info,"background");
3566  if (option != (const char *) NULL)
3567  (void) QueryColorDatabase(option,&image->background_color,
3568  &image->exception);
3569  option=GetImageOption(image_info,"bias");
3570  if (option != (const char *) NULL)
3571  image->bias=StringToDoubleInterval(option,(double) QuantumRange+1.0);
3572  option=GetImageOption(image_info,"black-point-compensation");
3573  if (option != (const char *) NULL)
3576  option=GetImageOption(image_info,"blue-primary");
3577  if (option != (const char *) NULL)
3578  {
3579  flags=ParseGeometry(option,&geometry_info);
3580  image->chromaticity.blue_primary.x=geometry_info.rho;
3581  image->chromaticity.blue_primary.y=geometry_info.sigma;
3582  if ((flags & SigmaValue) == 0)
3584  }
3585  option=GetImageOption(image_info,"bordercolor");
3586  if (option != (const char *) NULL)
3587  (void) QueryColorDatabase(option,&image->border_color,&image->exception);
3588  option=GetImageOption(image_info,"colors");
3589  if (option != (const char *) NULL)
3590  image->colors=StringToUnsignedLong(option);
3591  option=GetImageOption(image_info,"compose");
3592  if (option != (const char *) NULL)
3594  MagickFalse,option);
3595  option=GetImageOption(image_info,"compress");
3596  if (option != (const char *) NULL)
3599  option=GetImageOption(image_info,"debug");
3600  if (option != (const char *) NULL)
3602  MagickFalse,option);
3603  option=GetImageOption(image_info,"density");
3604  if (option != (const char *) NULL)
3605  {
3606  GeometryInfo
3607  geometry_info;
3608 
3609  /*
3610  Set image density.
3611  */
3612  flags=ParseGeometry(option,&geometry_info);
3613  image->x_resolution=geometry_info.rho;
3614  image->y_resolution=geometry_info.sigma;
3615  if ((flags & SigmaValue) == 0)
3616  image->y_resolution=image->x_resolution;
3617  }
3618  option=GetImageOption(image_info,"depth");
3619  if (option != (const char *) NULL)
3620  image->depth=StringToUnsignedLong(option);
3621  option=GetImageOption(image_info,"endian");
3622  if (option != (const char *) NULL)
3624  MagickFalse,option);
3625  option=GetImageOption(image_info,"filter");
3626  if (option != (const char *) NULL)
3628  MagickFalse,option);
3629  option=GetImageOption(image_info,"fuzz");
3630  if (option != (const char *) NULL)
3631  image->fuzz=StringToDoubleInterval(option,(double) QuantumRange+1.0);
3632  option=GetImageOption(image_info,"gravity");
3633  if (option != (const char *) NULL)
3635  MagickFalse,option);
3636  option=GetImageOption(image_info,"green-primary");
3637  if (option != (const char *) NULL)
3638  {
3639  flags=ParseGeometry(option,&geometry_info);
3640  image->chromaticity.green_primary.x=geometry_info.rho;
3641  image->chromaticity.green_primary.y=geometry_info.sigma;
3642  if ((flags & SigmaValue) == 0)
3644  }
3645  option=GetImageOption(image_info,"intensity");
3646  if (option != (const char *) NULL)
3649  option=GetImageOption(image_info,"intent");
3650  if (option != (const char *) NULL)
3653  option=GetImageOption(image_info,"interlace");
3654  if (option != (const char *) NULL)
3656  MagickFalse,option);
3657  option=GetImageOption(image_info,"interpolate");
3658  if (option != (const char *) NULL)
3661  option=GetImageOption(image_info,"loop");
3662  if (option != (const char *) NULL)
3663  image->iterations=StringToUnsignedLong(option);
3664  option=GetImageOption(image_info,"mattecolor");
3665  if (option != (const char *) NULL)
3666  (void) QueryColorDatabase(option,&image->matte_color,&image->exception);
3667  option=GetImageOption(image_info,"orient");
3668  if (option != (const char *) NULL)
3671  option=GetImageOption(image_info,"page");
3672  if (option != (const char *) NULL)
3673  {
3674  char
3675  *geometry;
3676 
3677  geometry=GetPageGeometry(option);
3678  flags=ParseAbsoluteGeometry(geometry,&image->page);
3679  geometry=DestroyString(geometry);
3680  }
3681  option=GetImageOption(image_info,"quality");
3682  if (option != (const char *) NULL)
3683  image->quality=StringToUnsignedLong(option);
3684  option=GetImageOption(image_info,"red-primary");
3685  if (option != (const char *) NULL)
3686  {
3687  flags=ParseGeometry(option,&geometry_info);
3688  image->chromaticity.red_primary.x=geometry_info.rho;
3689  image->chromaticity.red_primary.y=geometry_info.sigma;
3690  if ((flags & SigmaValue) == 0)
3692  }
3693  if (image_info->quality != UndefinedCompressionQuality)
3694  image->quality=image_info->quality;
3695  option=GetImageOption(image_info,"scene");
3696  if (option != (const char *) NULL)
3697  image->scene=StringToUnsignedLong(option);
3698  option=GetImageOption(image_info,"taint");
3699  if (option != (const char *) NULL)
3701  MagickFalse,option);
3702  option=GetImageOption(image_info,"tile-offset");
3703  if (option != (const char *) NULL)
3704  {
3705  char
3706  *geometry;
3707 
3708  geometry=GetPageGeometry(option);
3709  flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3710  geometry=DestroyString(geometry);
3711  }
3712  option=GetImageOption(image_info,"transparent-color");
3713  if (option != (const char *) NULL)
3714  (void) QueryColorDatabase(option,&image->transparent_color,
3715  &image->exception);
3716  option=GetImageOption(image_info,"type");
3717  if (option != (const char *) NULL)
3719  option);
3720  option=GetImageOption(image_info,"units");
3721  if (option != (const char *) NULL)
3723  MagickFalse,option);
3724  else
3725  units = image_info->units;
3726  if (units != UndefinedResolution)
3727  {
3728  if (image->units != units)
3729  switch (image->units)
3730  {
3732  {
3733  if (units == PixelsPerCentimeterResolution)
3734  {
3735  image->x_resolution/=2.54;
3736  image->y_resolution/=2.54;
3737  }
3738  break;
3739  }
3741  {
3742  if (units == PixelsPerInchResolution)
3743  {
3744  image->x_resolution=(double) ((size_t) (100.0*2.54*
3745  image->x_resolution+0.5))/100.0;
3746  image->y_resolution=(double) ((size_t) (100.0*2.54*
3747  image->y_resolution+0.5))/100.0;
3748  }
3749  break;
3750  }
3751  default:
3752  break;
3753  }
3754  image->units=units;
3755  }
3756  option=GetImageOption(image_info,"white-point");
3757  if (option != (const char *) NULL)
3758  {
3759  flags=ParseGeometry(option,&geometry_info);
3760  image->chromaticity.white_point.x=geometry_info.rho;
3761  image->chromaticity.white_point.y=geometry_info.sigma;
3762  if ((flags & SigmaValue) == 0)
3764  }
3765  ResetImageOptionIterator(image_info);
3766  for (option=GetNextImageOption(image_info); option != (const char *) NULL; )
3767  {
3768  value=GetImageOption(image_info,option);
3769  if (value != (const char *) NULL)
3770  {
3771  (void) FormatLocaleString(property,MaxTextExtent,"%s",option);
3772  (void) SetImageArtifact(image,property,value);
3773  }
3774  option=GetNextImageOption(image_info);
3775  }
3776  return(MagickTrue);
3777 }
size_t rows
Definition: image.h:174
MagickExport FILE * GetImageInfoFile(const ImageInfo *image_info)
Definition: image.c:1341
PixelIntensityMethod intensity
Definition: image.h:352
MagickExport CacheView * DestroyCacheView(CacheView *cache_view)
Definition: cache-view.c:254
double y_resolution
Definition: image.h:209
char filename[MaxTextExtent]
Definition: image.h:467
EndianType endian
Definition: image.h:387
MagickRealType opacity
Definition: pixel.h:122
#define GetPixelBlue(pixel)
size_t signature
Definition: image.h:486
struct _Image * list
Definition: image.h:309
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:1937
size_t subimage
Definition: image.h:479
MagickExport ImageInfo * AcquireImageInfo(void)
Definition: image.c:329
InterlaceType interlace
Definition: image.h:226
MagickExport void DestroyImagePixels(Image *image)
Definition: cache.c:799
#define GetPixelOpacity(pixel)
ColorspaceType colorspace
Definition: pixel.h:110
DisposeType dispose
Definition: image.h:238
size_t depth
Definition: pixel.h:119
Ascii85Info * ascii85
Definition: image.h:272
MagickProgressMonitor progress_monitor
Definition: image.h:264
char * scenes
Definition: image.h:373
ImageType type
Definition: image.h:334
size_t iterations
Definition: image.h:251
MagickExport ExceptionType CatchImageException(Image *image)
Definition: image.c:633
ssize_t ticks_per_second
Definition: image.h:248
size_t subrange
Definition: image.h:479
MagickExport SemaphoreInfo * AllocateSemaphoreInfo(void)
Definition: semaphore.c:191
MagickExport Image * ReferenceImage(Image *image)
Definition: image.c:2031
MagickExport MagickBooleanType DeleteImageOption(ImageInfo *image_info, const char *option)
Definition: option.c:1803
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:449
MagickExport void Ascii85Initialize(Image *image)
Definition: compress.c:268
double pointsize
Definition: image.h:403
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:2503
const char SaveImageTag[]
Definition: image.c:117
OrientationType
Definition: image.h:77
MagickBooleanType ping
Definition: image.h:343
char * extract
Definition: image.h:373
MagickExport MagickBooleanType SyncImagesSettings(ImageInfo *image_info, Image *images)
Definition: image.c:3518
#define ThrowFatalException(severity, tag)
double x
Definition: image.h:100
#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:3026
size_t number_scenes
Definition: image.h:379
char * sampling_factor
Definition: image.h:396
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:4874
MagickExport MagickStatusType ParseAbsoluteGeometry(const char *geometry, RectangleInfo *region_info)
Definition: geometry.c:664
MagickExport const char * GetMagicName(const MagicInfo *magic_info)
Definition: magic.c:590
EndianType endian
Definition: image.h:229
MagickBooleanType taint
Definition: image.h:170
MagickExport size_t ConcatenateMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:408
PixelIntensityMethod
Definition: pixel.h:67
MagickBooleanType debug
Definition: image.h:473
char * font
Definition: image.h:396
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:3537
MagickExport Cache ReferencePixelCache(Cache)
Definition: cache.c:4498
MagickPrivate MagickBooleanType SyncImagePixelCache(Image *, ExceptionInfo *)
Definition: cache.c:5119
InterlaceType
Definition: image.h:65
VirtualPixelMethod
Definition: cache-view.h:27
const char BorderColor[]
Definition: image.c:107
ColorspaceType colorspace
Definition: image.h:419
MagickExport const char * GetImageArtifact(const Image *image, const char *artifact)
Definition: artifact.c:266
char magick[MaxTextExtent]
Definition: image.h:278
double z
Definition: image.h:100
MagickBooleanType antialias
Definition: image.h:367
MagickPrivate void InitializeExceptionInfo(ExceptionInfo *)
Definition: exception.c:671
const char PSDensityGeometry[]
Definition: image.c:115
size_t colors
Definition: image.h:416
MagickExport MagickBooleanType SetImageBackgroundColor(Image *image)
Definition: image.c:2136
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:2365
static MagickBooleanType IsGrayColorspace(const ColorspaceType colorspace)
MagickExport void SetImageInfoBlob(ImageInfo *image_info, const void *blob, const size_t length)
Definition: image.c:2826
ResolutionType units
Definition: image.h:198
MagickExport MagickBooleanType SetImageChannels(Image *image, const size_t channels)
Definition: image.c:2244
size_t delay
Definition: image.h:244
size_t magick_rows
Definition: image.h:283
#define MAGICKCORE_QUANTUM_DEPTH
Definition: magick-type.h:28
MagickExport MagickBooleanType ImageToFile(Image *image, char *filename, ExceptionInfo *exception)
Definition: blob.c:1653
MagickExport MagickBooleanType SyncImage(Image *image)
Definition: image.c:3415
MagickBooleanType verbose
Definition: image.h:431
double bias
Definition: image.h:218
double blur
Definition: image.h:218
MagickExport char * GetPageGeometry(const char *page_geometry)
Definition: geometry.c:343
char magick_filename[MaxTextExtent]
Definition: image.h:278
Image * image
Definition: image-view.c:66
MagickFormatType format_type
Definition: magick.h:83
char * montage
Definition: image.h:201
CompressionType compression
Definition: image.h:161
double sigma
Definition: geometry.h:107
InterlaceType interlace
Definition: image.h:384
ClassType storage_class
Definition: image.h:155
char unique[MaxTextExtent]
Definition: image.h:467
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:327
#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:1838
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:373
MagickExport void SetImageInfoFile(ImageInfo *image_info, FILE *file)
Definition: image.c:2862
Definition: image.h:152
void * cache
Definition: image.h:451
MagickExport VirtualPixelMethod GetImageVirtualPixelMethod(const Image *image)
Definition: image.c:1472
ExceptionType
Definition: exception.h:28
ImageType type
Definition: image.h:422
#define SetPixelGreen(pixel, value)
const char SaveImagesTag[]
Definition: image.c:118
StreamHandler stream
Definition: image.h:455
FilterTypes
Definition: resample.h:32
static IndexPacket PushColormapIndex(Image *image, const size_t index, MagickBooleanType *range_exception)
Definition: image.c:3406
MagickExport MagickBooleanType TransformImageColorspace(Image *image, const ColorspaceType colorspace)
Definition: colorspace.c:1201
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:36
#define MagickSignature
MagickExport MagickBooleanType IsGeometry(const char *geometry)
Definition: geometry.c:571
MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, const AlphaChannelType alpha_type)
Definition: channel.c:640
char magick[MaxTextExtent]
Definition: image.h:467
MagickExport Image * GetImageClipMask(const Image *image, ExceptionInfo *exception)
Definition: image.c:1201
MagickExport Image * BlobToImage(const ImageInfo *image_info, const void *blob, const size_t length, ExceptionInfo *exception)
Definition: blob.c:316
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:3071
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1191
ChannelType channel
Definition: image.h:439
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:278
MagickExport Image * NewImageList(void)
Definition: list.c:918
PrimaryInfo red_primary
Definition: image.h:126
size_t scene
Definition: image.h:244
unsigned int MagickStatusType
Definition: magick-type.h:147
MagickExport char * AcquireString(const char *source)
Definition: string.c:120
MagickExport MagickBooleanType StripImage(Image *image)
Definition: image.c:3365
ClassType
Definition: magick-type.h:204
MagickExport void GetMagickPixelPacket(const Image *image, MagickPixelPacket *pixel)
Definition: pixel.c:2226
ExceptionInfo * exception
Definition: image-view.c:75
MagickExport const char * GetImageProperty(const Image *image, const char *property)
Definition: property.c:2048
const char PSPageGeometry[]
Definition: image.c:116
MagickBooleanType black_point_compensation
Definition: image.h:318
MagickExport MagickBooleanType IsImageObject(const Image *image)
Definition: image.c:1796
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:321
size_t length
Definition: image.h:464
MagickExport MagickBooleanType IsMagickConflict(const char *)
MagickExport StringInfo * DestroyStringInfo(StringInfo *string_info)
Definition: string.c:836
MagickExport MagickBooleanType CompositeImage(Image *image, const CompositeOperator compose, const Image *source_image, const ssize_t x_offset, const ssize_t y_offset)
Definition: composite.c:1606
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:529
VirtualPixelMethod virtual_pixel_method
Definition: image.h:489
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:461
const char BackgroundColor[]
Definition: image.c:106
double fuzz
Definition: image.h:403
#define MaxTextExtent
GravityType gravity
Definition: image.h:232
MagickExport MagickBooleanType CloseBlob(Image *)
volatile ssize_t reference_count
Definition: image.h:293
size_t scene
Definition: image.h:379
RectangleInfo page
Definition: image.h:213
size_t channels
Definition: image.h:346
MagickExport void DestroyImageProperties(Image *image)
Definition: property.c:306
size_t magick_columns
Definition: image.h:283
#define UndefinedCompressionQuality
Definition: image-private.h:37
PixelPacket border_color
Definition: image.h:180
ResolutionType units
Definition: image.h:390
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: string.c:1524
const char LoadImagesTag[]
Definition: image.c:113
MagickExport MagickBooleanType IsStringTrue(const char *value)
Definition: string.c:1437
MagickExport MagickBooleanType IsEventLogging(void)
Definition: log.c:684
void * cache
Definition: image.h:267
#define SetPixelRed(pixel, value)
CompressionType compression
Definition: image.h:361
const char DefaultTileLabel[]
Definition: image.c:110
PrimaryInfo blue_primary
Definition: image.h:126
#define ThrowFileException(exception, severity, tag, context)
OrientationType orientation
Definition: image.h:364
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:3832
Quantum opacity
Definition: pixel.h:143
MagickBooleanType monochrome
Definition: image.h:412
#define TransparentOpacity
Definition: image.h:28
PixelPacket matte_color
Definition: image.h:407
MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1379
MagickExport const char * GetImageOption(const ImageInfo *image_info, const char *key)
Definition: option.c:1874
MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info, const unsigned int frames, ExceptionInfo *exception)
Definition: image.c:2494
GravityType
Definition: geometry.h:77
MagickBooleanType dither
Definition: image.h:337
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:1047
PixelPacket pen
Definition: image.h:483
struct _Image * mask
Definition: image.h:323
MagickExport MagickOffsetType SeekBlob(Image *, const MagickOffsetType, const int)
size_t signature
Definition: image.h:307
MagickExport int LocaleNCompare(const char *p, const char *q, const size_t length)
Definition: string.c:1624
MagickExport VirtualPixelMethod GetPixelCacheVirtualMethod(const Image *image)
Definition: cache.c:2283
size_t columns
Definition: image.h:174
#define SetPixelRGBO(pixel, packet)
PreviewType preview_type
Definition: image.h:425
PixelPacket background_color
Definition: image.h:180
MagickExport size_t InterpretImageFilename(const ImageInfo *image_info, Image *image, const char *format, int value, char *filename)
Definition: image.c:1514
MagickExport const MagickInfo * GetMagickInfo(const char *name, ExceptionInfo *exception)
Definition: magick.c:403
MagickExport Image * SmushImages(const Image *images, const MagickBooleanType stack, const ssize_t offset, ExceptionInfo *exception)
Definition: image.c:3213
MagickExport MagickBooleanType OpenBlob(const ImageInfo *, Image *, const BlobMode, ExceptionInfo *)
MagickExport MagickBooleanType GetMagickAdjoin(const MagickInfo *magick_info)
Definition: magick.c:276
ssize_t x
Definition: geometry.h:128
MagickExport char * GetEnvironmentValue(const char *name)
Definition: string.c:1223
SemaphoreInfo * semaphore
Definition: image.h:296
char zero[MaxTextExtent]
Definition: image.h:467
static void ConvertRGBToCMYK(MagickPixelPacket *pixel)
struct _Image * next
Definition: image.h:309
MagickExport void ResetImageOptionIterator(const ImageInfo *image_info)
Definition: option.c:2684
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:739
ssize_t offset
Definition: image.h:206
RectangleInfo extract_info
Definition: image.h:213
MagickExport MagickBooleanType ResetImagePage(Image *image, const char *page)
Definition: image.c:2067
MagickExport MagickBooleanType GetMagickEndianSupport(const MagickInfo *magick_info)
Definition: magick.c:368
MagickExport MagickBooleanType IsBlobSeekable(const Image *image)
Definition: blob.c:2095
char * texture
Definition: image.h:396
PixelPacket border_color
Definition: image.h:407
#define SetPixelOpacity(pixel, value)
RenderingIntent
Definition: profile.h:42
double y
Definition: image.h:100
static MagickBooleanType IsPixelGray(const PixelPacket *pixel)
size_t quality
Definition: image.h:164
size_t colors
Definition: image.h:174
MagickExport MagickBooleanType SetImageExtent(Image *image, const size_t columns, const size_t rows)
Definition: image.c:2450
TimerInfo timer
Definition: image.h:261
static void SetMagickPixelPacket(const Image *image, const PixelPacket *color, const IndexPacket *index, MagickPixelPacket *pixel)
Definition: pixel-private.h:92
MagickBooleanType matte
Definition: image.h:170
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:471
#define GetMagickModule()
Definition: log.h:29
PrimaryInfo green_primary
Definition: image.h:126
MagickFormatType
Definition: magick.h:28
PixelPacket background_color
Definition: image.h:407
MagickExport void GetTimerInfo(TimerInfo *time_info)
Definition: timer.c:262
size_t quality
Definition: image.h:393
MagickBooleanType affirm
Definition: image.h:367
#define ThrowImageException(severity, tag)
MagickExport CacheView * AcquireVirtualCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:154
PrimaryInfo white_point
Definition: image.h:126
void * client_data
Definition: image.h:451
MagickBooleanType matte
Definition: pixel.h:113
char * density
Definition: image.h:396
static double StringToDoubleInterval(const char *string, const double interval)
MagickExport ImageInfo * DestroyImageInfo(ImageInfo *image_info)
Definition: image.c:1103
CompressionType
Definition: compress.h:25
RenderingIntent rendering_intent
Definition: image.h:192
MagickExport Image * AppendImages(const Image *images, const MagickBooleanType stack, ExceptionInfo *exception)
Definition: image.c:425
MagickExport MagickBooleanType IsTaintImage(const Image *image)
Definition: image.c:1833
MagickExport MagickBooleanType CloneImageOptions(ImageInfo *image_info, const ImageInfo *clone_info)
Definition: option.c:1710
const char MatteColor[]
Definition: image.c:114
MagickExport void ClonePixelCacheMethods(Cache, const Cache)
MagickBooleanType synchronize
Definition: image.h:498
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:1682
#define OpaqueOpacity
Definition: image.h:27
struct _Image * previous
Definition: image.h:309
PixelPacket transparent_color
Definition: image.h:492
char * server_name
Definition: image.h:396
MagickExport void DestroyImageArtifacts(Image *image)
Definition: artifact.c:229
MagickExport Image * GetImageMask(const Image *image, ExceptionInfo *exception)
Definition: image.c:1368
MagickExport MagickBooleanType QueryColorDatabase(const char *name, PixelPacket *color, ExceptionInfo *exception)
Definition: color.c:2479
MagickExport size_t GetImageChannels(Image *image)
Definition: image.c:1402
MagickExport Image * GetNextImageInList(const Image *images)
Definition: list.c:754
MagickExport char * DestroyString(char *string)
Definition: string.c:809
MagickExport void * AcquireMagickMemory(const size_t size)
Definition: memory.c:458
PixelPacket matte_color
Definition: image.h:180
double x_resolution
Definition: image.h:209
char * geometry
Definition: image.h:201
MagickExport MagickBooleanType DeleteImageProperty(Image *image, const char *property)
Definition: property.c:270
MagickExport MagickBooleanType ModifyImage(Image **image, ExceptionInfo *exception)
Definition: image.c:1886
MagickExport MagickBooleanType IsBlobExempt(const Image *image)
Definition: blob.c:2064
MagickPrivate void DisassociateBlob(Image *)
Definition: blob.c:730
MagickExport ImageInfo * CloneImageInfo(const ImageInfo *image_info)
Definition: image.c:934
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:349
MagickExport MagickStatusType ParseGeometry(const char *geometry, GeometryInfo *geometry_info)
Definition: geometry.c:814
MagickBooleanType dither
Definition: image.h:412
#define SetPixelIndex(indexes, value)
char * directory
Definition: image.h:201
ChromaticityInfo chromaticity
Definition: image.h:189
char * authenticate
Definition: image.h:435
BlobInfo * blob
Definition: image.h:275
FILE * file
Definition: image.h:458
static void SetPixelPacket(const Image *image, const MagickPixelPacket *pixel, PixelPacket *color, IndexPacket *index)
MagickExport void SetGeometry(const Image *image, RectangleInfo *geometry)
Definition: geometry.c:1532
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:1281
MagickExport MagickBooleanType SetImageOpacity(Image *image, const Quantum opacity)
Definition: image.c:2944
MagickExport MagickBooleanType IsHighDynamicRangeImage(const Image *image, ExceptionInfo *exception)
Definition: image.c:1684
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:951
MagickExport void GetImageException(Image *image, ExceptionInfo *exception)
Definition: image.c:1238
MagickExport const char * GetMagickProperty(const ImageInfo *image_info, Image *image, const char *property)
Definition: property.c:2719
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:180
ImageType
Definition: image.h:49
MagickExport void GravityAdjustGeometry(const size_t width, const size_t height, const GravityType gravity, RectangleInfo *region)
Definition: geometry.c:490
MagickExport char * CloneString(char **destination, const char *source)
Definition: string.c:268
#define Swap(x, y)
Definition: studio.h:364
MagickExport BlobInfo * ReferenceBlob(BlobInfo *)
Definition: blob.c:3669
MagickExport MagickBooleanType CloneImageArtifacts(Image *image, const Image *clone_image)
Definition: artifact.c:100
MagickExport MagickBooleanType NegateImage(Image *image, const MagickBooleanType grayscale)
Definition: enhance.c:3957
CompositeOperator compose
Definition: image.h:235
MagickRealType blue
Definition: pixel.h:122
CompositeOperator
Definition: composite.h:25
ResolutionType
Definition: image.h:90
MagickExport Cache ClonePixelCache(const Cache)
#define MagickExport
char * view
Definition: image.h:435
OrientationType orientation
Definition: image.h:167
MagickProgressMonitor progress_monitor
Definition: image.h:448
double fuzz
Definition: image.h:218
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:624
struct _Image * clip_mask
Definition: image.h:240
static ssize_t SmushYGap(const Image *smush_image, const Image *images, const ssize_t offset, ExceptionInfo *exception)
Definition: image.c:3142
Quantum IndexPacket
Definition: pixel.h:129
MagickExport MagickBooleanType SetImageColor(Image *image, const MagickPixelPacket *color)
Definition: image.c:2276
MagickBooleanType adjoin
Definition: image.h:367
char * page
Definition: image.h:373
MagickBooleanType ping
Definition: image.h:431
MagickExport MagickBooleanType IsSceneGeometry(const char *geometry, const MagickBooleanType pedantic)
Definition: geometry.c:612
MagickExport MagickBooleanType SetImageClipMask(Image *image, const Image *clip_mask)
Definition: image.c:2399
#define AppendImageTag
#define SetPixelBlue(pixel, value)
MagickExport char * GetNextImageOption(const ImageInfo *image_info)
Definition: option.c:2137
ssize_t group
Definition: image.h:428
MagickSizeType QuantumAny
Definition: magick-type.h:170
void * client_data
Definition: image.h:267
MagickExport MagickBooleanType SetImageMask(Image *image, const Image *mask)
Definition: image.c:2897
MagickExport Image * DestroyImage(Image *image)
Definition: image.c:1030
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:1433
double gamma
Definition: image.h:186
ColorspaceType colorspace
Definition: image.h:158
MagickPrivate MagickBooleanType ClearExceptionInfo(ExceptionInfo *, MagickBooleanType)
Definition: exception.c:404
MagickExport StringInfo * CloneStringInfo(const StringInfo *string_info)
Definition: string.c:320
MagickExport void DisassociateImageStream(Image *image)
Definition: image.c:1170
#define QuantumRange
Definition: magick-type.h:94
MagickBooleanType temporary
Definition: image.h:367
MagickBooleanType debug
Definition: image.h:290
size_t depth
Definition: image.h:379
void * profile
Definition: image.h:495
MagickExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
Definition: exception.c:431
ExceptionInfo exception
Definition: image.h:287
InterpolatePixelMethod interpolate
Definition: image.h:315
MagickExport void InheritException(ExceptionInfo *exception, const ExceptionInfo *relative)
Definition: exception.c:623
size_t depth
Definition: image.h:174
FilterTypes filter
Definition: image.h:223
ExceptionType severity
Definition: exception.h:105