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