MagickCore  6.8.5
constitute.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % CCCC OOO N N SSSSS TTTTT IIIII TTTTT U U TTTTT EEEEE %
7 % C O O NN N SS T I T U U T E %
8 % C O O N N N ESSS T I T U U T EEE %
9 % C O O N NN SS T I T U U T E %
10 % CCCC OOO N N SSSSS T IIIII T UUU T EEEEE %
11 % %
12 % %
13 % MagickCore Methods to Consitute an Image %
14 % %
15 % Software Design %
16 % John Cristy %
17 % October 1998 %
18 % %
19 % %
20 % Copyright 1999-2013 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  Include declarations.
41 */
42 #include "magick/studio.h"
43 #include "magick/attribute.h"
44 #include "magick/blob.h"
45 #include "magick/blob-private.h"
46 #include "magick/exception.h"
48 #include "magick/cache.h"
49 #include "magick/client.h"
51 #include "magick/constitute.h"
52 #include "magick/delegate.h"
53 #include "magick/geometry.h"
54 #include "magick/identify.h"
55 #include "magick/image-private.h"
56 #include "magick/list.h"
57 #include "magick/magick.h"
58 #include "magick/memory_.h"
59 #include "magick/monitor.h"
60 #include "magick/monitor-private.h"
61 #include "magick/option.h"
62 #include "magick/pixel.h"
63 #include "magick/policy.h"
64 #include "magick/profile.h"
65 #include "magick/property.h"
66 #include "magick/quantum.h"
67 #include "magick/resize.h"
68 #include "magick/resource_.h"
69 #include "magick/semaphore.h"
70 #include "magick/statistic.h"
71 #include "magick/stream.h"
72 #include "magick/string_.h"
73 #include "magick/string-private.h"
74 #include "magick/timer.h"
75 #include "magick/token.h"
76 #include "magick/transform.h"
77 #include "magick/utility.h"
78 
79 static SemaphoreInfo
81 
82 /*
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 % %
85 % %
86 % %
87 + C o n s t i t u t e C o m p o n e n t G e n e s i s %
88 % %
89 % %
90 % %
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 %
93 % ConstituteComponentGenesis() instantiates the constitute component.
94 %
95 % The format of the ConstituteComponentGenesis method is:
96 %
97 % MagickBooleanType ConstituteComponentGenesis(void)
98 %
99 */
101 {
103  return(MagickTrue);
104 }
105 
106 /*
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 % %
109 % %
110 % %
111 + C o n s t i t u t e C o m p o n e n t T e r m i n u s %
112 % %
113 % %
114 % %
115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 %
117 % ConstituteComponentTerminus() destroys the constitute component.
118 %
119 % The format of the ConstituteComponentTerminus method is:
120 %
121 % ConstituteComponentTerminus(void)
122 %
123 */
125 {
126  if (constitute_semaphore == (SemaphoreInfo *) NULL)
129 }
130 
131 /*
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133 % %
134 % %
135 % %
136 % C o n s t i t u t e I m a g e %
137 % %
138 % %
139 % %
140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141 %
142 % ConstituteImage() returns an image from the pixel data you supply.
143 % The pixel data must be in scanline order top-to-bottom. The data can be
144 % char, short int, int, float, or double. Float and double require the
145 % pixels to be normalized [0..1], otherwise [0..QuantumRange]. For example, to
146 % create a 640x480 image from unsigned red-green-blue character data, use:
147 %
148 % image = ConstituteImage(640,480,"RGB",CharPixel,pixels,&exception);
149 %
150 % The format of the ConstituteImage method is:
151 %
152 % Image *ConstituteImage(const size_t columns,const size_t rows,
153 % const char *map,const StorageType storage,const void *pixels,
154 % ExceptionInfo *exception)
155 %
156 % A description of each parameter follows:
157 %
158 % o columns: width in pixels of the image.
159 %
160 % o rows: height in pixels of the image.
161 %
162 % o map: This string reflects the expected ordering of the pixel array.
163 % It can be any combination or order of R = red, G = green, B = blue,
164 % A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan,
165 % Y = yellow, M = magenta, K = black, I = intensity (for grayscale),
166 % P = pad.
167 %
168 % o storage: Define the data type of the pixels. Float and double types are
169 % expected to be normalized [0..1] otherwise [0..QuantumRange]. Choose
170 % from these types: CharPixel, DoublePixel, FloatPixel, IntegerPixel,
171 % LongPixel, QuantumPixel, or ShortPixel.
172 %
173 % o pixels: This array of values contain the pixel components as defined by
174 % map and type. You must preallocate this array where the expected
175 % length varies depending on the values of width, height, map, and type.
176 %
177 % o exception: return any errors or warnings in this structure.
178 %
179 */
180 MagickExport Image *ConstituteImage(const size_t columns,
181  const size_t rows,const char *map,const StorageType storage,
182  const void *pixels,ExceptionInfo *exception)
183 {
184  Image
185  *image;
186 
188  status;
189 
190  /*
191  Allocate image structure.
192  */
193  assert(map != (const char *) NULL);
194  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",map);
195  assert(pixels != (void *) NULL);
196  assert(exception != (ExceptionInfo *) NULL);
197  assert(exception->signature == MagickSignature);
198  image=AcquireImage((ImageInfo *) NULL);
199  if (image == (Image *) NULL)
200  return((Image *) NULL);
201  if ((columns == 0) || (rows == 0))
202  ThrowImageException(OptionError,"NonZeroWidthAndHeightRequired");
203  image->columns=columns;
204  image->rows=rows;
205  (void) SetImageBackgroundColor(image);
206  status=ImportImagePixels(image,0,0,columns,rows,map,storage,pixels);
207  if (status == MagickFalse)
208  {
209  InheritException(exception,&image->exception);
210  image=DestroyImage(image);
211  }
212  return(image);
213 }
214 
215 /*
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217 % %
218 % %
219 % %
220 % P i n g I m a g e %
221 % %
222 % %
223 % %
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
225 %
226 % PingImage() returns all the properties of an image or image sequence
227 % except for the pixels. It is much faster and consumes far less memory
228 % than ReadImage(). On failure, a NULL image is returned and exception
229 % describes the reason for the failure.
230 %
231 % The format of the PingImage method is:
232 %
233 % Image *PingImage(const ImageInfo *image_info,ExceptionInfo *exception)
234 %
235 % A description of each parameter follows:
236 %
237 % o image_info: Ping the image defined by the file or filename members of
238 % this structure.
239 %
240 % o exception: return any errors or warnings in this structure.
241 %
242 */
243 
244 #if defined(__cplusplus) || defined(c_plusplus)
245 extern "C" {
246 #endif
247 
248 static size_t PingStream(const Image *magick_unused(image),
249  const void *magick_unused(pixels),const size_t columns)
250 {
251  return(columns);
252 }
253 
254 #if defined(__cplusplus) || defined(c_plusplus)
255 }
256 #endif
257 
259  ExceptionInfo *exception)
260 {
261  Image
262  *image;
263 
264  ImageInfo
265  *ping_info;
266 
267  assert(image_info != (ImageInfo *) NULL);
268  assert(image_info->signature == MagickSignature);
269  if (image_info->debug != MagickFalse)
271  image_info->filename);
272  assert(exception != (ExceptionInfo *) NULL);
273  ping_info=CloneImageInfo(image_info);
274  ping_info->ping=MagickTrue;
275  image=ReadStream(ping_info,&PingStream,exception);
276  if (image != (Image *) NULL)
277  {
278  ResetTimer(&image->timer);
279  if (ping_info->verbose != MagickFalse)
280  (void) IdentifyImage(image,stdout,MagickFalse);
281  }
282  ping_info=DestroyImageInfo(ping_info);
283  return(image);
284 }
285 
286 /*
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288 % %
289 % %
290 % %
291 % P i n g I m a g e s %
292 % %
293 % %
294 % %
295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
296 %
297 % PingImages() pings one or more images and returns them as an image list.
298 %
299 % The format of the PingImage method is:
300 %
301 % Image *PingImages(const ImageInfo *image_info,ExceptionInfo *exception)
302 %
303 % A description of each parameter follows:
304 %
305 % o image_info: the image info.
306 %
307 % o exception: return any errors or warnings in this structure.
308 %
309 */
311  ExceptionInfo *exception)
312 {
313  char
314  filename[MaxTextExtent];
315 
316  Image
317  *image,
318  *images;
319 
320  ImageInfo
321  *read_info;
322 
323  /*
324  Ping image list from a file.
325  */
326  assert(image_info != (ImageInfo *) NULL);
327  assert(image_info->signature == MagickSignature);
328  if (image_info->debug != MagickFalse)
330  image_info->filename);
331  assert(exception != (ExceptionInfo *) NULL);
332  (void) InterpretImageFilename(image_info,(Image *) NULL,image_info->filename,
333  (int) image_info->scene,filename);
334  if (LocaleCompare(filename,image_info->filename) != 0)
335  {
337  *sans;
338 
339  ssize_t
340  extent,
341  scene;
342 
343  /*
344  Images of the form image-%d.png[1-5].
345  */
346  read_info=CloneImageInfo(image_info);
347  sans=AcquireExceptionInfo();
348  (void) SetImageInfo(read_info,0,sans);
349  sans=DestroyExceptionInfo(sans);
350  if (read_info->number_scenes == 0)
351  {
352  read_info=DestroyImageInfo(read_info);
353  return(PingImage(image_info,exception));
354  }
355  (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
356  images=NewImageList();
357  extent=(ssize_t) (read_info->scene+read_info->number_scenes);
358  for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++)
359  {
360  (void) InterpretImageFilename(image_info,(Image *) NULL,filename,(int)
361  scene,read_info->filename);
362  image=PingImage(read_info,exception);
363  if (image == (Image *) NULL)
364  continue;
365  AppendImageToList(&images,image);
366  }
367  read_info=DestroyImageInfo(read_info);
368  return(images);
369  }
370  return(PingImage(image_info,exception));
371 }
372 
373 /*
374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
375 % %
376 % %
377 % %
378 % R e a d I m a g e %
379 % %
380 % %
381 % %
382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 %
384 % ReadImage() reads an image or image sequence from a file or file handle.
385 % The method returns a NULL if there is a memory shortage or if the image
386 % cannot be read. On failure, a NULL image is returned and exception
387 % describes the reason for the failure.
388 %
389 % The format of the ReadImage method is:
390 %
391 % Image *ReadImage(const ImageInfo *image_info,ExceptionInfo *exception)
392 %
393 % A description of each parameter follows:
394 %
395 % o image_info: Read the image defined by the file or filename members of
396 % this structure.
397 %
398 % o exception: return any errors or warnings in this structure.
399 %
400 */
402  ExceptionInfo *exception)
403 {
404  char
405  filename[MaxTextExtent],
406  magick[MaxTextExtent],
407  magick_filename[MaxTextExtent];
408 
409  const char
410  *value;
411 
412  const DelegateInfo
413  *delegate_info;
414 
415  const MagickInfo
416  *magick_info;
417 
419  *sans_exception;
420 
422  geometry_info;
423 
424  Image
425  *image,
426  *next;
427 
428  ImageInfo
429  *read_info;
430 
432  flags,
433  thread_support;
434 
436  domain;
437 
439  rights;
440 
441  /*
442  Determine image type from filename prefix or suffix (e.g. image.jpg).
443  */
444  assert(image_info != (ImageInfo *) NULL);
445  assert(image_info->signature == MagickSignature);
446  assert(image_info->filename != (char *) NULL);
447  if (image_info->debug != MagickFalse)
449  image_info->filename);
450  assert(exception != (ExceptionInfo *) NULL);
451  read_info=CloneImageInfo(image_info);
452  (void) CopyMagickString(magick_filename,read_info->filename,MaxTextExtent);
453  (void) SetImageInfo(read_info,0,exception);
454  (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
455  (void) CopyMagickString(magick,read_info->magick,MaxTextExtent);
456  domain=CoderPolicyDomain;
457  rights=ReadPolicyRights;
458  if (IsRightsAuthorized(domain,rights,read_info->magick) == MagickFalse)
459  {
460  errno=EPERM;
462  "NotAuthorized","`%s'",read_info->filename);
463  read_info=DestroyImageInfo(read_info);
464  return((Image *) NULL);
465  }
466  /*
467  Call appropriate image reader based on image type.
468  */
469  sans_exception=AcquireExceptionInfo();
470  magick_info=GetMagickInfo(read_info->magick,sans_exception);
471  sans_exception=DestroyExceptionInfo(sans_exception);
472  if (magick_info != (const MagickInfo *) NULL)
473  {
474  if (GetMagickEndianSupport(magick_info) == MagickFalse)
475  read_info->endian=UndefinedEndian;
476  else
477  if ((image_info->endian == UndefinedEndian) &&
478  (GetMagickRawSupport(magick_info) != MagickFalse))
479  {
480  size_t
481  lsb_first;
482 
483  lsb_first=1;
484  read_info->endian=(*(char *) &lsb_first) == 1 ? LSBEndian :
485  MSBEndian;
486  }
487  }
488  if ((magick_info != (const MagickInfo *) NULL) &&
489  (GetMagickSeekableStream(magick_info) != MagickFalse))
490  {
492  status;
493 
494  image=AcquireImage(read_info);
495  (void) CopyMagickString(image->filename,read_info->filename,
496  MaxTextExtent);
497  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
498  if (status == MagickFalse)
499  {
500  read_info=DestroyImageInfo(read_info);
501  image=DestroyImage(image);
502  return((Image *) NULL);
503  }
504  if (IsBlobSeekable(image) == MagickFalse)
505  {
506  /*
507  Coder requires a seekable stream.
508  */
509  *read_info->filename='\0';
510  status=ImageToFile(image,read_info->filename,exception);
511  if (status == MagickFalse)
512  {
513  (void) CloseBlob(image);
514  read_info=DestroyImageInfo(read_info);
515  image=DestroyImage(image);
516  return((Image *) NULL);
517  }
518  read_info->temporary=MagickTrue;
519  }
520  (void) CloseBlob(image);
521  image=DestroyImage(image);
522  }
523  image=NewImageList();
524  if (constitute_semaphore == (SemaphoreInfo *) NULL)
526  if ((magick_info == (const MagickInfo *) NULL) ||
527  (GetImageDecoder(magick_info) == (DecodeImageHandler *) NULL))
528  {
529  delegate_info=GetDelegateInfo(read_info->magick,(char *) NULL,exception);
530  if (delegate_info == (const DelegateInfo *) NULL)
531  {
532  (void) SetImageInfo(read_info,0,exception);
533  (void) CopyMagickString(read_info->filename,filename,MaxTextExtent);
534  magick_info=GetMagickInfo(read_info->magick,exception);
535  }
536  }
537  if ((magick_info != (const MagickInfo *) NULL) &&
538  (GetImageDecoder(magick_info) != (DecodeImageHandler *) NULL))
539  {
540  thread_support=GetMagickThreadSupport(magick_info);
541  if ((thread_support & DecoderThreadSupport) == 0)
543  image=GetImageDecoder(magick_info)(read_info,exception);
544  if ((thread_support & DecoderThreadSupport) == 0)
546  }
547  else
548  {
549  delegate_info=GetDelegateInfo(read_info->magick,(char *) NULL,exception);
550  if (delegate_info == (const DelegateInfo *) NULL)
551  {
552  (void) ThrowMagickException(exception,GetMagickModule(),
553  MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
554  read_info->filename);
555  if (read_info->temporary != MagickFalse)
556  (void) RelinquishUniqueFileResource(read_info->filename);
557  read_info=DestroyImageInfo(read_info);
558  return((Image *) NULL);
559  }
560  /*
561  Let our decoding delegate process the image.
562  */
563  image=AcquireImage(read_info);
564  if (image == (Image *) NULL)
565  {
566  read_info=DestroyImageInfo(read_info);
567  return((Image *) NULL);
568  }
569  (void) CopyMagickString(image->filename,read_info->filename,
570  MaxTextExtent);
571  *read_info->filename='\0';
572  if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
574  (void) InvokeDelegate(read_info,image,read_info->magick,(char *) NULL,
575  exception);
576  if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
578  image=DestroyImageList(image);
579  read_info->temporary=MagickTrue;
580  (void) SetImageInfo(read_info,0,exception);
581  magick_info=GetMagickInfo(read_info->magick,exception);
582  if ((magick_info == (const MagickInfo *) NULL) ||
583  (GetImageDecoder(magick_info) == (DecodeImageHandler *) NULL))
584  {
585  if (IsPathAccessible(read_info->filename) != MagickFalse)
586  (void) ThrowMagickException(exception,GetMagickModule(),
587  MissingDelegateError,"NoDecodeDelegateForThisImageFormat","`%s'",
588  read_info->filename);
589  else
590  ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
591  read_info->filename);
592  read_info=DestroyImageInfo(read_info);
593  return((Image *) NULL);
594  }
595  thread_support=GetMagickThreadSupport(magick_info);
596  if ((thread_support & DecoderThreadSupport) == 0)
598  image=(Image *) (GetImageDecoder(magick_info))(read_info,exception);
599  if ((thread_support & DecoderThreadSupport) == 0)
601  }
602  if (read_info->temporary != MagickFalse)
603  {
604  (void) RelinquishUniqueFileResource(read_info->filename);
605  read_info->temporary=MagickFalse;
606  if (image != (Image *) NULL)
607  (void) CopyMagickString(image->filename,filename,MaxTextExtent);
608  }
609  if (image == (Image *) NULL)
610  {
611  read_info=DestroyImageInfo(read_info);
612  return(image);
613  }
614  if (exception->severity >= ErrorException)
616  "Coder (%s) generated an image despite an error (%d), "
617  "notify the developers",image->magick,exception->severity);
618  if (IsBlobTemporary(image) != MagickFalse)
619  (void) RelinquishUniqueFileResource(read_info->filename);
620  if ((GetNextImageInList(image) != (Image *) NULL) &&
622  {
623  Image
624  *clones;
625 
626  clones=CloneImages(image,read_info->scenes,exception);
627  if (clones == (Image *) NULL)
629  "SubimageSpecificationReturnsNoImages","`%s'",read_info->filename);
630  else
631  {
632  image=DestroyImageList(image);
633  image=GetFirstImageInList(clones);
634  }
635  }
636  if (GetBlobError(image) != MagickFalse)
637  {
639  "AnErrorHasOccurredReadingFromFile",read_info->filename);
640  image=DestroyImageList(image);
641  read_info=DestroyImageInfo(read_info);
642  return((Image *) NULL);
643  }
644  for (next=image; next != (Image *) NULL; next=GetNextImageInList(next))
645  {
646  char
647  magick_path[MaxTextExtent],
648  *property,
649  timestamp[MaxTextExtent];
650 
651  const char
652  *option;
653 
654  const StringInfo
655  *profile;
656 
657  next->taint=MagickFalse;
658  GetPathComponent(magick_filename,MagickPath,magick_path);
659  if (*magick_path == '\0')
660  (void) CopyMagickString(next->magick,magick,MaxTextExtent);
661  (void) CopyMagickString(next->magick_filename,magick_filename,
662  MaxTextExtent);
663  if (IsBlobTemporary(image) != MagickFalse)
664  (void) CopyMagickString(next->filename,filename,MaxTextExtent);
665  if (next->magick_columns == 0)
666  next->magick_columns=next->columns;
667  if (next->magick_rows == 0)
668  next->magick_rows=next->rows;
669  value=GetImageProperty(next,"tiff:Orientation");
670  if (value == (char *) NULL)
671  value=GetImageProperty(next,"exif:Orientation");
672  if (value != (char *) NULL)
673  {
675  (void) DeleteImageProperty(next,"tiff:Orientation");
676  (void) DeleteImageProperty(next,"exif:Orientation");
677  }
678  value=GetImageProperty(next,"exif:XResolution");
679  if (value != (char *) NULL)
680  {
681  geometry_info.rho=next->x_resolution;
682  geometry_info.sigma=1.0;
683  flags=ParseGeometry(value,&geometry_info);
684  if (geometry_info.sigma != 0)
685  next->x_resolution=geometry_info.rho/geometry_info.sigma;
686  (void) DeleteImageProperty(next,"exif:XResolution");
687  }
688  value=GetImageProperty(next,"exif:YResolution");
689  if (value != (char *) NULL)
690  {
691  geometry_info.rho=next->y_resolution;
692  geometry_info.sigma=1.0;
693  flags=ParseGeometry(value,&geometry_info);
694  if (geometry_info.sigma != 0)
695  next->y_resolution=geometry_info.rho/geometry_info.sigma;
696  (void) DeleteImageProperty(next,"exif:YResolution");
697  }
698  value=GetImageProperty(next,"tiff:ResolutionUnit");
699  if (value == (char *) NULL)
700  value=GetImageProperty(next,"exif:ResolutionUnit");
701  if (value != (char *) NULL)
702  {
703  next->units=(ResolutionType) (StringToLong(value)-1);
704  (void) DeleteImageProperty(next,"exif:ResolutionUnit");
705  (void) DeleteImageProperty(next,"tiff:ResolutionUnit");
706  }
707  if (next->page.width == 0)
708  next->page.width=next->columns;
709  if (next->page.height == 0)
710  next->page.height=next->rows;
711  option=GetImageOption(read_info,"caption");
712  if (option != (const char *) NULL)
713  {
714  property=InterpretImageProperties(read_info,next,option);
715  (void) SetImageProperty(next,"caption",property);
716  property=DestroyString(property);
717  }
718  option=GetImageOption(read_info,"comment");
719  if (option != (const char *) NULL)
720  {
721  property=InterpretImageProperties(read_info,next,option);
722  (void) SetImageProperty(next,"comment",property);
723  property=DestroyString(property);
724  }
725  option=GetImageOption(read_info,"label");
726  if (option != (const char *) NULL)
727  {
728  property=InterpretImageProperties(read_info,next,option);
729  (void) SetImageProperty(next,"label",property);
730  property=DestroyString(property);
731  }
732  if (LocaleCompare(next->magick,"TEXT") == 0)
733  (void) ParseAbsoluteGeometry("0x0+0+0",&next->page);
734  if ((read_info->extract != (char *) NULL) &&
735  (read_info->stream == (StreamHandler) NULL))
736  {
738  geometry;
739 
740  flags=ParseAbsoluteGeometry(read_info->extract,&geometry);
741  if ((next->columns != geometry.width) ||
742  (next->rows != geometry.height))
743  {
744  if (((flags & XValue) != 0) || ((flags & YValue) != 0))
745  {
746  Image
747  *crop_image;
748 
749  crop_image=CropImage(next,&geometry,exception);
750  if (crop_image != (Image *) NULL)
751  ReplaceImageInList(&next,crop_image);
752  }
753  else
754  if (((flags & WidthValue) != 0) || ((flags & HeightValue) != 0))
755  {
756  Image
757  *size_image;
758 
759  flags=ParseRegionGeometry(next,read_info->extract,&geometry,
760  exception);
761  size_image=ResizeImage(next,geometry.width,geometry.height,
762  next->filter,next->blur,exception);
763  if (size_image != (Image *) NULL)
764  ReplaceImageInList(&next,size_image);
765  }
766  }
767  }
768  profile=GetImageProfile(next,"icc");
769  if (profile == (const StringInfo *) NULL)
770  profile=GetImageProfile(next,"icm");
771  if (profile != (const StringInfo *) NULL)
772  {
774  next->color_profile.info=GetStringInfoDatum(profile);
775  }
776  profile=GetImageProfile(next,"iptc");
777  if (profile == (const StringInfo *) NULL)
778  profile=GetImageProfile(next,"8bim");
779  if (profile != (const StringInfo *) NULL)
780  {
781  next->iptc_profile.length=GetStringInfoLength(profile);
782  next->iptc_profile.info=GetStringInfoDatum(profile);
783  }
784  (void) FormatMagickTime(GetBlobProperties(next)->st_mtime,MaxTextExtent,
785  timestamp);
786  (void) SetImageProperty(next,"date:modify",timestamp);
787  (void) FormatMagickTime(GetBlobProperties(next)->st_ctime,MaxTextExtent,
788  timestamp);
789  (void) SetImageProperty(next,"date:create",timestamp);
790  option=GetImageOption(image_info,"delay");
791  if (option != (const char *) NULL)
792  {
794  geometry_info;
795 
796  flags=ParseGeometry(option,&geometry_info);
797  if ((flags & GreaterValue) != 0)
798  {
799  if (next->delay > (size_t) floor(geometry_info.rho+0.5))
800  next->delay=(size_t) floor(geometry_info.rho+0.5);
801  }
802  else
803  if ((flags & LessValue) != 0)
804  {
805  if (next->delay < (size_t) floor(geometry_info.rho+0.5))
806  next->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
807  }
808  else
809  next->delay=(size_t) floor(geometry_info.rho+0.5);
810  if ((flags & SigmaValue) != 0)
811  next->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
812  }
813  option=GetImageOption(image_info,"dispose");
814  if (option != (const char *) NULL)
816  MagickFalse,option);
817  if (read_info->verbose != MagickFalse)
818  (void) IdentifyImage(next,stderr,MagickFalse);
819  image=next;
820  }
821  read_info=DestroyImageInfo(read_info);
822  return(GetFirstImageInList(image));
823 }
824 
825 /*
826 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
827 % %
828 % %
829 % %
830 % R e a d I m a g e s %
831 % %
832 % %
833 % %
834 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
835 %
836 % ReadImages() reads one or more images and returns them as an image list.
837 %
838 % The format of the ReadImage method is:
839 %
840 % Image *ReadImages(const ImageInfo *image_info,ExceptionInfo *exception)
841 %
842 % A description of each parameter follows:
843 %
844 % o image_info: the image info.
845 %
846 % o exception: return any errors or warnings in this structure.
847 %
848 */
850  ExceptionInfo *exception)
851 {
852  char
853  filename[MaxTextExtent];
854 
855  Image
856  *image,
857  *images;
858 
859  ImageInfo
860  *read_info;
861 
862  /*
863  Read image list from a file.
864  */
865  assert(image_info != (ImageInfo *) NULL);
866  assert(image_info->signature == MagickSignature);
867  if (image_info->debug != MagickFalse)
869  image_info->filename);
870  assert(exception != (ExceptionInfo *) NULL);
871  (void) InterpretImageFilename(image_info,(Image *) NULL,image_info->filename,
872  (int) image_info->scene,filename);
873  if (LocaleCompare(filename,image_info->filename) != 0)
874  {
876  *sans;
877 
878  ssize_t
879  extent,
880  scene;
881 
882  /*
883  Images of the form image-%d.png[1-5].
884  */
885  read_info=CloneImageInfo(image_info);
886  sans=AcquireExceptionInfo();
887  (void) SetImageInfo(read_info,0,sans);
888  sans=DestroyExceptionInfo(sans);
889  if (read_info->number_scenes == 0)
890  {
891  read_info=DestroyImageInfo(read_info);
892  return(ReadImage(image_info,exception));
893  }
894  (void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
895  images=NewImageList();
896  extent=(ssize_t) (read_info->scene+read_info->number_scenes);
897  for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++)
898  {
899  (void) InterpretImageFilename(image_info,(Image *) NULL,filename,(int)
900  scene,read_info->filename);
901  image=ReadImage(read_info,exception);
902  if (image == (Image *) NULL)
903  continue;
904  AppendImageToList(&images,image);
905  }
906  read_info=DestroyImageInfo(read_info);
907  return(images);
908  }
909  return(ReadImage(image_info,exception));
910 }
911 
912 /*
913 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
914 % %
915 % %
916 % %
917 + R e a d I n l i n e I m a g e %
918 % %
919 % %
920 % %
921 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
922 %
923 % ReadInlineImage() reads a Base64-encoded inline image or image sequence.
924 % The method returns a NULL if there is a memory shortage or if the image
925 % cannot be read. On failure, a NULL image is returned and exception
926 % describes the reason for the failure.
927 %
928 % The format of the ReadInlineImage method is:
929 %
930 % Image *ReadInlineImage(const ImageInfo *image_info,const char *content,
931 % ExceptionInfo *exception)
932 %
933 % A description of each parameter follows:
934 %
935 % o image_info: the image info.
936 %
937 % o content: the image encoded in Base64.
938 %
939 % o exception: return any errors or warnings in this structure.
940 %
941 */
943  const char *content,ExceptionInfo *exception)
944 {
945  Image
946  *image;
947 
948  ImageInfo
949  *read_info;
950 
951  unsigned char
952  *blob;
953 
954  size_t
955  length;
956 
957  register const char
958  *p;
959 
960  /*
961  Skip over header (e.g. data:image/gif;base64,).
962  */
963  image=NewImageList();
964  for (p=content; (*p != ',') && (*p != '\0'); p++) ;
965  if (*p == '\0')
966  ThrowReaderException(CorruptImageError,"CorruptImage");
967  p++;
968  length=0;
969  blob=Base64Decode(p,&length);
970  if (length == 0)
971  ThrowReaderException(CorruptImageError,"CorruptImage");
972  read_info=CloneImageInfo(image_info);
973  (void) SetImageInfoProgressMonitor(read_info,(MagickProgressMonitor) NULL,
974  (void *) NULL);
975  *read_info->filename='\0';
976  *read_info->magick='\0';
977  image=BlobToImage(read_info,blob,length,exception);
978  blob=(unsigned char *) RelinquishMagickMemory(blob);
979  read_info=DestroyImageInfo(read_info);
980  return(image);
981 }
982 
983 /*
984 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
985 % %
986 % %
987 % %
988 % W r i t e I m a g e %
989 % %
990 % %
991 % %
992 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
993 %
994 % WriteImage() writes an image or an image sequence to a file or file handle.
995 % If writing to a file is on disk, the name is defined by the filename member
996 % of the image structure. WriteImage() returns MagickFalse is there is a
997 % memory shortage or if the image cannot be written. Check the exception
998 % member of image to determine the cause for any failure.
999 %
1000 % The format of the WriteImage method is:
1001 %
1002 % MagickBooleanType WriteImage(const ImageInfo *image_info,Image *image)
1003 %
1004 % A description of each parameter follows:
1005 %
1006 % o image_info: the image info.
1007 %
1008 % o image: the image.
1009 %
1010 */
1012  Image *image)
1013 {
1014  char
1015  filename[MaxTextExtent];
1016 
1017  const char
1018  *option;
1019 
1020  const DelegateInfo
1021  *delegate_info;
1022 
1023  const MagickInfo
1024  *magick_info;
1025 
1027  *sans_exception;
1028 
1029  ImageInfo
1030  *write_info;
1031 
1033  status,
1034  temporary;
1035 
1037  thread_support;
1038 
1039  PolicyDomain
1040  domain;
1041 
1042  PolicyRights
1043  rights;
1044 
1045  /*
1046  Determine image type from filename prefix or suffix (e.g. image.jpg).
1047  */
1048  assert(image_info != (ImageInfo *) NULL);
1049  assert(image_info->signature == MagickSignature);
1050  if (image->debug != MagickFalse)
1052  image_info->filename);
1053  assert(image != (Image *) NULL);
1054  assert(image->signature == MagickSignature);
1055  sans_exception=AcquireExceptionInfo();
1056  write_info=CloneImageInfo(image_info);
1057  (void) CopyMagickString(write_info->filename,image->filename,MaxTextExtent);
1058  if (*write_info->magick == '\0')
1059  (void) CopyMagickString(write_info->magick,image->magick,MaxTextExtent);
1060  (void) SetImageInfo(write_info,1,sans_exception);
1061  if (LocaleCompare(write_info->magick,"clipmask") == 0)
1062  {
1063  if (image->clip_mask == (Image *) NULL)
1064  {
1066  OptionError,"NoClipPathDefined","`%s'",image->filename);
1067  write_info=DestroyImageInfo(write_info);
1068  return(MagickFalse);
1069  }
1070  image=image->clip_mask;
1071  (void) SetImageInfo(write_info,1,sans_exception);
1072  }
1073  (void) CopyMagickString(filename,image->filename,MaxTextExtent);
1074  (void) CopyMagickString(image->filename,write_info->filename,MaxTextExtent);
1075  domain=CoderPolicyDomain;
1076  rights=WritePolicyRights;
1077  if (IsRightsAuthorized(domain,rights,write_info->magick) == MagickFalse)
1078  {
1079  sans_exception=DestroyExceptionInfo(sans_exception);
1080  write_info=DestroyImageInfo(write_info);
1081  errno=EPERM;
1082  ThrowBinaryException(PolicyError,"NotAuthorized",filename);
1083  }
1084  /*
1085  Call appropriate image reader based on image type.
1086  */
1087  magick_info=GetMagickInfo(write_info->magick,sans_exception);
1088  sans_exception=DestroyExceptionInfo(sans_exception);
1089  if (magick_info != (const MagickInfo *) NULL)
1090  {
1091  if (GetMagickEndianSupport(magick_info) == MagickFalse)
1092  image->endian=UndefinedEndian;
1093  else
1094  if ((image_info->endian == UndefinedEndian) &&
1095  (GetMagickRawSupport(magick_info) != MagickFalse))
1096  {
1097  size_t
1098  lsb_first;
1099 
1100  lsb_first=1;
1101  image->endian=(*(char *) &lsb_first) == 1 ? LSBEndian : MSBEndian;
1102  }
1103  }
1104  (void) SyncImageProfiles(image);
1105  option=GetImageOption(image_info,"delegate:bimodal");
1106  if ((option != (const char *) NULL) &&
1107  (IsMagickTrue(option) != MagickFalse) &&
1108  (write_info->page == (char *) NULL) &&
1109  (GetPreviousImageInList(image) == (Image *) NULL) &&
1110  (GetNextImageInList(image) == (Image *) NULL) &&
1111  (IsTaintImage(image) == MagickFalse))
1112  {
1113  delegate_info=GetDelegateInfo(image->magick,write_info->magick,
1114  &image->exception);
1115  if ((delegate_info != (const DelegateInfo *) NULL) &&
1116  (GetDelegateMode(delegate_info) == 0) &&
1118  {
1119  /*
1120  Process image with bi-modal delegate.
1121  */
1122  (void) CopyMagickString(image->filename,image->magick_filename,
1123  MaxTextExtent);
1124  status=InvokeDelegate(write_info,image,image->magick,
1125  write_info->magick,&image->exception);
1126  write_info=DestroyImageInfo(write_info);
1127  (void) CopyMagickString(image->filename,filename,MaxTextExtent);
1128  return(status);
1129  }
1130  }
1131  status=MagickFalse;
1132  temporary=MagickFalse;
1133  if ((magick_info != (const MagickInfo *) NULL) &&
1134  (GetMagickSeekableStream(magick_info) != MagickFalse))
1135  {
1136  char
1137  filename[MaxTextExtent];
1138 
1139  (void) CopyMagickString(filename,image->filename,MaxTextExtent);
1140  status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
1141  (void) CopyMagickString(image->filename,filename,MaxTextExtent);
1142  if (status != MagickFalse)
1143  {
1144  if (IsBlobSeekable(image) == MagickFalse)
1145  {
1146  /*
1147  A seekable stream is required by the encoder.
1148  */
1149  write_info->adjoin=MagickTrue;
1150  (void) CopyMagickString(write_info->filename,image->filename,
1151  MaxTextExtent);
1152  (void) AcquireUniqueFilename(image->filename);
1153  temporary=MagickTrue;
1154  }
1155  (void) CloseBlob(image);
1156  }
1157  }
1158  if (constitute_semaphore == (SemaphoreInfo *) NULL)
1160  if ((magick_info != (const MagickInfo *) NULL) &&
1161  (GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
1162  {
1163  /*
1164  Call appropriate image writer based on image type.
1165  */
1166  thread_support=GetMagickThreadSupport(magick_info);
1167  if ((thread_support & EncoderThreadSupport) == 0)
1169  status=GetImageEncoder(magick_info)(write_info,image);
1170  if ((thread_support & EncoderThreadSupport) == 0)
1172  }
1173  else
1174  {
1175  delegate_info=GetDelegateInfo((char *) NULL,write_info->magick,
1176  &image->exception);
1177  if (delegate_info != (DelegateInfo *) NULL)
1178  {
1179  /*
1180  Process the image with delegate.
1181  */
1182  *write_info->filename='\0';
1183  if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
1185  status=InvokeDelegate(write_info,image,(char *) NULL,
1186  write_info->magick,&image->exception);
1187  if (GetDelegateThreadSupport(delegate_info) == MagickFalse)
1189  (void) CopyMagickString(image->filename,filename,MaxTextExtent);
1190  }
1191  else
1192  {
1193  sans_exception=AcquireExceptionInfo();
1194  magick_info=GetMagickInfo(write_info->magick,sans_exception);
1195  sans_exception=DestroyExceptionInfo(sans_exception);
1196  if ((write_info->affirm == MagickFalse) &&
1197  (magick_info == (const MagickInfo *) NULL))
1198  {
1199  (void) CopyMagickString(write_info->magick,image->magick,
1200  MaxTextExtent);
1201  magick_info=GetMagickInfo(write_info->magick,&image->exception);
1202  }
1203  if ((magick_info == (const MagickInfo *) NULL) ||
1204  (GetImageEncoder(magick_info) == (EncodeImageHandler *) NULL))
1205  {
1206  char
1207  extension[MaxTextExtent];
1208 
1209  GetPathComponent(image->filename,ExtensionPath,extension);
1210  if (*extension != '\0')
1211  magick_info=GetMagickInfo(extension,&image->exception);
1212  else
1213  magick_info=GetMagickInfo(image->magick,&image->exception);
1214  (void) CopyMagickString(image->filename,filename,MaxTextExtent);
1215  }
1216  if ((magick_info == (const MagickInfo *) NULL) ||
1217  (GetImageEncoder(magick_info) == (EncodeImageHandler *) NULL))
1218  {
1219  magick_info=GetMagickInfo(image->magick,&image->exception);
1220  if ((magick_info == (const MagickInfo *) NULL) ||
1221  (GetImageEncoder(magick_info) == (EncodeImageHandler *) NULL))
1223  MissingDelegateError,"NoEncodeDelegateForThisImageFormat",
1224  "`%s'",image->filename);
1225  else
1227  MissingDelegateWarning,"NoEncodeDelegateForThisImageFormat",
1228  "`%s'",image->filename);
1229  }
1230  if ((magick_info != (const MagickInfo *) NULL) &&
1231  (GetImageEncoder(magick_info) != (EncodeImageHandler *) NULL))
1232  {
1233  /*
1234  Call appropriate image writer based on image type.
1235  */
1236  thread_support=GetMagickThreadSupport(magick_info);
1237  if ((thread_support & EncoderThreadSupport) == 0)
1239  status=GetImageEncoder(magick_info)(write_info,image);
1240  if ((thread_support & EncoderThreadSupport) == 0)
1242  }
1243  }
1244  }
1245  if (GetBlobError(image) != MagickFalse)
1247  "AnErrorHasOccurredWritingToFile",image->filename);
1248  if (temporary == MagickTrue)
1249  {
1250  /*
1251  Copy temporary image file to permanent.
1252  */
1253  status=OpenBlob(write_info,image,ReadBinaryBlobMode,&image->exception);
1254  if (status != MagickFalse)
1255  {
1256  (void) RelinquishUniqueFileResource(write_info->filename);
1257  status=ImageToFile(image,write_info->filename,&image->exception);
1258  }
1259  (void) CloseBlob(image);
1260  (void) RelinquishUniqueFileResource(image->filename);
1261  (void) CopyMagickString(image->filename,write_info->filename,
1262  MaxTextExtent);
1263  }
1264  if ((LocaleCompare(write_info->magick,"info") != 0) &&
1265  (write_info->verbose != MagickFalse))
1266  (void) IdentifyImage(image,stderr,MagickFalse);
1267  write_info=DestroyImageInfo(write_info);
1268  return(status);
1269 }
1270 
1271 /*
1272 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1273 % %
1274 % %
1275 % %
1276 % W r i t e I m a g e s %
1277 % %
1278 % %
1279 % %
1280 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1281 %
1282 % WriteImages() writes an image sequence into one or more files. While
1283 % WriteImage() can write an image sequence, it is limited to writing
1284 % the sequence into a single file using a format which supports multiple
1285 % frames. WriteImages(), however, does not have this limitation, instead it
1286 % generates multiple output files if necessary (or when requested). When
1287 % ImageInfo's adjoin flag is set to MagickFalse, the file name is expected
1288 % to include a printf-style formatting string for the frame number (e.g.
1289 % "image%02d.png").
1290 %
1291 % The format of the WriteImages method is:
1292 %
1293 % MagickBooleanType WriteImages(const ImageInfo *image_info,Image *images,
1294 % const char *filename,ExceptionInfo *exception)
1295 %
1296 % A description of each parameter follows:
1297 %
1298 % o image_info: the image info.
1299 %
1300 % o images: the image list.
1301 %
1302 % o filename: the image filename.
1303 %
1304 % o exception: return any errors or warnings in this structure.
1305 %
1306 */
1308  Image *images,const char *filename,ExceptionInfo *exception)
1309 {
1310 #define WriteImageTag "Write/Image"
1311 
1312  BlobInfo
1313  *blob;
1314 
1316  *sans_exception;
1317 
1318  ImageInfo
1319  *write_info;
1320 
1322  proceed;
1323 
1325  i;
1326 
1328  progress_monitor;
1329 
1331  number_images;
1332 
1334  status;
1335 
1336  register Image
1337  *p;
1338 
1339  assert(image_info != (const ImageInfo *) NULL);
1340  assert(image_info->signature == MagickSignature);
1341  assert(images != (Image *) NULL);
1342  assert(images->signature == MagickSignature);
1343  if (images->debug != MagickFalse)
1344  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename);
1345  assert(exception != (ExceptionInfo *) NULL);
1346  write_info=CloneImageInfo(image_info);
1347  images=GetFirstImageInList(images);
1348  blob=CloneBlobInfo(images->blob); /* thread specific I/O handler */
1349  DestroyBlob(images);
1350  images->blob=blob;
1351  if (filename != (const char *) NULL)
1352  for (p=images; p != (Image *) NULL; p=GetNextImageInList(p))
1353  (void) CopyMagickString(p->filename,filename,MaxTextExtent);
1354  (void) CopyMagickString(write_info->filename,images->filename,MaxTextExtent);
1355  if (*write_info->magick == '\0')
1356  (void) CopyMagickString(write_info->magick,images->magick,MaxTextExtent);
1357  sans_exception=AcquireExceptionInfo();
1358  (void) SetImageInfo(write_info,(unsigned int) GetImageListLength(images),
1359  sans_exception);
1360  sans_exception=DestroyExceptionInfo(sans_exception);
1361  p=images;
1362  for ( ; GetNextImageInList(p) != (Image *) NULL; p=GetNextImageInList(p))
1363  if (p->scene >= GetNextImageInList(p)->scene)
1364  {
1365  register ssize_t
1366  i;
1367 
1368  /*
1369  Generate consistent scene numbers.
1370  */
1371  i=(ssize_t) images->scene;
1372  for (p=images; p != (Image *) NULL; p=GetNextImageInList(p))
1373  p->scene=(size_t) i++;
1374  break;
1375  }
1376  /*
1377  Write images.
1378  */
1379  status=MagickTrue;
1380  progress_monitor=(MagickProgressMonitor) NULL;
1381  i=0;
1382  number_images=GetImageListLength(images);
1383  for (p=images; p != (Image *) NULL; p=GetNextImageInList(p))
1384  {
1385  if (number_images != 1)
1386  progress_monitor=SetImageProgressMonitor(p,(MagickProgressMonitor) NULL,
1387  p->client_data);
1388  status&=WriteImage(write_info,p);
1389  GetImageException(p,exception);
1390  if (number_images != 1)
1391  (void) SetImageProgressMonitor(p,progress_monitor,p->client_data);
1392  if (write_info->adjoin != MagickFalse)
1393  break;
1394  if (number_images != 1)
1395  {
1396  proceed=SetImageProgress(p,WriteImageTag,i++,number_images);
1397  if (proceed == MagickFalse)
1398  break;
1399  }
1400  }
1401  write_info=DestroyImageInfo(write_info);
1402  return(status != 0 ? MagickTrue : MagickFalse);
1403 }