MagickCore  6.9.0
image.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % IIIII M M AAA GGGG EEEEE %
7 % I MM MM A A G E %
8 % I M M M AAAAA G GG EEE %
9 % I M M A A G G E %
10 % IIIII M M A A GGGG EEEEE %
11 % %
12 % %
13 % MagickCore Image Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % July 1992 %
18 % %
19 % %
20 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
22 % %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
25 % %
26 % http://www.imagemagick.org/script/license.php %
27 % %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
33 % %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 %
38 */
39 
40 /*
41  Include declarations.
42 */
43 #include "magick/studio.h"
44 #include "magick/animate.h"
45 #include "magick/artifact.h"
46 #include "magick/blob.h"
47 #include "magick/blob-private.h"
48 #include "magick/cache.h"
49 #include "magick/cache-private.h"
50 #include "magick/cache-view.h"
51 #include "magick/channel.h"
52 #include "magick/client.h"
53 #include "magick/color.h"
54 #include "magick/color-private.h"
55 #include "magick/colormap.h"
56 #include "magick/colorspace.h"
58 #include "magick/composite.h"
60 #include "magick/compress.h"
61 #include "magick/constitute.h"
62 #include "magick/deprecate.h"
63 #include "magick/display.h"
64 #include "magick/draw.h"
65 #include "magick/enhance.h"
66 #include "magick/exception.h"
68 #include "magick/gem.h"
69 #include "magick/geometry.h"
70 #include "magick/histogram.h"
71 #include "magick/image-private.h"
72 #include "magick/list.h"
73 #include "magick/magic.h"
74 #include "magick/magick.h"
75 #include "magick/memory_.h"
76 #include "magick/module.h"
77 #include "magick/monitor.h"
78 #include "magick/monitor-private.h"
79 #include "magick/option.h"
80 #include "magick/paint.h"
81 #include "magick/pixel-accessor.h"
82 #include "magick/pixel-private.h"
83 #include "magick/profile.h"
84 #include "magick/property.h"
85 #include "magick/quantize.h"
86 #include "magick/random_.h"
87 #include "magick/resource_.h"
88 #include "magick/segment.h"
89 #include "magick/semaphore.h"
91 #include "magick/statistic.h"
92 #include "magick/string_.h"
93 #include "magick/string-private.h"
94 #include "magick/thread-private.h"
95 #include "magick/threshold.h"
96 #include "magick/timer.h"
97 #include "magick/token.h"
98 #include "magick/utility.h"
99 #include "magick/version.h"
100 #include "magick/xwindow-private.h"
101 
102 /*
103  Constant declaration.
104 */
105 const char
106  BackgroundColor[] = "#ffffff", /* white */
107  BorderColor[] = "#dfdfdf", /* gray */
108  DefaultTileFrame[] = "15x15+3+3",
109  DefaultTileGeometry[] = "120x120+4+3>",
110  DefaultTileLabel[] = "%f\n%G\n%b",
111  ForegroundColor[] = "#000", /* black */
112  LoadImageTag[] = "Load/Image",
113  LoadImagesTag[] = "Load/Images",
114  MatteColor[] = "#bdbdbd", /* gray */
115  PSDensityGeometry[] = "72.0x72.0",
116  PSPageGeometry[] = "612x792",
117  SaveImageTag[] = "Save/Image",
118  SaveImagesTag[] = "Save/Images",
119  TransparentColor[] = "#00000000"; /* transparent black */
120 
121 const double
123 
124 /*
125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126 % %
127 % %
128 % %
129 % A c q u i r e I m a g e %
130 % %
131 % %
132 % %
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 %
135 % AcquireImage() returns a pointer to an image structure initialized to
136 % default values.
137 %
138 % The format of the AcquireImage method is:
139 %
140 % Image *AcquireImage(const ImageInfo *image_info)
141 %
142 % A description of each parameter follows:
143 %
144 % o image_info: Many of the image default values are set from this
145 % structure. For example, filename, compression, depth, background color,
146 % and others.
147 %
148 */
150 {
151  const char
152  *option;
153 
154  Image
155  *image;
156 
158  flags;
159 
160  /*
161  Allocate image structure.
162  */
163  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
164  image=(Image *) AcquireMagickMemory(sizeof(*image));
165  if (image == (Image *) NULL)
166  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
167  (void) ResetMagickMemory(image,0,sizeof(*image));
168  /*
169  Initialize Image structure.
170  */
171  (void) CopyMagickString(image->magick,"MIFF",MaxTextExtent);
172  image->storage_class=DirectClass;
174  image->colorspace=sRGBColorspace;
176  image->gamma=1.000f/2.200f;
177  image->chromaticity.red_primary.x=0.6400f;
178  image->chromaticity.red_primary.y=0.3300f;
179  image->chromaticity.red_primary.z=0.0300f;
180  image->chromaticity.green_primary.x=0.3000f;
181  image->chromaticity.green_primary.y=0.6000f;
182  image->chromaticity.green_primary.z=0.1000f;
183  image->chromaticity.blue_primary.x=0.1500f;
184  image->chromaticity.blue_primary.y=0.0600f;
185  image->chromaticity.blue_primary.z=0.7900f;
186  image->chromaticity.white_point.x=0.3127f;
187  image->chromaticity.white_point.y=0.3290f;
188  image->chromaticity.white_point.z=0.3583f;
189  image->interlace=NoInterlace;
191  image->compose=OverCompositeOp;
192  image->blur=1.0;
195  &image->exception);
196  (void) QueryColorDatabase(BorderColor,&image->border_color,&image->exception);
197  (void) QueryColorDatabase(MatteColor,&image->matte_color,&image->exception);
199  &image->exception);
200  GetTimerInfo(&image->timer);
201  image->ping=MagickFalse;
202  image->cache=AcquirePixelCache(0);
203  image->blob=CloneBlobInfo((BlobInfo *) NULL);
204  image->timestamp=time((time_t *) NULL);
205  image->debug=IsEventLogging();
206  image->reference_count=1;
208  image->signature=MagickSignature;
209  if (image_info == (ImageInfo *) NULL)
210  return(image);
211  /*
212  Transfer image info.
213  */
214  SetBlobExempt(image,image_info->file != (FILE *) NULL ? MagickTrue :
215  MagickFalse);
216  (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
217  (void) CopyMagickString(image->magick_filename,image_info->filename,
218  MaxTextExtent);
219  (void) CopyMagickString(image->magick,image_info->magick,MaxTextExtent);
220  if (image_info->size != (char *) NULL)
221  {
222  (void) ParseAbsoluteGeometry(image_info->size,&image->extract_info);
223  image->columns=image->extract_info.width;
224  image->rows=image->extract_info.height;
225  image->offset=image->extract_info.x;
226  image->extract_info.x=0;
227  image->extract_info.y=0;
228  }
229  if (image_info->extract != (char *) NULL)
230  {
232  geometry;
233 
234  flags=ParseAbsoluteGeometry(image_info->extract,&geometry);
235  if (((flags & XValue) != 0) || ((flags & YValue) != 0))
236  {
237  image->extract_info=geometry;
238  Swap(image->columns,image->extract_info.width);
239  Swap(image->rows,image->extract_info.height);
240  }
241  }
242  image->compression=image_info->compression;
243  image->quality=image_info->quality;
244  image->endian=image_info->endian;
245  image->interlace=image_info->interlace;
246  image->units=image_info->units;
247  if (image_info->density != (char *) NULL)
248  {
250  geometry_info;
251 
252  flags=ParseGeometry(image_info->density,&geometry_info);
253  image->x_resolution=geometry_info.rho;
254  image->y_resolution=geometry_info.sigma;
255  if ((flags & SigmaValue) == 0)
256  image->y_resolution=image->x_resolution;
257  }
258  if (image_info->page != (char *) NULL)
259  {
260  char
261  *geometry;
262 
263  image->page=image->extract_info;
264  geometry=GetPageGeometry(image_info->page);
265  (void) ParseAbsoluteGeometry(geometry,&image->page);
266  geometry=DestroyString(geometry);
267  }
268  if (image_info->depth != 0)
269  image->depth=image_info->depth;
270  image->dither=image_info->dither;
271  image->background_color=image_info->background_color;
272  image->border_color=image_info->border_color;
273  image->matte_color=image_info->matte_color;
274  image->transparent_color=image_info->transparent_color;
275  image->ping=image_info->ping;
276  image->progress_monitor=image_info->progress_monitor;
277  image->client_data=image_info->client_data;
278  if (image_info->cache != (void *) NULL)
279  ClonePixelCacheMethods(image->cache,image_info->cache);
280  (void) SyncImageSettings(image_info,image);
281  option=GetImageOption(image_info,"delay");
282  if (option != (const char *) NULL)
283  {
285  geometry_info;
286 
287  flags=ParseGeometry(option,&geometry_info);
288  if ((flags & GreaterValue) != 0)
289  {
290  if (image->delay > (size_t) floor(geometry_info.rho+0.5))
291  image->delay=(size_t) floor(geometry_info.rho+0.5);
292  }
293  else
294  if ((flags & LessValue) != 0)
295  {
296  if (image->delay < (size_t) floor(geometry_info.rho+0.5))
297  image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
298  }
299  else
300  image->delay=(size_t) floor(geometry_info.rho+0.5);
301  if ((flags & SigmaValue) != 0)
302  image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
303  }
304  option=GetImageOption(image_info,"dispose");
305  if (option != (const char *) NULL)
307  MagickFalse,option);
308  return(image);
309 }
310 
311 /*
312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
313 % %
314 % %
315 % %
316 % A c q u i r e I m a g e I n f o %
317 % %
318 % %
319 % %
320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
321 %
322 % AcquireImageInfo() allocates the ImageInfo structure.
323 %
324 % The format of the AcquireImageInfo method is:
325 %
326 % ImageInfo *AcquireImageInfo(void)
327 %
328 */
330 {
331  ImageInfo
332  *image_info;
333 
334  image_info=(ImageInfo *) AcquireMagickMemory(sizeof(*image_info));
335  if (image_info == (ImageInfo *) NULL)
336  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
337  GetImageInfo(image_info);
338  return(image_info);
339 }
340 
341 /*
342 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
343 % %
344 % %
345 % %
346 % A c q u i r e N e x t I m a g e %
347 % %
348 % %
349 % %
350 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
351 %
352 % AcquireNextImage() initializes the next image in a sequence to
353 % default values. The next member of image points to the newly allocated
354 % image. If there is a memory shortage, next is assigned NULL.
355 %
356 % The format of the AcquireNextImage method is:
357 %
358 % void AcquireNextImage(const ImageInfo *image_info,Image *image)
359 %
360 % A description of each parameter follows:
361 %
362 % o image_info: Many of the image default values are set from this
363 % structure. For example, filename, compression, depth, background color,
364 % and others.
365 %
366 % o image: the image.
367 %
368 */
370 {
371  /*
372  Allocate image structure.
373  */
374  assert(image != (Image *) NULL);
375  assert(image->signature == MagickSignature);
376  if (image->debug != MagickFalse)
377  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
378  image->next=AcquireImage(image_info);
379  if (GetNextImageInList(image) == (Image *) NULL)
380  return;
382  MaxTextExtent);
383  if (image_info != (ImageInfo *) NULL)
384  (void) CopyMagickString(GetNextImageInList(image)->filename,
385  image_info->filename,MaxTextExtent);
387  image->next->blob=ReferenceBlob(image->blob);
388  image->next->endian=image->endian;
389  image->next->scene=image->scene+1;
390  image->next->previous=image;
391 }
392 
393 /*
394 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
395 % %
396 % %
397 % %
398 % A p p e n d I m a g e s %
399 % %
400 % %
401 % %
402 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
403 %
404 % AppendImages() takes all images from the current image pointer to the end
405 % of the image list and appends them to each other top-to-bottom if the
406 % stack parameter is true, otherwise left-to-right.
407 %
408 % The current gravity setting now effects how the image is justified in the
409 % final image.
410 %
411 % The format of the AppendImages method is:
412 %
413 % Image *AppendImages(const Image *images,const MagickBooleanType stack,
414 % ExceptionInfo *exception)
415 %
416 % A description of each parameter follows:
417 %
418 % o images: the image sequence.
419 %
420 % o stack: A value other than 0 stacks the images top-to-bottom.
421 %
422 % o exception: return any errors or warnings in this structure.
423 %
424 */
427 {
428 #define AppendImageTag "Append/Image"
429 
430  CacheView
431  *append_view;
432 
433  Image
434  *append_image;
435 
437  matte,
438  status;
439 
441  n;
442 
444  geometry;
445 
446  register const Image
447  *next;
448 
449  size_t
450  height,
451  number_images,
452  width;
453 
454  ssize_t
455  x_offset,
456  y,
457  y_offset;
458 
459  /*
460  Compute maximum area of appended area.
461  */
462  assert(images != (Image *) NULL);
463  assert(images->signature == MagickSignature);
464  if (images->debug != MagickFalse)
465  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
466  assert(exception != (ExceptionInfo *) NULL);
467  assert(exception->signature == MagickSignature);
468  matte=images->matte;
469  number_images=1;
470  width=images->columns;
471  height=images->rows;
472  next=GetNextImageInList(images);
473  for ( ; next != (Image *) NULL; next=GetNextImageInList(next))
474  {
475  if (next->matte != MagickFalse)
476  matte=MagickTrue;
477  number_images++;
478  if (stack != MagickFalse)
479  {
480  if (next->columns > width)
481  width=next->columns;
482  height+=next->rows;
483  continue;
484  }
485  width+=next->columns;
486  if (next->rows > height)
487  height=next->rows;
488  }
489  /*
490  Append images.
491  */
492  append_image=CloneImage(images,width,height,MagickTrue,exception);
493  if (append_image == (Image *) NULL)
494  return((Image *) NULL);
495  if (SetImageStorageClass(append_image,DirectClass) == MagickFalse)
496  {
497  InheritException(exception,&append_image->exception);
498  append_image=DestroyImage(append_image);
499  return((Image *) NULL);
500  }
501  append_image->matte=matte;
502  (void) SetImageBackgroundColor(append_image);
503  status=MagickTrue;
504  x_offset=0;
505  y_offset=0;
506  next=images;
507  append_view=AcquireAuthenticCacheView(append_image,exception);
508  for (n=0; n < (MagickOffsetType) number_images; n++)
509  {
510  CacheView
511  *image_view;
512 
513  Image
514  *image;
515 
517  proceed;
518 
519  image=CloneImage(next,0,0,MagickTrue,exception);
520  if (image == (Image *) NULL)
521  break;
522  status=TransformImageColorspace(image,append_image->colorspace);
523  if (status == MagickFalse)
524  break;
525  SetGeometry(append_image,&geometry);
526  GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
527  if (stack != MagickFalse)
528  x_offset-=geometry.x;
529  else
530  y_offset-=geometry.y;
531  image_view=AcquireVirtualCacheView(image,exception);
532 #if defined(MAGICKCORE_OPENMP_SUPPORT)
533  #pragma omp parallel for schedule(static,4) shared(status) \
534  magick_threads(image,image,image->rows,1)
535 #endif
536  for (y=0; y < (ssize_t) image->rows; y++)
537  {
539  sync;
540 
541  register const IndexPacket
542  *restrict indexes;
543 
544  register const PixelPacket
545  *restrict p;
546 
547  register IndexPacket
548  *restrict append_indexes;
549 
550  register PixelPacket
551  *restrict q;
552 
553  register ssize_t
554  x;
555 
556  if (status == MagickFalse)
557  continue;
558  p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
559  q=QueueCacheViewAuthenticPixels(append_view,x_offset,y+y_offset,
560  image->columns,1,exception);
561  if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
562  {
563  status=MagickFalse;
564  continue;
565  }
566  indexes=GetCacheViewVirtualIndexQueue(image_view);
567  append_indexes=GetCacheViewAuthenticIndexQueue(append_view);
568  for (x=0; x < (ssize_t) image->columns; x++)
569  {
570  SetPixelRed(q,GetPixelRed(p));
574  if (image->matte != MagickFalse)
576  if ((image->colorspace == CMYKColorspace) &&
577  (append_image->colorspace == CMYKColorspace))
578  SetPixelIndex(append_indexes+x,GetPixelIndex(indexes+x));
579  p++;
580  q++;
581  }
582  sync=SyncCacheViewAuthenticPixels(append_view,exception);
583  if (sync == MagickFalse)
584  status=MagickFalse;
585  }
586  image_view=DestroyCacheView(image_view);
587  if (stack == MagickFalse)
588  {
589  x_offset+=(ssize_t) image->columns;
590  y_offset=0;
591  }
592  else
593  {
594  x_offset=0;
595  y_offset+=(ssize_t) image->rows;
596  }
597  image=DestroyImage(image);
598  proceed=SetImageProgress(append_image,AppendImageTag,n,number_images);
599  if (proceed == MagickFalse)
600  break;
601  next=GetNextImageInList(next);
602  }
603  append_view=DestroyCacheView(append_view);
604  if (status == MagickFalse)
605  append_image=DestroyImage(append_image);
606  return(append_image);
607 }
608 
609 /*
610 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
611 % %
612 % %
613 % %
614 % C a t c h I m a g e E x c e p t i o n %
615 % %
616 % %
617 % %
618 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 %
620 % CatchImageException() returns if no exceptions are found in the image
621 % sequence, otherwise it determines the most severe exception and reports
622 % it as a warning or error depending on the severity.
623 %
624 % The format of the CatchImageException method is:
625 %
626 % ExceptionType CatchImageException(Image *image)
627 %
628 % A description of each parameter follows:
629 %
630 % o image: An image sequence.
631 %
632 */
634 {
636  *exception;
637 
639  severity;
640 
641  assert(image != (const Image *) NULL);
642  assert(image->signature == MagickSignature);
643  if (image->debug != MagickFalse)
644  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
645  exception=AcquireExceptionInfo();
646  GetImageException(image,exception);
647  CatchException(exception);
648  severity=exception->severity;
649  exception=DestroyExceptionInfo(exception);
650  return(severity);
651 }
652 
653 /*
654 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
655 % %
656 % %
657 % %
658 % C l i p I m a g e P a t h %
659 % %
660 % %
661 % %
662 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
663 %
664 % ClipImagePath() sets the image clip mask based any clipping path information
665 % if it exists.
666 %
667 % The format of the ClipImagePath method is:
668 %
669 % MagickBooleanType ClipImagePath(Image *image,const char *pathname,
670 % const MagickBooleanType inside)
671 %
672 % A description of each parameter follows:
673 %
674 % o image: the image.
675 %
676 % o pathname: name of clipping path resource. If name is preceded by #, use
677 % clipping path numbered by name.
678 %
679 % o inside: if non-zero, later operations take effect inside clipping path.
680 % Otherwise later operations take effect outside clipping path.
681 %
682 */
683 
685 {
686  return(ClipImagePath(image,"#1",MagickTrue));
687 }
688 
690  const MagickBooleanType inside)
691 {
692 #define ClipImagePathTag "ClipPath/Image"
693 
694  char
695  *property;
696 
697  const char
698  *value;
699 
700  Image
701  *clip_mask;
702 
703  ImageInfo
704  *image_info;
705 
706  assert(image != (const Image *) NULL);
707  assert(image->signature == MagickSignature);
708  if (image->debug != MagickFalse)
709  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
710  assert(pathname != NULL);
711  property=AcquireString(pathname);
712  (void) FormatLocaleString(property,MaxTextExtent,"8BIM:1999,2998:%s",
713  pathname);
714  value=GetImageProperty(image,property);
715  property=DestroyString(property);
716  if (value == (const char *) NULL)
717  {
718  ThrowFileException(&image->exception,OptionError,"NoClipPathDefined",
719  image->filename);
720  return(MagickFalse);
721  }
722  image_info=AcquireImageInfo();
723  (void) CopyMagickString(image_info->filename,image->filename,MaxTextExtent);
724  (void) ConcatenateMagickString(image_info->filename,pathname,MaxTextExtent);
725  clip_mask=BlobToImage(image_info,value,strlen(value),&image->exception);
726  image_info=DestroyImageInfo(image_info);
727  if (clip_mask == (Image *) NULL)
728  return(MagickFalse);
729  if (clip_mask->storage_class == PseudoClass)
730  {
731  (void) SyncImage(clip_mask);
732  if (SetImageStorageClass(clip_mask,DirectClass) == MagickFalse)
733  return(MagickFalse);
734  }
735  if (inside == MagickFalse)
736  (void) NegateImage(clip_mask,MagickFalse);
738  "8BIM:1999,2998:%s\nPS",pathname);
739  (void) SetImageClipMask(image,clip_mask);
740  clip_mask=DestroyImage(clip_mask);
741  return(MagickTrue);
742 }
743 
744 /*
745 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
746 % %
747 % %
748 % %
749 % C l o n e I m a g e %
750 % %
751 % %
752 % %
753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
754 %
755 % CloneImage() copies an image and returns the copy as a new image object.
756 %
757 % If the specified columns and rows is 0, an exact copy of the image is
758 % returned, otherwise the pixel data is undefined and must be initialized
759 % with the QueueAuthenticPixels() and SyncAuthenticPixels() methods. On
760 % failure, a NULL image is returned and exception describes the reason for the
761 % failure.
762 %
763 % The format of the CloneImage method is:
764 %
765 % Image *CloneImage(const Image *image,const size_t columns,
766 % const size_t rows,const MagickBooleanType orphan,
767 % ExceptionInfo *exception)
768 %
769 % A description of each parameter follows:
770 %
771 % o image: the image.
772 %
773 % o columns: the number of columns in the cloned image.
774 %
775 % o rows: the number of rows in the cloned image.
776 %
777 % o detach: With a value other than 0, the cloned image is detached from
778 % its parent I/O stream.
779 %
780 % o exception: return any errors or warnings in this structure.
781 %
782 */
783 MagickExport Image *CloneImage(const Image *image,const size_t columns,
784  const size_t rows,const MagickBooleanType detach,ExceptionInfo *exception)
785 {
786  double
787  scale;
788 
789  Image
790  *clone_image;
791 
792  size_t
793  length;
794 
795  /*
796  Clone the image.
797  */
798  assert(image != (const Image *) NULL);
799  assert(image->signature == MagickSignature);
800  if (image->debug != MagickFalse)
801  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
802  assert(exception != (ExceptionInfo *) NULL);
803  assert(exception->signature == MagickSignature);
804  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  SetPixelPacket(image,&background,&pixel,&index);
2178  /*
2179  Set image background color.
2180  */
2181  status=MagickTrue;
2182  exception=(&image->exception);
2183  image_view=AcquireAuthenticCacheView(image,exception);
2184  for (y=0; y < (ssize_t) image->rows; y++)
2185  {
2186  register PixelPacket
2187  *restrict q;
2188 
2189  register ssize_t
2190  x;
2191 
2192  if (status == MagickFalse)
2193  continue;
2194  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2195  if (q == (PixelPacket *) NULL)
2196  {
2197  status=MagickFalse;
2198  continue;
2199  }
2200  for (x=0; x < (ssize_t) image->columns; x++)
2201  *q++=pixel;
2202  if (image->colorspace == CMYKColorspace)
2203  {
2204  register IndexPacket
2205  *restrict indexes;
2206 
2207  indexes=GetCacheViewAuthenticIndexQueue(image_view);
2208  for (x=0; x < (ssize_t) image->columns; x++)
2209  SetPixelIndex(indexes+x,index);
2210  }
2211  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2212  status=MagickFalse;
2213  }
2214  image_view=DestroyCacheView(image_view);
2215  return(status);
2216 }
2217 
2218 /*
2219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2220 % %
2221 % %
2222 % %
2223 % S e t I m a g e C h a n n e l s %
2224 % %
2225 % %
2226 % %
2227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2228 %
2229 % SetImageChannels() sets the number of pixels channels associated with the
2230 % image.
2231 %
2232 % The format of the SetImageChannels method is:
2233 %
2234 % MagickBooleanType SetImageChannels(Image *image,const size_t channels)
2235 %
2236 % A description of each parameter follows:
2237 %
2238 % o image: the image.
2239 %
2240 % o channels: The number of pixel channels.
2241 %
2242 */
2244  const size_t channels)
2245 {
2246  image->channels=channels;
2247  return(MagickTrue);
2248 }
2249 
2250 /*
2251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2252 % %
2253 % %
2254 % %
2255 % S e t I m a g e C o l o r %
2256 % %
2257 % %
2258 % %
2259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2260 %
2261 % SetImageColor() set the entire image canvas to the specified color.
2262 %
2263 % The format of the SetImageColor method is:
2264 %
2265 % MagickBooleanType SetImageColor(Image *image,
2266 % const MagickPixelPacket *color)
2267 %
2268 % A description of each parameter follows:
2269 %
2270 % o image: the image.
2271 %
2272 % o background: the image color.
2273 %
2274 */
2276  const MagickPixelPacket *color)
2277 {
2278  CacheView
2279  *image_view;
2280 
2282  *exception;
2283 
2285  status;
2286 
2287  ssize_t
2288  y;
2289 
2290  assert(image != (Image *) NULL);
2291  if (image->debug != MagickFalse)
2292  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2293  assert(image->signature == MagickSignature);
2294  assert(color != (const MagickPixelPacket *) NULL);
2295  image->colorspace=color->colorspace;
2296  image->matte=color->matte;
2297  image->fuzz=color->fuzz;
2298  image->depth=color->depth;
2299  status=MagickTrue;
2300  exception=(&image->exception);
2301  image_view=AcquireAuthenticCacheView(image,exception);
2302 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2303  #pragma omp parallel for schedule(static,4) shared(status) \
2304  magick_threads(image,image,image->rows,1)
2305 #endif
2306  for (y=0; y < (ssize_t) image->rows; y++)
2307  {
2308  register IndexPacket
2309  *restrict indexes;
2310 
2311  register PixelPacket
2312  *restrict q;
2313 
2314  register ssize_t
2315  x;
2316 
2317  if (status == MagickFalse)
2318  continue;
2319  q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2320  if (q == (PixelPacket *) NULL)
2321  {
2322  status=MagickFalse;
2323  continue;
2324  }
2325  indexes=GetCacheViewAuthenticIndexQueue(image_view);
2326  for (x=0; x < (ssize_t) image->columns; x++)
2327  {
2328  SetPixelPacket(image,color,q,indexes+x);
2329  q++;
2330  }
2331  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2332  status=MagickFalse;
2333  }
2334  image_view=DestroyCacheView(image_view);
2335  return(status);
2336 }
2337 
2338 /*
2339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2340 % %
2341 % %
2342 % %
2343 % S e t I m a g e S t o r a g e C l a s s %
2344 % %
2345 % %
2346 % %
2347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2348 %
2349 % SetImageStorageClass() sets the image class: DirectClass for true color
2350 % images or PseudoClass for colormapped images.
2351 %
2352 % The format of the SetImageStorageClass method is:
2353 %
2354 % MagickBooleanType SetImageStorageClass(Image *image,
2355 % const ClassType storage_class)
2356 %
2357 % A description of each parameter follows:
2358 %
2359 % o image: the image.
2360 %
2361 % o storage_class: The image class.
2362 %
2363 */
2365  const ClassType storage_class)
2366 {
2367  image->storage_class=storage_class;
2368  return(SyncImagePixelCache(image,&image->exception));
2369 }
2370 
2371 /*
2372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2373 % %
2374 % %
2375 % %
2376 % S e t I m a g e C l i p M a s k %
2377 % %
2378 % %
2379 % %
2380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2381 %
2382 % SetImageClipMask() associates a clip path with the image. The clip path
2383 % must be the same dimensions as the image. Set any pixel component of
2384 % the clip path to TransparentOpacity to prevent that corresponding image
2385 % pixel component from being updated when SyncAuthenticPixels() is applied.
2386 %
2387 % The format of the SetImageClipMask method is:
2388 %
2389 % MagickBooleanType SetImageClipMask(Image *image,const Image *clip_mask)
2390 %
2391 % A description of each parameter follows:
2392 %
2393 % o image: the image.
2394 %
2395 % o clip_mask: the image clip path.
2396 %
2397 */
2399  const Image *clip_mask)
2400 {
2401  assert(image != (Image *) NULL);
2402  if (image->debug != MagickFalse)
2403  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2404  assert(image->signature == MagickSignature);
2405  if (clip_mask != (const Image *) NULL)
2406  if ((clip_mask->columns != image->columns) ||
2407  (clip_mask->rows != image->rows))
2408  ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
2409  if (image->clip_mask != (Image *) NULL)
2410  image->clip_mask=DestroyImage(image->clip_mask);
2411  image->clip_mask=NewImageList();
2412  if (clip_mask == (Image *) NULL)
2413  return(MagickTrue);
2415  return(MagickFalse);
2416  image->clip_mask=CloneImage(clip_mask,0,0,MagickTrue,&image->exception);
2417  if (image->clip_mask == (Image *) NULL)
2418  return(MagickFalse);
2419  return(MagickTrue);
2420 }
2421 
2422 /*
2423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2424 % %
2425 % %
2426 % %
2427 % S e t I m a g e E x t e n t %
2428 % %
2429 % %
2430 % %
2431 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2432 %
2433 % SetImageExtent() sets the image size (i.e. columns & rows).
2434 %
2435 % The format of the SetImageExtent method is:
2436 %
2437 % MagickBooleanType SetImageExtent(Image *image,
2438 % const size_t columns,const size_t rows)
2439 %
2440 % A description of each parameter follows:
2441 %
2442 % o image: the image.
2443 %
2444 % o columns: The image width in pixels.
2445 %
2446 % o rows: The image height in pixels.
2447 %
2448 */
2450  const size_t columns,const size_t rows)
2451 {
2452  if ((columns == 0) || (rows == 0))
2453  return(MagickFalse);
2454  image->columns=columns;
2455  image->rows=rows;
2456  return(SyncImagePixelCache(image,&image->exception));
2457 }
2458 
2459 /*
2460 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2461 % %
2462 % %
2463 % %
2464 + S e t I m a g e I n f o %
2465 % %
2466 % %
2467 % %
2468 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2469 %
2470 % SetImageInfo() initializes the `magick' field of the ImageInfo structure.
2471 % It is set to a type of image format based on the prefix or suffix of the
2472 % filename. For example, `ps:image' returns PS indicating a Postscript image.
2473 % JPEG is returned for this filename: `image.jpg'. The filename prefix has
2474 % precendence over the suffix. Use an optional index enclosed in brackets
2475 % after a file name to specify a desired scene of a multi-resolution image
2476 % format like Photo CD (e.g. img0001.pcd[4]). A True (non-zero) return value
2477 % indicates success.
2478 %
2479 % The format of the SetImageInfo method is:
2480 %
2481 % MagickBooleanType SetImageInfo(ImageInfo *image_info,
2482 % const unsigned int frames,ExceptionInfo *exception)
2483 %
2484 % A description of each parameter follows:
2485 %
2486 % o image_info: the image info.
2487 %
2488 % o frames: the number of images you intend to write.
2489 %
2490 % o exception: return any errors or warnings in this structure.
2491 %
2492 */
2494  const unsigned int frames,ExceptionInfo *exception)
2495 {
2496  char
2497  extension[MaxTextExtent],
2498  filename[MaxTextExtent],
2499  magic[MaxTextExtent],
2500  *q,
2501  subimage[MaxTextExtent];
2502 
2503  const MagicInfo
2504  *magic_info;
2505 
2506  const MagickInfo
2507  *magick_info;
2508 
2510  *sans_exception;
2511 
2512  Image
2513  *image;
2514 
2516  status;
2517 
2518  register const char
2519  *p;
2520 
2521  ssize_t
2522  count;
2523 
2524  unsigned char
2525  magick[2*MaxTextExtent];
2526 
2527  /*
2528  Look for 'image.format' in filename.
2529  */
2530  assert(image_info != (ImageInfo *) NULL);
2531  assert(image_info->signature == MagickSignature);
2532  if (image_info->debug != MagickFalse)
2534  image_info->filename);
2535  *subimage='\0';
2536  GetPathComponent(image_info->filename,SubimagePath,subimage);
2537  if (*subimage != '\0')
2538  {
2539  /*
2540  Look for scene specification (e.g. img0001.pcd[4]).
2541  */
2542  if (IsSceneGeometry(subimage,MagickFalse) == MagickFalse)
2543  {
2544  if (IsGeometry(subimage) != MagickFalse)
2545  (void) CloneString(&image_info->extract,subimage);
2546  }
2547  else
2548  {
2549  size_t
2550  first,
2551  last;
2552 
2553  (void) CloneString(&image_info->scenes,subimage);
2554  image_info->scene=StringToUnsignedLong(image_info->scenes);
2555  image_info->number_scenes=image_info->scene;
2556  p=image_info->scenes;
2557  for (q=(char *) image_info->scenes; *q != '\0'; p++)
2558  {
2559  while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
2560  p++;
2561  first=(size_t) strtol(p,&q,10);
2562  last=first;
2563  while (isspace((int) ((unsigned char) *q)) != 0)
2564  q++;
2565  if (*q == '-')
2566  last=(size_t) strtol(q+1,&q,10);
2567  if (first > last)
2568  Swap(first,last);
2569  if (first < image_info->scene)
2570  image_info->scene=first;
2571  if (last > image_info->number_scenes)
2572  image_info->number_scenes=last;
2573  p=q;
2574  }
2575  image_info->number_scenes-=image_info->scene-1;
2576  image_info->subimage=image_info->scene;
2577  image_info->subrange=image_info->number_scenes;
2578  }
2579  }
2580  *extension='\0';
2581  GetPathComponent(image_info->filename,ExtensionPath,extension);
2582 #if defined(MAGICKCORE_ZLIB_DELEGATE)
2583  if (*extension != '\0')
2584  if ((LocaleCompare(extension,"gz") == 0) ||
2585  (LocaleCompare(extension,"Z") == 0) ||
2586  (LocaleCompare(extension,"svgz") == 0) ||
2587  (LocaleCompare(extension,"wmz") == 0))
2588  {
2589  char
2590  path[MaxTextExtent];
2591 
2592  (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
2593  path[strlen(path)-strlen(extension)-1]='\0';
2594  GetPathComponent(path,ExtensionPath,extension);
2595  }
2596 #endif
2597 #if defined(MAGICKCORE_BZLIB_DELEGATE)
2598  if (*extension != '\0')
2599  if (LocaleCompare(extension,"bz2") == 0)
2600  {
2601  char
2602  path[MaxTextExtent];
2603 
2604  (void) CopyMagickString(path,image_info->filename,MaxTextExtent);
2605  path[strlen(path)-strlen(extension)-1]='\0';
2606  GetPathComponent(path,ExtensionPath,extension);
2607  }
2608 #endif
2609  image_info->affirm=MagickFalse;
2610  sans_exception=AcquireExceptionInfo();
2611  if (*extension != '\0')
2612  {
2614  format_type;
2615 
2616  register ssize_t
2617  i;
2618 
2619  static const char
2620  *format_type_formats[] =
2621  {
2622  "AUTOTRACE",
2623  "BROWSE",
2624  "DCRAW",
2625  "EDIT",
2626  "EPHEMERAL",
2627  "LAUNCH",
2628  "MPEG:DECODE",
2629  "MPEG:ENCODE",
2630  "PRINT",
2631  "PS:ALPHA",
2632  "PS:CMYK",
2633  "PS:COLOR",
2634  "PS:GRAY",
2635  "PS:MONO",
2636  "SCAN",
2637  "SHOW",
2638  "WIN",
2639  (char *) NULL
2640  };
2641 
2642  /*
2643  User specified image format.
2644  */
2645  (void) CopyMagickString(magic,extension,MaxTextExtent);
2646  LocaleUpper(magic);
2647  /*
2648  Look for explicit image formats.
2649  */
2650  format_type=UndefinedFormatType;
2651  i=0;
2652  while ((format_type == UndefinedFormatType) &&
2653  (format_type_formats[i] != (char *) NULL))
2654  {
2655  if ((*magic == *format_type_formats[i]) &&
2656  (LocaleCompare(magic,format_type_formats[i]) == 0))
2657  format_type=ExplicitFormatType;
2658  i++;
2659  }
2660  magick_info=GetMagickInfo(magic,sans_exception);
2661  if ((magick_info != (const MagickInfo *) NULL) &&
2662  (magick_info->format_type != UndefinedFormatType))
2663  format_type=magick_info->format_type;
2664  if (format_type == UndefinedFormatType)
2665  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2666  else
2667  if (format_type == ExplicitFormatType)
2668  {
2669  image_info->affirm=MagickTrue;
2670  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2671  }
2672  if (LocaleCompare(magic,"RGB") == 0)
2673  image_info->affirm=MagickFalse; /* maybe SGI disguised as RGB */
2674  }
2675  /*
2676  Look for explicit 'format:image' in filename.
2677  */
2678  *magic='\0';
2679  GetPathComponent(image_info->filename,MagickPath,magic);
2680  if (*magic == '\0')
2681  (void) CopyMagickString(magic,image_info->magick,MaxTextExtent);
2682  else
2683  {
2684  /*
2685  User specified image format.
2686  */
2687  LocaleUpper(magic);
2688  if (IsMagickConflict(magic) == MagickFalse)
2689  {
2690  (void) CopyMagickString(image_info->magick,magic,MaxTextExtent);
2691  if (LocaleCompare(magic,"EPHEMERAL") != 0)
2692  image_info->affirm=MagickTrue;
2693  else
2694  image_info->temporary=MagickTrue;
2695  }
2696  }
2697  magick_info=GetMagickInfo(magic,sans_exception);
2698  sans_exception=DestroyExceptionInfo(sans_exception);
2699  if ((magick_info == (const MagickInfo *) NULL) ||
2700  (GetMagickEndianSupport(magick_info) == MagickFalse))
2701  image_info->endian=UndefinedEndian;
2702  GetPathComponent(image_info->filename,CanonicalPath,filename);
2703  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2704  if ((image_info->adjoin != MagickFalse) && (frames > 1))
2705  {
2706  /*
2707  Test for multiple image support (e.g. image%02d.png).
2708  */
2709  (void) InterpretImageFilename(image_info,(Image *) NULL,
2710  image_info->filename,(int) image_info->scene,filename);
2711  if ((LocaleCompare(filename,image_info->filename) != 0) &&
2712  (strchr(filename,'%') == (char *) NULL))
2713  image_info->adjoin=MagickFalse;
2714  }
2715  if ((image_info->adjoin != MagickFalse) && (frames > 0))
2716  {
2717  /*
2718  Some image formats do not support multiple frames per file.
2719  */
2720  magick_info=GetMagickInfo(magic,exception);
2721  if (magick_info != (const MagickInfo *) NULL)
2722  if (GetMagickAdjoin(magick_info) == MagickFalse)
2723  image_info->adjoin=MagickFalse;
2724  }
2725  if (image_info->affirm != MagickFalse)
2726  return(MagickTrue);
2727  if (frames == 0)
2728  {
2729  /*
2730  Determine the image format from the first few bytes of the file.
2731  */
2732  image=AcquireImage(image_info);
2733  (void) CopyMagickString(image->filename,image_info->filename,
2734  MaxTextExtent);
2735  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2736  if (status == MagickFalse)
2737  {
2738  image=DestroyImage(image);
2739  return(MagickFalse);
2740  }
2741  if ((IsBlobSeekable(image) == MagickFalse) ||
2742  (IsBlobExempt(image) != MagickFalse))
2743  {
2744  /*
2745  Copy standard input or pipe to temporary file.
2746  */
2747  *filename='\0';
2748  status=ImageToFile(image,filename,exception);
2749  (void) CloseBlob(image);
2750  if (status == MagickFalse)
2751  {
2752  image=DestroyImage(image);
2753  return(MagickFalse);
2754  }
2755  SetImageInfoFile(image_info,(FILE *) NULL);
2756  (void) CopyMagickString(image->filename,filename,MaxTextExtent);
2757  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
2758  if (status == MagickFalse)
2759  {
2760  image=DestroyImage(image);
2761  return(MagickFalse);
2762  }
2763  (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2764  image_info->temporary=MagickTrue;
2765  }
2766  (void) ResetMagickMemory(magick,0,sizeof(magick));
2767  count=ReadBlob(image,2*MaxTextExtent,magick);
2768  (void) SeekBlob(image,-((MagickOffsetType) count),SEEK_CUR);
2769  (void) CloseBlob(image);
2770  image=DestroyImage(image);
2771  /*
2772  Check magic.xml configuration file.
2773  */
2774  sans_exception=AcquireExceptionInfo();
2775  magic_info=GetMagicInfo(magick,(size_t) count,sans_exception);
2776  if ((magic_info != (const MagicInfo *) NULL) &&
2777  (GetMagicName(magic_info) != (char *) NULL))
2778  {
2779  (void) CopyMagickString(image_info->magick,GetMagicName(magic_info),
2780  MaxTextExtent);
2781  magick_info=GetMagickInfo(image_info->magick,sans_exception);
2782  if ((magick_info == (const MagickInfo *) NULL) ||
2783  (GetMagickEndianSupport(magick_info) == MagickFalse))
2784  image_info->endian=UndefinedEndian;
2785  sans_exception=DestroyExceptionInfo(sans_exception);
2786  return(MagickTrue);
2787  }
2788  magick_info=GetMagickInfo(image_info->magick,sans_exception);
2789  if ((magick_info == (const MagickInfo *) NULL) ||
2790  (GetMagickEndianSupport(magick_info) == MagickFalse))
2791  image_info->endian=UndefinedEndian;
2792  sans_exception=DestroyExceptionInfo(sans_exception);
2793  }
2794  return(MagickTrue);
2795 }
2796 
2797 /*
2798 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2799 % %
2800 % %
2801 % %
2802 % S e t I m a g e I n f o B l o b %
2803 % %
2804 % %
2805 % %
2806 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2807 %
2808 % SetImageInfoBlob() sets the image info blob member.
2809 %
2810 % The format of the SetImageInfoBlob method is:
2811 %
2812 % void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
2813 % const size_t length)
2814 %
2815 % A description of each parameter follows:
2816 %
2817 % o image_info: the image info.
2818 %
2819 % o blob: the blob.
2820 %
2821 % o length: the blob length.
2822 %
2823 */
2824 MagickExport void SetImageInfoBlob(ImageInfo *image_info,const void *blob,
2825  const size_t length)
2826 {
2827  assert(image_info != (ImageInfo *) NULL);
2828  assert(image_info->signature == MagickSignature);
2829  if (image_info->debug != MagickFalse)
2831  image_info->filename);
2832  image_info->blob=(void *) blob;
2833  image_info->length=length;
2834 }
2835 
2836 /*
2837 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2838 % %
2839 % %
2840 % %
2841 % S e t I m a g e I n f o F i l e %
2842 % %
2843 % %
2844 % %
2845 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2846 %
2847 % SetImageInfoFile() sets the image info file member.
2848 %
2849 % The format of the SetImageInfoFile method is:
2850 %
2851 % void SetImageInfoFile(ImageInfo *image_info,FILE *file)
2852 %
2853 % A description of each parameter follows:
2854 %
2855 % o image_info: the image info.
2856 %
2857 % o file: the file.
2858 %
2859 */
2860 MagickExport void SetImageInfoFile(ImageInfo *image_info,FILE *file)
2861 {
2862  assert(image_info != (ImageInfo *) NULL);
2863  assert(image_info->signature == MagickSignature);
2864  if (image_info->debug != MagickFalse)
2866  image_info->filename);
2867  image_info->file=file;
2868 }
2869 
2870 /*
2871 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2872 % %
2873 % %
2874 % %
2875 % S e t I m a g e M a s k %
2876 % %
2877 % %
2878 % %
2879 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2880 %
2881 % SetImageMask() associates a mask with the image. The mask must be the same
2882 % dimensions as the image.
2883 %
2884 % The format of the SetImageMask method is:
2885 %
2886 % MagickBooleanType SetImageMask(Image *image,const Image *mask)
2887 %
2888 % A description of each parameter follows:
2889 %
2890 % o image: the image.
2891 %
2892 % o mask: the image mask.
2893 %
2894 */
2896 {
2897  assert(image != (Image *) NULL);
2898  if (image->debug != MagickFalse)
2899  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2900  assert(image->signature == MagickSignature);
2901  if (mask != (const Image *) NULL)
2902  if ((mask->columns != image->columns) || (mask->rows != image->rows))
2903  ThrowBinaryException(ImageError,"ImageSizeDiffers",image->filename);
2904  if (image->mask != (Image *) NULL)
2905  image->mask=DestroyImage(image->mask);
2906  image->mask=NewImageList();
2907  if (mask == (Image *) NULL)
2908  return(MagickTrue);
2910  return(MagickFalse);
2911  image->mask=CloneImage(mask,0,0,MagickTrue,&image->exception);
2912  if (image->mask == (Image *) NULL)
2913  return(MagickFalse);
2914  return(MagickTrue);
2915 }
2916 
2917 /*
2918 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2919 % %
2920 % %
2921 % %
2922 % S e t I m a g e O p a c i t y %
2923 % %
2924 % %
2925 % %
2926 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2927 %
2928 % SetImageOpacity() sets the opacity levels of the image.
2929 %
2930 % The format of the SetImageOpacity method is:
2931 %
2932 % MagickBooleanType SetImageOpacity(Image *image,const Quantum opacity)
2933 %
2934 % A description of each parameter follows:
2935 %
2936 % o image: the image.
2937 %
2938 % o opacity: the level of transparency: 0 is fully opaque and QuantumRange is
2939 % fully transparent.
2940 %
2941 */
2943  const Quantum opacity)
2944 {
2945  CacheView
2946  *image_view;
2947 
2949  *exception;
2950 
2952  status;
2953 
2954  ssize_t
2955  y;
2956 
2957  assert(image != (Image *) NULL);
2958  if (image->debug != MagickFalse)
2959  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
2960  assert(image->signature == MagickSignature);
2961  image->matte=MagickTrue;
2962  status=MagickTrue;
2963  exception=(&image->exception);
2964  image_view=AcquireAuthenticCacheView(image,exception);
2965 #if defined(MAGICKCORE_OPENMP_SUPPORT)
2966  #pragma omp parallel for schedule(static,4) shared(status) \
2967  magick_threads(image,image,image->rows,1)
2968 #endif
2969  for (y=0; y < (ssize_t) image->rows; y++)
2970  {
2971  register PixelPacket
2972  *restrict q;
2973 
2974  register ssize_t
2975  x;
2976 
2977  if (status == MagickFalse)
2978  continue;
2979  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
2980  if (q == (PixelPacket *) NULL)
2981  {
2982  status=MagickFalse;
2983  continue;
2984  }
2985  for (x=0; x < (ssize_t) image->columns; x++)
2986  {
2987  SetPixelOpacity(q,opacity);
2988  q++;
2989  }
2990  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
2991  status=MagickFalse;
2992  }
2993  image_view=DestroyCacheView(image_view);
2994  return(status);
2995 }
2996 
2997 /*
2998 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2999 % %
3000 % %
3001 % %
3002 % 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 %
3003 % %
3004 % %
3005 % %
3006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3007 %
3008 % SetImageVirtualPixelMethod() sets the "virtual pixels" method for the
3009 % image and returns the previous setting. A virtual pixel is any pixel access
3010 % that is outside the boundaries of the image cache.
3011 %
3012 % The format of the SetImageVirtualPixelMethod() method is:
3013 %
3014 % VirtualPixelMethod SetImageVirtualPixelMethod(const Image *image,
3015 % const VirtualPixelMethod virtual_pixel_method)
3016 %
3017 % A description of each parameter follows:
3018 %
3019 % o image: the image.
3020 %
3021 % o virtual_pixel_method: choose the type of virtual pixel.
3022 %
3023 */
3025  const VirtualPixelMethod virtual_pixel_method)
3026 {
3027  assert(image != (const Image *) NULL);
3028  assert(image->signature == MagickSignature);
3029  if (image->debug != MagickFalse)
3030  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3031  return(SetPixelCacheVirtualMethod(image,virtual_pixel_method));
3032 }
3033 
3034 /*
3035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3036 % %
3037 % %
3038 % %
3039 % S m u s h I m a g e s %
3040 % %
3041 % %
3042 % %
3043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3044 %
3045 % SmushImages() takes all images from the current image pointer to the end
3046 % of the image list and smushes them to each other top-to-bottom if the
3047 % stack parameter is true, otherwise left-to-right.
3048 %
3049 % The current gravity setting now effects how the image is justified in the
3050 % final image.
3051 %
3052 % The format of the SmushImages method is:
3053 %
3054 % Image *SmushImages(const Image *images,const MagickBooleanType stack,
3055 % ExceptionInfo *exception)
3056 %
3057 % A description of each parameter follows:
3058 %
3059 % o images: the image sequence.
3060 %
3061 % o stack: A value other than 0 stacks the images top-to-bottom.
3062 %
3063 % o offset: minimum distance in pixels between images.
3064 %
3065 % o exception: return any errors or warnings in this structure.
3066 %
3067 */
3068 
3069 static ssize_t SmushXGap(const Image *smush_image,const Image *images,
3070  const ssize_t offset,ExceptionInfo *exception)
3071 {
3072  CacheView
3073  *left_view,
3074  *right_view;
3075 
3076  const Image
3077  *left_image,
3078  *right_image;
3079 
3081  left_geometry,
3082  right_geometry;
3083 
3084  register const PixelPacket
3085  *p;
3086 
3087  register ssize_t
3088  i,
3089  y;
3090 
3091  size_t
3092  gap;
3093 
3094  ssize_t
3095  x;
3096 
3097  if (images->previous == (Image *) NULL)
3098  return(0);
3099  right_image=images;
3100  SetGeometry(smush_image,&right_geometry);
3101  GravityAdjustGeometry(right_image->columns,right_image->rows,
3102  right_image->gravity,&right_geometry);
3103  left_image=images->previous;
3104  SetGeometry(smush_image,&left_geometry);
3105  GravityAdjustGeometry(left_image->columns,left_image->rows,
3106  left_image->gravity,&left_geometry);
3107  gap=right_image->columns;
3108  left_view=AcquireVirtualCacheView(left_image,exception);
3109  right_view=AcquireVirtualCacheView(right_image,exception);
3110  for (y=0; y < (ssize_t) smush_image->rows; y++)
3111  {
3112  for (x=(ssize_t) left_image->columns-1; x > 0; x--)
3113  {
3114  p=GetCacheViewVirtualPixels(left_view,x,left_geometry.y+y,1,1,exception);
3115  if ((p == (const PixelPacket *) NULL) ||
3117  ((left_image->columns-x-1) >= gap))
3118  break;
3119  }
3120  i=(ssize_t) left_image->columns-x-1;
3121  for (x=0; x < (ssize_t) right_image->columns; x++)
3122  {
3123  p=GetCacheViewVirtualPixels(right_view,x,right_geometry.y+y,1,1,
3124  exception);
3125  if ((p == (const PixelPacket *) NULL) ||
3127  ((x+i) >= (ssize_t) gap))
3128  break;
3129  }
3130  if ((x+i) < (ssize_t) gap)
3131  gap=(size_t) (x+i);
3132  }
3133  right_view=DestroyCacheView(right_view);
3134  left_view=DestroyCacheView(left_view);
3135  if (y < (ssize_t) smush_image->rows)
3136  return(offset);
3137  return((ssize_t) gap-offset);
3138 }
3139 
3140 static ssize_t SmushYGap(const Image *smush_image,const Image *images,
3141  const ssize_t offset,ExceptionInfo *exception)
3142 {
3143  CacheView
3144  *bottom_view,
3145  *top_view;
3146 
3147  const Image
3148  *bottom_image,
3149  *top_image;
3150 
3152  bottom_geometry,
3153  top_geometry;
3154 
3155  register const PixelPacket
3156  *p;
3157 
3158  register ssize_t
3159  i,
3160  x;
3161 
3162  size_t
3163  gap;
3164 
3165  ssize_t
3166  y;
3167 
3168  if (images->previous == (Image *) NULL)
3169  return(0);
3170  bottom_image=images;
3171  SetGeometry(smush_image,&bottom_geometry);
3172  GravityAdjustGeometry(bottom_image->columns,bottom_image->rows,
3173  bottom_image->gravity,&bottom_geometry);
3174  top_image=images->previous;
3175  SetGeometry(smush_image,&top_geometry);
3176  GravityAdjustGeometry(top_image->columns,top_image->rows,top_image->gravity,
3177  &top_geometry);
3178  gap=bottom_image->rows;
3179  top_view=AcquireVirtualCacheView(top_image,exception);
3180  bottom_view=AcquireVirtualCacheView(bottom_image,exception);
3181  for (x=0; x < (ssize_t) smush_image->columns; x++)
3182  {
3183  for (y=(ssize_t) top_image->rows-1; y > 0; y--)
3184  {
3185  p=GetCacheViewVirtualPixels(top_view,top_geometry.x+x,y,1,1,exception);
3186  if ((p == (const PixelPacket *) NULL) ||
3188  ((top_image->rows-y-1) >= gap))
3189  break;
3190  }
3191  i=(ssize_t) top_image->rows-y-1;
3192  for (y=0; y < (ssize_t) bottom_image->rows; y++)
3193  {
3194  p=GetCacheViewVirtualPixels(bottom_view,bottom_geometry.x+x,y,1,1,
3195  exception);
3196  if ((p == (const PixelPacket *) NULL) ||
3198  ((y+i) >= (ssize_t) gap))
3199  break;
3200  }
3201  if ((y+i) < (ssize_t) gap)
3202  gap=(size_t) (y+i);
3203  }
3204  bottom_view=DestroyCacheView(bottom_view);
3205  top_view=DestroyCacheView(top_view);
3206  if (x < (ssize_t) smush_image->columns)
3207  return(offset);
3208  return((ssize_t) gap-offset);
3209 }
3210 
3212  const MagickBooleanType stack,const ssize_t offset,ExceptionInfo *exception)
3213 {
3214 #define SmushImageTag "Smush/Image"
3215 
3216  CacheView
3217  *smush_view;
3218 
3219  const Image
3220  *image;
3221 
3222  Image
3223  *smush_image;
3224 
3226  matte,
3227  proceed,
3228  status;
3229 
3231  n;
3232 
3234  geometry;
3235 
3236  register const Image
3237  *next;
3238 
3239  size_t
3240  height,
3241  number_images,
3242  width;
3243 
3244  ssize_t
3245  x_offset,
3246  y_offset;
3247 
3248  /*
3249  Compute maximum area of smushed area.
3250  */
3251  assert(images != (Image *) NULL);
3252  assert(images->signature == MagickSignature);
3253  if (images->debug != MagickFalse)
3254  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3255  assert(exception != (ExceptionInfo *) NULL);
3256  assert(exception->signature == MagickSignature);
3257  image=images;
3258  matte=image->matte;
3259  number_images=1;
3260  width=image->columns;
3261  height=image->rows;
3262  next=GetNextImageInList(image);
3263  for ( ; next != (Image *) NULL; next=GetNextImageInList(next))
3264  {
3265  if (next->matte != MagickFalse)
3266  matte=MagickTrue;
3267  number_images++;
3268  if (stack != MagickFalse)
3269  {
3270  if (next->columns > width)
3271  width=next->columns;
3272  height+=next->rows;
3273  if (next->previous != (Image *) NULL)
3274  height+=offset;
3275  continue;
3276  }
3277  width+=next->columns;
3278  if (next->previous != (Image *) NULL)
3279  width+=offset;
3280  if (next->rows > height)
3281  height=next->rows;
3282  }
3283  /*
3284  Smush images.
3285  */
3286  smush_image=CloneImage(image,width,height,MagickTrue,exception);
3287  if (smush_image == (Image *) NULL)
3288  return((Image *) NULL);
3289  if (SetImageStorageClass(smush_image,DirectClass) == MagickFalse)
3290  {
3291  InheritException(exception,&smush_image->exception);
3292  smush_image=DestroyImage(smush_image);
3293  return((Image *) NULL);
3294  }
3295  smush_image->matte=matte;
3296  (void) SetImageBackgroundColor(smush_image);
3297  status=MagickTrue;
3298  x_offset=0;
3299  y_offset=0;
3300  smush_view=AcquireVirtualCacheView(smush_image,exception);
3301  for (n=0; n < (MagickOffsetType) number_images; n++)
3302  {
3303  SetGeometry(smush_image,&geometry);
3304  GravityAdjustGeometry(image->columns,image->rows,image->gravity,&geometry);
3305  if (stack != MagickFalse)
3306  {
3307  x_offset-=geometry.x;
3308  y_offset-=SmushYGap(smush_image,image,offset,exception);
3309  }
3310  else
3311  {
3312  x_offset-=SmushXGap(smush_image,image,offset,exception);
3313  y_offset-=geometry.y;
3314  }
3315  status=CompositeImage(smush_image,OverCompositeOp,image,x_offset,y_offset);
3316  proceed=SetImageProgress(image,SmushImageTag,n,number_images);
3317  if (proceed == MagickFalse)
3318  break;
3319  if (stack == MagickFalse)
3320  {
3321  x_offset+=(ssize_t) image->columns;
3322  y_offset=0;
3323  }
3324  else
3325  {
3326  x_offset=0;
3327  y_offset+=(ssize_t) image->rows;
3328  }
3329  image=GetNextImageInList(image);
3330  }
3331  if (stack == MagickFalse)
3332  smush_image->columns=(size_t) x_offset;
3333  else
3334  smush_image->rows=(size_t) y_offset;
3335  smush_view=DestroyCacheView(smush_view);
3336  if (status == MagickFalse)
3337  smush_image=DestroyImage(smush_image);
3338  return(smush_image);
3339 }
3340 
3341 /*
3342 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3343 % %
3344 % %
3345 % %
3346 % S t r i p I m a g e %
3347 % %
3348 % %
3349 % %
3350 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3351 %
3352 % StripImage() strips an image of all profiles and comments.
3353 %
3354 % The format of the StripImage method is:
3355 %
3356 % MagickBooleanType StripImage(Image *image)
3357 %
3358 % A description of each parameter follows:
3359 %
3360 % o image: the image.
3361 %
3362 */
3364 {
3366  status;
3367 
3368  assert(image != (Image *) NULL);
3369  if (image->debug != MagickFalse)
3370  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3371  DestroyImageProfiles(image);
3372  (void) DeleteImageProperty(image,"comment");
3373  (void) DeleteImageProperty(image,"date:create");
3374  (void) DeleteImageProperty(image,"date:modify");
3375  status=SetImageArtifact(image,"png:exclude-chunk",
3376  "EXIF,iCCP,iTXt,sRGB,tEXt,zCCP,zTXt,date");
3377  return(status);
3378 }
3379 
3380 /*
3381 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3382 % %
3383 % %
3384 % %
3385 + S y n c I m a g e %
3386 % %
3387 % %
3388 % %
3389 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3390 %
3391 % SyncImage() initializes the red, green, and blue intensities of each pixel
3392 % as defined by the colormap index.
3393 %
3394 % The format of the SyncImage method is:
3395 %
3396 % MagickBooleanType SyncImage(Image *image)
3397 %
3398 % A description of each parameter follows:
3399 %
3400 % o image: the image.
3401 %
3402 */
3403 
3404 static inline IndexPacket PushColormapIndex(Image *image,
3405  const size_t index,MagickBooleanType *range_exception)
3406 {
3407  if (index < image->colors)
3408  return((IndexPacket) index);
3409  *range_exception=MagickTrue;
3410  return((IndexPacket) 0);
3411 }
3412 
3414 {
3415  CacheView
3416  *image_view;
3417 
3419  *exception;
3420 
3422  range_exception,
3423  status,
3424  taint;
3425 
3426  ssize_t
3427  y;
3428 
3429  assert(image != (Image *) NULL);
3430  if (image->debug != MagickFalse)
3431  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
3432  assert(image->signature == MagickSignature);
3433  if (image->storage_class == DirectClass)
3434  return(MagickFalse);
3435  range_exception=MagickFalse;
3436  status=MagickTrue;
3437  taint=image->taint;
3438  exception=(&image->exception);
3439  image_view=AcquireAuthenticCacheView(image,exception);
3440 #if defined(MAGICKCORE_OPENMP_SUPPORT)
3441  #pragma omp parallel for schedule(static,4) shared(range_exception,status) \
3442  magick_threads(image,image,image->rows,1)
3443 #endif
3444  for (y=0; y < (ssize_t) image->rows; y++)
3445  {
3446  IndexPacket
3447  index;
3448 
3449  register IndexPacket
3450  *restrict indexes;
3451 
3452  register PixelPacket
3453  *restrict q;
3454 
3455  register ssize_t
3456  x;
3457 
3458  if (status == MagickFalse)
3459  continue;
3460  q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
3461  if (q == (PixelPacket *) NULL)
3462  {
3463  status=MagickFalse;
3464  continue;
3465  }
3466  indexes=GetCacheViewAuthenticIndexQueue(image_view);
3467  for (x=0; x < (ssize_t) image->columns; x++)
3468  {
3469  index=PushColormapIndex(image,(size_t) GetPixelIndex(indexes+x),
3470  &range_exception);
3471  if (image->matte == MagickFalse)
3472  SetPixelRgb(q,image->colormap+(ssize_t) index)
3473  else
3474  SetPixelRGBO(q,image->colormap+(ssize_t) index);
3475  q++;
3476  }
3477  if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
3478  status=MagickFalse;
3479  }
3480  image_view=DestroyCacheView(image_view);
3481  image->taint=taint;
3482  if ((image->ping == MagickFalse) && (range_exception != MagickFalse))
3484  CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
3485  return(status);
3486 }
3487 
3488 /*
3489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3490 % %
3491 % %
3492 % %
3493 % S y n c I m a g e S e t t i n g s %
3494 % %
3495 % %
3496 % %
3497 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3498 %
3499 % SyncImageSettings() syncs image_info options into per-image attributes.
3500 %
3501 % The format of the SyncImageSettings method is:
3502 %
3503 % MagickBooleanType SyncImageSettings(const ImageInfo *image_info,
3504 % Image *image)
3505 % MagickBooleanType SyncImagesSettings(const ImageInfo *image_info,
3506 % Image *image)
3507 %
3508 % A description of each parameter follows:
3509 %
3510 % o image_info: the image info.
3511 %
3512 % o image: the image.
3513 %
3514 */
3515 
3517  Image *images)
3518 {
3519  Image
3520  *image;
3521 
3522  assert(image_info != (const ImageInfo *) NULL);
3523  assert(image_info->signature == MagickSignature);
3524  assert(images != (Image *) NULL);
3525  assert(images->signature == MagickSignature);
3526  if (images->debug != MagickFalse)
3527  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
3528  image=images;
3529  for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
3530  (void) SyncImageSettings(image_info,image);
3531  (void) DeleteImageOption(image_info,"page");
3532  return(MagickTrue);
3533 }
3534 
3536  Image *image)
3537 {
3538  char
3539  property[MaxTextExtent];
3540 
3541  const char
3542  *option,
3543  *value;
3544 
3545  GeometryInfo
3546  geometry_info;
3547 
3549  flags;
3550 
3552  units;
3553 
3554  /*
3555  Sync image options.
3556  */
3557  assert(image_info != (const ImageInfo *) NULL);
3558  assert(image_info->signature == MagickSignature);
3559  assert(image != (Image *) NULL);
3560  assert(image->signature == MagickSignature);
3561  if (image->debug != MagickFalse)
3562  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3563  option=GetImageOption(image_info,"background");
3564  if (option != (const char *) NULL)
3565  (void) QueryColorDatabase(option,&image->background_color,
3566  &image->exception);
3567  option=GetImageOption(image_info,"bias");
3568  if (option != (const char *) NULL)
3569  image->bias=StringToDoubleInterval(option,(double) QuantumRange+1.0);
3570  option=GetImageOption(image_info,"black-point-compensation");
3571  if (option != (const char *) NULL)
3574  option=GetImageOption(image_info,"blue-primary");
3575  if (option != (const char *) NULL)
3576  {
3577  flags=ParseGeometry(option,&geometry_info);
3578  image->chromaticity.blue_primary.x=geometry_info.rho;
3579  image->chromaticity.blue_primary.y=geometry_info.sigma;
3580  if ((flags & SigmaValue) == 0)
3582  }
3583  option=GetImageOption(image_info,"bordercolor");
3584  if (option != (const char *) NULL)
3585  (void) QueryColorDatabase(option,&image->border_color,&image->exception);
3586  option=GetImageOption(image_info,"colors");
3587  if (option != (const char *) NULL)
3588  image->colors=StringToUnsignedLong(option);
3589  option=GetImageOption(image_info,"compose");
3590  if (option != (const char *) NULL)
3592  MagickFalse,option);
3593  option=GetImageOption(image_info,"compress");
3594  if (option != (const char *) NULL)
3597  option=GetImageOption(image_info,"debug");
3598  if (option != (const char *) NULL)
3600  MagickFalse,option);
3601  option=GetImageOption(image_info,"density");
3602  if (option != (const char *) NULL)
3603  {
3604  GeometryInfo
3605  geometry_info;
3606 
3607  /*
3608  Set image density.
3609  */
3610  flags=ParseGeometry(option,&geometry_info);
3611  image->x_resolution=geometry_info.rho;
3612  image->y_resolution=geometry_info.sigma;
3613  if ((flags & SigmaValue) == 0)
3614  image->y_resolution=image->x_resolution;
3615  }
3616  option=GetImageOption(image_info,"depth");
3617  if (option != (const char *) NULL)
3618  image->depth=StringToUnsignedLong(option);
3619  option=GetImageOption(image_info,"endian");
3620  if (option != (const char *) NULL)
3622  MagickFalse,option);
3623  option=GetImageOption(image_info,"filter");
3624  if (option != (const char *) NULL)
3626  MagickFalse,option);
3627  option=GetImageOption(image_info,"fuzz");
3628  if (option != (const char *) NULL)
3629  image->fuzz=StringToDoubleInterval(option,(double) QuantumRange+1.0);
3630  option=GetImageOption(image_info,"gravity");
3631  if (option != (const char *) NULL)
3633  MagickFalse,option);
3634  option=GetImageOption(image_info,"green-primary");
3635  if (option != (const char *) NULL)
3636  {
3637  flags=ParseGeometry(option,&geometry_info);
3638  image->chromaticity.green_primary.x=geometry_info.rho;
3639  image->chromaticity.green_primary.y=geometry_info.sigma;
3640  if ((flags & SigmaValue) == 0)
3642  }
3643  option=GetImageOption(image_info,"intensity");
3644  if (option != (const char *) NULL)
3647  option=GetImageOption(image_info,"intent");
3648  if (option != (const char *) NULL)
3651  option=GetImageOption(image_info,"interlace");
3652  if (option != (const char *) NULL)
3654  MagickFalse,option);
3655  option=GetImageOption(image_info,"interpolate");
3656  if (option != (const char *) NULL)
3659  option=GetImageOption(image_info,"loop");
3660  if (option != (const char *) NULL)
3661  image->iterations=StringToUnsignedLong(option);
3662  option=GetImageOption(image_info,"mattecolor");
3663  if (option != (const char *) NULL)
3664  (void) QueryColorDatabase(option,&image->matte_color,&image->exception);
3665  option=GetImageOption(image_info,"orient");
3666  if (option != (const char *) NULL)
3669  option=GetImageOption(image_info,"page");
3670  if (option != (const char *) NULL)
3671  {
3672  char
3673  *geometry;
3674 
3675  geometry=GetPageGeometry(option);
3676  flags=ParseAbsoluteGeometry(geometry,&image->page);
3677  geometry=DestroyString(geometry);
3678  }
3679  option=GetImageOption(image_info,"quality");
3680  if (option != (const char *) NULL)
3681  image->quality=StringToUnsignedLong(option);
3682  option=GetImageOption(image_info,"red-primary");
3683  if (option != (const char *) NULL)
3684  {
3685  flags=ParseGeometry(option,&geometry_info);
3686  image->chromaticity.red_primary.x=geometry_info.rho;
3687  image->chromaticity.red_primary.y=geometry_info.sigma;
3688  if ((flags & SigmaValue) == 0)
3690  }
3691  if (image_info->quality != UndefinedCompressionQuality)
3692  image->quality=image_info->quality;
3693  option=GetImageOption(image_info,"scene");
3694  if (option != (const char *) NULL)
3695  image->scene=StringToUnsignedLong(option);
3696  option=GetImageOption(image_info,"taint");
3697  if (option != (const char *) NULL)
3699  MagickFalse,option);
3700  option=GetImageOption(image_info,"tile-offset");
3701  if (option != (const char *) NULL)
3702  {
3703  char
3704  *geometry;
3705 
3706  geometry=GetPageGeometry(option);
3707  flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3708  geometry=DestroyString(geometry);
3709  }
3710  option=GetImageOption(image_info,"transparent-color");
3711  if (option != (const char *) NULL)
3712  (void) QueryColorDatabase(option,&image->transparent_color,
3713  &image->exception);
3714  option=GetImageOption(image_info,"type");
3715  if (option != (const char *) NULL)
3717  option);
3718  option=GetImageOption(image_info,"units");
3719  if (option != (const char *) NULL)
3721  MagickFalse,option);
3722  else
3723  units = image_info->units;
3724  if (units != UndefinedResolution)
3725  {
3726  if (image->units != units)
3727  switch (image->units)
3728  {
3730  {
3731  if (units == PixelsPerCentimeterResolution)
3732  {
3733  image->x_resolution/=2.54;
3734  image->y_resolution/=2.54;
3735  }
3736  break;
3737  }
3739  {
3740  if (units == PixelsPerInchResolution)
3741  {
3742  image->x_resolution=(double) ((size_t) (100.0*2.54*
3743  image->x_resolution+0.5))/100.0;
3744  image->y_resolution=(double) ((size_t) (100.0*2.54*
3745  image->y_resolution+0.5))/100.0;
3746  }
3747  break;
3748  }
3749  default:
3750  break;
3751  }
3752  image->units=units;
3753  }
3754  option=GetImageOption(image_info,"white-point");
3755  if (option != (const char *) NULL)
3756  {
3757  flags=ParseGeometry(option,&geometry_info);
3758  image->chromaticity.white_point.x=geometry_info.rho;
3759  image->chromaticity.white_point.y=geometry_info.sigma;
3760  if ((flags & SigmaValue) == 0)
3762  }
3763  ResetImageOptionIterator(image_info);
3764  for (option=GetNextImageOption(image_info); option != (const char *) NULL; )
3765  {
3766  value=GetImageOption(image_info,option);
3767  if (value != (const char *) NULL)
3768  {
3769  (void) FormatLocaleString(property,MaxTextExtent,"%s",option);
3770  (void) SetImageArtifact(image,property,value);
3771  }
3772  option=GetNextImageOption(image_info);
3773  }
3774  return(MagickTrue);
3775 }
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:830
#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:1802
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:2502
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:3516
#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:3024
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:4900
MagickExport MagickStatusType ParseAbsoluteGeometry(const char *geometry, RectangleInfo *region_info)
Definition: geometry.c:663
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:414
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:3535
MagickExport Cache ReferencePixelCache(Cache)
Definition: cache.c:4524
MagickPrivate MagickBooleanType SyncImagePixelCache(Image *, ExceptionInfo *)
Definition: cache.c:5145
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:2364
static MagickBooleanType IsGrayColorspace(const ColorspaceType colorspace)
MagickExport void SetImageInfoBlob(ImageInfo *image_info, const void *blob, const size_t length)
Definition: image.c:2824
ResolutionType units
Definition: image.h:198
MagickExport MagickBooleanType SetImageChannels(Image *image, const size_t channels)
Definition: image.c:2243
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:1685
MagickExport MagickBooleanType SyncImage(Image *image)
Definition: image.c:3413
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:342
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:1837
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:2860
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:3404
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:33
#define MagickSignature
MagickExport MagickBooleanType IsGeometry(const char *geometry)
Definition: geometry.c:570
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:322
const double DefaultResolution
Definition: image.c:122
static ssize_t SmushXGap(const Image *smush_image, const Image *images, const ssize_t offset, ExceptionInfo *exception)
Definition: image.c:3069
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1199
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:119
MagickExport MagickBooleanType StripImage(Image *image)
Definition: image.c:3363
ClassType
Definition: magick-type.h:204
MagickExport void GetMagickPixelPacket(const Image *image, MagickPixelPacket *pixel)
Definition: pixel.c:2098
ExceptionInfo * exception
Definition: image-view.c:75
MagickExport const char * GetImageProperty(const Image *image, const char *property)
Definition: property.c:2053
const char PSPageGeometry[]
Definition: image.c:116
MagickBooleanType black_point_compensation
Definition: image.h: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:842
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:34
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:1533
const char LoadImagesTag[]
Definition: image.c:113
MagickExport MagickBooleanType IsStringTrue(const char *value)
Definition: string.c:1446
MagickExport MagickBooleanType IsEventLogging(void)
Definition: log.c:684
void * cache
Definition: image.h: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:3767
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:1380
MagickExport const char * GetImageOption(const ImageInfo *image_info, const char *key)
Definition: option.c:1873
MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info, const unsigned int frames, ExceptionInfo *exception)
Definition: image.c:2493
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:1633
MagickExport VirtualPixelMethod GetPixelCacheVirtualMethod(const Image *image)
Definition: cache.c:2314
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:402
MagickExport Image * SmushImages(const Image *images, const MagickBooleanType stack, const ssize_t offset, ExceptionInfo *exception)
Definition: image.c:3211
MagickExport MagickBooleanType OpenBlob(const ImageInfo *, Image *, const BlobMode, ExceptionInfo *)
MagickExport MagickBooleanType GetMagickAdjoin(const MagickInfo *magick_info)
Definition: magick.c:275
ssize_t x
Definition: geometry.h:128
MagickExport char * GetEnvironmentValue(const char *name)
Definition: string.c:1232
SemaphoreInfo * semaphore
Definition: image.h: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:2683
size_t height
Definition: geometry.h:124
const char DefaultTileFrame[]
Definition: image.c:108
MagickExport void CatchException(ExceptionInfo *exception)
Definition: exception.c:191
#define GetPixelIndex(indexes)
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:745
ssize_t offset
Definition: image.h: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:367
MagickExport MagickBooleanType IsBlobSeekable(const Image *image)
Definition: blob.c:2125
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:2449
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:475
#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:1709
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:1691
#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:2491
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:815
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:2094
MagickPrivate void DisassociateBlob(Image *)
Definition: blob.c:735
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:813
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:1539
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:2942
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:2680
MagickExport PixelPacket * QueueCacheViewAuthenticPixels(CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:881
PixelPacket * colormap
Definition: image.h: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:489
MagickExport char * CloneString(char **destination, const char *source)
Definition: string.c:267
#define Swap(x, y)
Definition: studio.h:361
MagickExport BlobInfo * ReferenceBlob(BlobInfo *)
Definition: blob.c:3605
MagickExport MagickBooleanType CloneImageArtifacts(Image *image, const Image *clone_image)
Definition: artifact.c:100
MagickExport MagickBooleanType NegateImage(Image *image, const MagickBooleanType grayscale)
Definition: enhance.c:3975
CompositeOperator compose
Definition: image.h: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:630
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:3140
Quantum IndexPacket
Definition: pixel.h:129
MagickExport MagickBooleanType SetImageColor(Image *image, const MagickPixelPacket *color)
Definition: image.c:2275
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:611
MagickExport MagickBooleanType SetImageClipMask(Image *image, const Image *clip_mask)
Definition: image.c:2398
#define AppendImageTag
#define SetPixelBlue(pixel, value)
MagickExport char * GetNextImageOption(const ImageInfo *image_info)
Definition: option.c:2136
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:2895
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
MagickExport MagickBooleanType CompositeImage(Image *image, const CompositeOperator compose, const Image *composite_image, const ssize_t x_offset, const ssize_t y_offset)
Definition: composite.c:1627
MagickPrivate MagickBooleanType ClearExceptionInfo(ExceptionInfo *, MagickBooleanType)
Definition: exception.c:404
MagickExport StringInfo * CloneStringInfo(const StringInfo *string_info)
Definition: string.c:319
MagickExport void DisassociateImageStream(Image *image)
Definition: image.c: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